edbee - Qt Editor Library
Public Member Functions | List of all members
edbee::ChangeGroup Class Referenceabstract

An undoable-command-group. More...

#include <change.h>

+ Inheritance diagram for edbee::ChangeGroup:
+ Collaboration diagram for edbee::ChangeGroup:

Public Member Functions

 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 bool isDiscardable ()
 This method is called it the group is discardable. A discardable group will be optimized away if the group is empty, or if there's a single item in the group. A none-discardable group will always remain. More...
 
virtual void groupClosed ()
 This method is called if the group is closed and is added to the stack Default implementation is to do nothing. More...
 
virtual void execute (TextDocument *document)
 executes this command group More...
 
virtual void revert (TextDocument *document)
 Reverts the command gorup. More...
 
virtual bool giveAndMerge (TextDocument *document, Change *textChange)=0
 Gives the change and merges it if possible. This method should return false if the change couldn't be merged. When the method returns true the ownership of the given textchange is transfered to this class. More...
 
virtual void flatten ()
 This method flattens the undo-group by expanding all subgroups to local groups. More...
 
virtual void giveChange (TextDocument *doc, Change *change)=0
 
virtual Changeat (int idx)=0
 
virtual Changetake (int idx)=0
 
virtual int size ()=0
 
virtual void clear (bool performDelete=true)=0
 
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...
 
virtual QString toString ()
 Converts this change group to a string. 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...
 

Detailed Description

An undoable-command-group.

Constructor & Destructor Documentation

◆ ChangeGroup()

edbee::ChangeGroup::ChangeGroup ( TextEditorController controller)

default contructor

Parameters
controllerthe controller this groups belongs to

◆ ~ChangeGroup()

edbee::ChangeGroup::~ChangeGroup ( )
virtual

The destructor deletes all added textchanges.

Member Function Documentation

◆ at()

virtual Change* edbee::ChangeGroup::at ( int  idx)
pure virtual

Implemented in edbee::MergableChangeGroup.

◆ clear()

virtual void edbee::ChangeGroup::clear ( bool  performDelete = true)
pure virtual

Implemented in edbee::MergableChangeGroup.

◆ controllerContext()

TextEditorController * edbee::ChangeGroup::controllerContext ( )
virtual

if this commandgroup only contains commands for a single controller context Then this context is returned else 0 is returned

0 is always 0!

Reimplemented from edbee::ControllerChange.

◆ execute()

void edbee::ChangeGroup::execute ( TextDocument document)
virtual

executes this command group

Parameters
documentthe document the document to execute this for

Implements edbee::Change.

Reimplemented in edbee::MergableChangeGroup.

◆ flatten()

void edbee::ChangeGroup::flatten ( )
virtual

This method flattens the undo-group by expanding all subgroups to local groups.

◆ giveAndMerge()

virtual bool edbee::ChangeGroup::giveAndMerge ( TextDocument document,
Change textChange 
)
pure virtual

Gives the change and merges it if possible. This method should return false if the change couldn't be merged. When the method returns true the ownership of the given textchange is transfered to this class.

Parameters
documentthe document this change is for
textChangethe textchange
Returns
true if the merge succeeded. The textChange ownership is only tranfered if true if returend

Reimplemented from edbee::Change.

Implemented in edbee::MergableChangeGroup.

◆ giveChange()

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

Implemented in edbee::MergableChangeGroup.

◆ groupClosed()

void edbee::ChangeGroup::groupClosed ( )
virtual

This method is called if the group is closed and is added to the stack Default implementation is to do nothing.

Reimplemented in edbee::MergableChangeGroup.

◆ isDiscardable()

bool edbee::ChangeGroup::isDiscardable ( )
virtual

This method is called it the group is discardable. A discardable group will be optimized away if the group is empty, or if there's a single item in the group. A none-discardable group will always remain.

Reimplemented in edbee::MergableChangeGroup.

◆ isGroup()

bool edbee::ChangeGroup::isGroup ( )
virtual

A group change is a group change, so this method returns true :)

Reimplemented from edbee::Change.

◆ last()

Change * edbee::ChangeGroup::last ( )

This method returns the last change in the change group.

Returns
the last textchange

◆ recursiveSize()

int edbee::ChangeGroup::recursiveSize ( )

The total number of items in the list (excluding the group items)

Returns
the number of items recussive (iterating) all groups

◆ revert()

void edbee::ChangeGroup::revert ( TextDocument document)
virtual

Reverts the command gorup.

Reimplemented from edbee::Change.

Reimplemented in edbee::MergableChangeGroup.

◆ size()

virtual int edbee::ChangeGroup::size ( )
pure virtual

Implemented in edbee::MergableChangeGroup.

◆ take()

virtual Change* edbee::ChangeGroup::take ( int  idx)
pure virtual

Implemented in edbee::MergableChangeGroup.

◆ takeLast()

Change * edbee::ChangeGroup::takeLast ( )

Takes the ownership of the last element and removes it from the stack.

Returns
the last textchange

◆ toString()

QString edbee::ChangeGroup::toString ( )
virtual

Converts this change group to a string.

Implements edbee::Change.

Reimplemented in edbee::MergableChangeGroup.


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