edbee - Qt Editor Library
Public Member Functions | Protected Member Functions | List of all members
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. More...
 
virtual ~MergableChangeGroup ()
 The default destructor. More...
 
virtual bool isDiscardable ()
 default not discardable More...
 
virtual void groupClosed ()
 the group is closed, we must 'store' the selection More...
 
virtual void execute (TextDocument *document)
 Executes this textchange. More...
 
virtual void revert (TextDocument *document)
 this method is called to revert the operation reverts the given operation More...
 
void giveSingleTextChange (TextDocument *doc, TextChange *change)
 Gives a single textchange. More...
 
void giveLineDataListTextChange (TextDocument *doc, LineDataListChange *change)
 gives a line data list text change More...
 
virtual void giveChange (TextDocument *doc, Change *change)
 Gives the change. More...
 
virtual Changeat (int idx)
 returns the textchange at the given index More...
 
virtual Changetake (int idx)
 Takes the given item. More...
 
virtual int size ()
 returns the number of elements More...
 
virtual void clear (bool performDelete=true)
 clears all items More...
 
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. More...
 
virtual QString toString ()
 Converts this textchange to a textual representation. More...
 
QString toSingleTextChangeTestString ()
 Converts the textchangeList as as string The format is the following: <offset>:<length>:<str>,... More...
 
void moveChangesFromGroup (TextDocument *doc, ChangeGroup *group)
 Moves all textchanges from the given group to this group. More...
 
- Public Member Functions inherited from edbee::ChangeGroup
 ChangeGroup (TextEditorController *controller)
 default contructor More...
 
virtual ~ChangeGroup ()
 The destructor deletes all added textchanges. More...
 
virtual bool isGroup ()
 A group change is a group change, so this method returns true :) More...
 
virtual void flatten ()
 This method flattens the undo-group by expanding all subgroups to local groups. More...
 
Changelast ()
 This method returns the last change in the change group. More...
 
ChangetakeLast ()
 Takes the ownership of the last element and removes it from the stack. More...
 
int recursiveSize ()
 The total number of items in the list (excluding the group items) More...
 
virtual TextEditorControllercontrollerContext ()
 if this commandgroup only contains commands for a single controller context Then this context is returned else 0 is returned More...
 
- Public Member Functions inherited from edbee::ControllerChange
 ControllerChange (TextEditorController *controller)
 A controller specific textcommand. Warning you should NOT modify the textdocument! More...
 
virtual TextEditorControllercontroller ()
 returns the controller More...
 
- Public Member Functions inherited from edbee::Change
virtual ~Change ()
 a virtual empty destructor More...
 
virtual bool canUndo ()
 This method should return true if the change can be reverted. More...
 
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. More...
 
bool isDocumentChange ()
 this method can be used to check if the given change is a document change More...
 

Protected Member Functions

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

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

Implements edbee::ChangeGroup.

◆ clear()

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

clears all items

Implements 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

Implements edbee::ChangeGroup.

◆ giveChange()

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

Gives the change.

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

Implements 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

Implements edbee::ChangeGroup.

◆ take()

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

Takes the given item.

Implements 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: