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>
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 Change * | at (int idx) |
returns the textchange at the given index | |
virtual Change * | take (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. | |
![]() | |
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. | |
Change * | last () |
This method returns the last change in the change group. | |
Change * | takeLast () |
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 TextEditorController * | controllerContext () |
if this commandgroup only contains commands for a single controller context Then this context is returned else 0 is returned | |
![]() | |
ControllerChange (TextEditorController *controller) | |
A controller specific textcommand. Warning you should NOT modify the textdocument! | |
virtual TextEditorController * | controller () |
returns the controller | |
![]() | |
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. | |
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.
edbee::MergableChangeGroup::MergableChangeGroup | ( | TextEditorController * | controller | ) |
The default complex textchange constructor.
|
virtual |
The default destructor.
|
virtual |
returns the textchange at the given index
Reimplemented from edbee::ChangeGroup.
|
virtual |
clears all items
Reimplemented from edbee::ChangeGroup.
|
protected |
This is going to be the magic method that's going to merge all changes.
document | the document to merge the changes for |
|
protected |
Compresses the textchanges.
document | the document to merge the changes for |
|
virtual |
Executes this textchange.
document | the document to execute this operation for |
Reimplemented from edbee::ChangeGroup.
|
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
textChange | the textchange to merge |
Reimplemented from edbee::ChangeGroup.
|
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.
void edbee::MergableChangeGroup::giveLineDataListTextChange | ( | TextDocument * | doc, |
LineDataListChange * | change ) |
gives a line data list text change
void edbee::MergableChangeGroup::giveSingleTextChange | ( | TextDocument * | doc, |
TextChange * | change ) |
Gives a single textchange.
|
virtual |
the group is closed, we must 'store' the selection
Reimplemented from edbee::ChangeGroup.
|
virtual |
default not discardable
Reimplemented from edbee::ChangeGroup.
|
protected |
merges the given textchange as a group.
document | the document this merge is for |
textChange | the textchange to merge |
|
protected |
document | the document this merge is for |
textChange | the textchange to merge |
void edbee::MergableChangeGroup::moveChangesFromGroup | ( | TextDocument * | doc, |
ChangeGroup * | group ) |
Moves all textchanges from the given group to this group.
group | the group to move the selection from |
|
virtual |
this method is called to revert the operation reverts the given operation
Reimplemented from edbee::ChangeGroup.
|
virtual |
returns the number of elements
Reimplemented from edbee::ChangeGroup.
|
virtual |
Takes the given item.
Reimplemented from edbee::ChangeGroup.
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
|
virtual |
Converts this textchange to a textual representation.
Reimplemented from edbee::ChangeGroup.