edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
edbee::MergableChangeGroup Class Reference

A special mergable group textchange. Used by the editor to merge editing operation together.. I hate the name, but currently don't know a better name of this class :) More...

#include <mergablechangegroup.h>

+ Inheritance diagram for edbee::MergableChangeGroup:
+ Collaboration diagram for edbee::MergableChangeGroup:

Public Member Functions

 MergableChangeGroup (TextEditorController *controller)
 The default complex textchange constructor.
 
virtual ~MergableChangeGroup ()
 The default destructor.
 
virtual bool isDiscardable ()
 default not discardable
 
virtual void groupClosed ()
 the group is closed, we must 'store' the selection
 
virtual void execute (TextDocument *document)
 Executes this textchange.
 
virtual void revert (TextDocument *document)
 this method is called to revert the operation reverts the given operation
 
void giveSingleTextChange (TextDocument *doc, TextChange *change)
 Gives a single textchange.
 
void giveLineDataListTextChange (TextDocument *doc, LineDataListChange *change)
 gives a line data list text change
 
virtual void giveChange (TextDocument *doc, Change *change)
 Gives the change.
 
virtual Changeat (int idx)
 returns the textchange at the given index
 
virtual Changetake (int idx)
 Takes the given item.
 
virtual int size ()
 returns the number of elements
 
virtual void clear (bool performDelete=true)
 clears all items
 
virtual bool giveAndMerge (TextDocument *document, Change *textChange)
 This method tries to merge the given change with the other change The textChange supplied with this method should NOT have been executed yet. It's the choice of this merge operation if the execution is required.
 
virtual QString toString ()
 Converts this textchange to a textual representation.
 
QString toSingleTextChangeTestString ()
 Converts the textchangeList as as string The format is the following: <offset>:<length>:<str>,...
 
void moveChangesFromGroup (TextDocument *doc, ChangeGroup *group)
 Moves all textchanges from the given group to this group.
 
- Public Member Functions inherited from edbee::ChangeGroup
 ChangeGroup (TextEditorController *controller)
 default contructor
 
virtual ~ChangeGroup ()
 The destructor deletes all added textchanges.
 
virtual bool isGroup ()
 A group change is a group change, so this method returns true :)
 
virtual void flatten ()
 This method flattens the undo-group by expanding all subgroups to local groups.
 
Changelast ()
 This method returns the last change in the change group.
 
ChangetakeLast ()
 Takes the ownership of the last element and removes it from the stack.
 
int recursiveSize ()
 The total number of items in the list (excluding the group items)
 
virtual TextEditorControllercontrollerContext ()
 if this commandgroup only contains commands for a single controller context Then this context is returned else 0 is returned
 
- Public Member Functions inherited from edbee::ControllerChange
 ControllerChange (TextEditorController *controller)
 A controller specific textcommand. Warning you should NOT modify the textdocument!
 
virtual TextEditorControllercontroller ()
 returns the controller
 
- Public Member Functions inherited from edbee::Change
virtual ~Change ()
 a virtual empty destructor
 
virtual bool canUndo ()
 This method should return true if the change can be reverted.
 
virtual bool isPersistenceRequired ()
 This flag is used to mark this stack item as non-persistence requirable The default behaviour is that every textchange requires persistence. It is also possible to have certain changes that do not require persitence but should be placed on the undo stack.
 
bool isDocumentChange ()
 this method can be used to check if the given change is a document change
 

Protected Member Functions

bool mergeAsGroup (TextDocument *document, Change *textChange)
 merges the given textchange as a group.
 
bool mergeAsSelection (TextDocument *document, Change *textChange)
 
void compressTextChanges (TextDocument *document)
 Compresses the textchanges.
 
void compressChanges (TextDocument *document)
 This is going to be the magic method that's going to merge all changes.
 

Detailed Description

A special mergable group textchange. Used by the editor to merge editing operation together.. I hate the name, but currently don't know a better name of this class :)

This is a complete rewrite of the earlier implementation. This implemenation simply adds all changes to a group. It tries to compress the changes that are compressable This group has 1 previous selection and 1 next selection. All selection changes are 'removed' and only the last and first state is stored.

Constructor & Destructor Documentation

◆ MergableChangeGroup()

edbee::MergableChangeGroup::MergableChangeGroup ( TextEditorController * controller)

The default complex textchange constructor.

◆ ~MergableChangeGroup()

edbee::MergableChangeGroup::~MergableChangeGroup ( )
virtual

The default destructor.

Member Function Documentation

◆ at()

Change * edbee::MergableChangeGroup::at ( int idx)
virtual

returns the textchange at the given index

Reimplemented from edbee::ChangeGroup.

◆ clear()

void edbee::MergableChangeGroup::clear ( bool performDelete = true)
virtual

clears all items

Reimplemented from edbee::ChangeGroup.

◆ compressChanges()

void edbee::MergableChangeGroup::compressChanges ( TextDocument * document)
protected

This is going to be the magic method that's going to merge all changes.

Parameters
documentthe document to merge the changes for

◆ compressTextChanges()

void edbee::MergableChangeGroup::compressTextChanges ( TextDocument * document)
protected

Compresses the textchanges.

Parameters
documentthe document to merge the changes for

◆ execute()

void edbee::MergableChangeGroup::execute ( TextDocument * document)
virtual

Executes this textchange.

Parameters
documentthe document to execute this operation for

Reimplemented from edbee::ChangeGroup.

◆ giveAndMerge()

bool edbee::MergableChangeGroup::giveAndMerge ( TextDocument * document,
Change * textChange )
virtual

This method tries to merge the given change with the other change The textChange supplied with this method should NOT have been executed yet. It's the choice of this merge operation if the execution is required.

this method tries to merge the textchange with this text change

Parameters
textChangethe textchange to merge
Returns
true if the merge has been successfull. False if nothing has been merged and executed

Reimplemented from edbee::ChangeGroup.

◆ giveChange()

void edbee::MergableChangeGroup::giveChange ( TextDocument * doc,
Change * change )
virtual

Gives the change.

we can simply delete the change, the ComplexTextChange automatically records the last change selection on the undoGroupEnd

Reimplemented from edbee::ChangeGroup.

◆ giveLineDataListTextChange()

void edbee::MergableChangeGroup::giveLineDataListTextChange ( TextDocument * doc,
LineDataListChange * change )

gives a line data list text change

◆ giveSingleTextChange()

void edbee::MergableChangeGroup::giveSingleTextChange ( TextDocument * doc,
TextChange * change )

Gives a single textchange.

Todo
: void giveAbstractRangedTextChange( TextDocument* doc, QList<AbstractRangedTextChange* changeList>& changes, AbstractRangedTextChange* change );

◆ groupClosed()

void edbee::MergableChangeGroup::groupClosed ( )
virtual

the group is closed, we must 'store' the selection

Reimplemented from edbee::ChangeGroup.

◆ isDiscardable()

bool edbee::MergableChangeGroup::isDiscardable ( )
virtual

default not discardable

Reimplemented from edbee::ChangeGroup.

◆ mergeAsGroup()

bool edbee::MergableChangeGroup::mergeAsGroup ( TextDocument * document,
Change * textChange )
protected

merges the given textchange as a group.

Parameters
documentthe document this merge is for
textChangethe textchange to merge
Returns
true if the textchange was merged as group.

◆ mergeAsSelection()

bool edbee::MergableChangeGroup::mergeAsSelection ( TextDocument * document,
Change * textChange )
protected
Parameters
documentthe document this merge is for
textChangethe textchange to merge
Returns
true if the textchange was merged as group.

◆ moveChangesFromGroup()

void edbee::MergableChangeGroup::moveChangesFromGroup ( TextDocument * doc,
ChangeGroup * group )

Moves all textchanges from the given group to this group.

Parameters
groupthe group to move the selection from

◆ revert()

void edbee::MergableChangeGroup::revert ( TextDocument * document)
virtual

this method is called to revert the operation reverts the given operation

Reimplemented from edbee::ChangeGroup.

◆ size()

int edbee::MergableChangeGroup::size ( )
virtual

returns the number of elements

Reimplemented from edbee::ChangeGroup.

◆ take()

Change * edbee::MergableChangeGroup::take ( int idx)
virtual

Takes the given item.

Reimplemented from edbee::ChangeGroup.

◆ toSingleTextChangeTestString()

QString edbee::MergableChangeGroup::toSingleTextChangeTestString ( )

Converts the textchangeList as as string The format is the following: <offset>:<length>:<str>,...

sample: 0:2:ABC,1:2:QW

◆ toString()

QString edbee::MergableChangeGroup::toString ( )
virtual

Converts this textchange to a textual representation.

Reimplemented from edbee::ChangeGroup.


The documentation for this class was generated from the following files: