edbee - Qt Editor Library
|
This is the undo stack for the texteditor. This stack is SHARED by all views of the document The stack also stores view-specific commands of all views. More...
#include <textundostack.h>
Public Types | |
enum | EndUndoGroupAction { ActionUngrouped, ActionFullDiscard, ActionEnd } |
This enumeration is signaled to the listeners to notify what happend when ending an undo group. More... | |
Signals | |
void | undoGroupStarted (edbee::ChangeGroup *group) |
void | undoGroupEnded (int coalesceId, bool merged, int action) |
This signal is fired when the group is ended. Warning, when the group is merged the group pointer will be 0!! More... | |
void | changeAdded (edbee::Change *change) |
void | undoExecuted (edbee::Change *change) |
void | redoExecuted (edbee::Change *change) |
void | persistedChanged (bool persisted) |
This signal is emitted if the persisted state is changed. More... | |
Public Member Functions | |
TextUndoStack (TextDocument *doc, QObject *parent=0) | |
Constructs the main undostack. More... | |
virtual | ~TextUndoStack () |
the undo stack items More... | |
void | clear () |
clears both stacks More... | |
void | registerContoller (TextEditorController *controller) |
Registers acontroller for it's own view pointer. More... | |
void | unregisterController (TextEditorController *controller) |
Unregisters the given controller. More... | |
bool | isControllerRegistered (TextEditorController *controller) |
Checks if the given controller is registered. More... | |
void | beginUndoGroup (ChangeGroup *group) |
Starts an undo group (or increase nest-level-counter) More... | |
ChangeGroup * | currentGroup () |
This method returns the current active group. More... | |
void | endUndoGroup (int coalesceId, bool flatten) |
Ends the undogroup. More... | |
void | endUndoGroupAndDiscard () |
Ends the undo-group and discards all content. More... | |
int | undoGroupLevel () |
returns the number of stacked undo-groups More... | |
int | lastCoalesceIdAtCurrentLevel () |
returns the last coalesceId at the given level More... | |
void | setLastCoalesceIdAtCurrentLevel (int id) |
Sets the last coalesceId at the current level. More... | |
void | resetAllLastCoalesceIds () |
Resets all coalsceIds. More... | |
Change * | giveChange (Change *change, int coalesceId) |
This method gives the command and tries to coalesce the command if possible Warning when a change is MERGED, the original change is deleted!!! And the original pointer is invalid!!!! More... | |
bool | canUndo (TextEditorController *controller=0) |
Should check if a undo operation can be performed. When no controller is given a document-undo is checkd else a view specific soft undo is tested. More... | |
bool | canRedo (TextEditorController *controller=0) |
Should check if a redo operation can be performed. When no controller is given a document-redo is checkd else a view specific soft redo is tested. More... | |
void | undo (TextEditorController *controller=0, bool controllerOnly=false) |
performs an undo operation More... | |
void | redo (TextEditorController *controller=0, bool controllerOnly=false) |
performs the redo operation for the given controller More... | |
bool | isCollectionEnabled () |
void | setCollectionEnabled (bool enabled) |
bool | isUndoRunning () |
bool | isRedoRunning () |
int | size () |
returns the number of changes on the stack More... | |
Change * | at (int idx) |
returns the change at the given index More... | |
int | currentIndex (TextEditorController *controller=0) |
This method return the index that's active for the given controller The currentIndex points directly AFTER the last placed item on the stack. More... | |
int | lastIndex (TextEditorController *controller=0) |
This method returns the last index for a given controller The lastIndex points to the index on the stack. More... | |
Change * | last (TextEditorController *controller=0) |
Returns last textchange on the undo stack. More... | |
int | sizeInDocChanges () |
The number of doc-'undo' items on the stack. More... | |
int | currentIndexInDocChanges () |
This method returns the current doc change index. More... | |
Change * | findRedoChange (TextEditorController *controller=0) |
This method returns the current redo change. This maybe the change for the given context or the document change depending on what comes first. More... | |
Change * | findUndoChange (TextEditorController *controller=0) |
This method returns the last change (TOS) for the given controller. More... | |
void | setPersisted (bool enabled) |
Marks the current documentIndex as persisted. More... | |
bool | isPersisted () |
returns true if the undo-stack is on a persisted index More... | |
int | persistedIndex () |
This method returns the current persisted index. More... | |
TextDocument * | document () |
QString | dumpStack () |
makes a dump of the current stack More... | |
void | dumpStackInternal () |
Dumps the internal stack. More... | |
Protected Member Functions | |
int | findRedoIndex (int index, TextEditorController *controller=0) |
This method finds the next redo-item. More... | |
int | findUndoIndex (int index, TextEditorController *controller=0) |
This method finds the index of the given stackitem from the given index. More... | |
void | clearRedo (TextEditorController *controller) |
Clears all redo's for the given controller. More... | |
bool | undoControllerChange (TextEditorController *controller) |
This method undos the given controller change. This method does NOT undo document changes. More... | |
void | undoDocumentChange () |
Performs an document-change undo. More... | |
bool | redoControllerChange (TextEditorController *controller) |
undo's the given controller change More... | |
void | redoDocumentChange () |
redo a document change More... | |
void | setPersistedIndex (int index) |
Sets the persisted in dex and fires a signal. More... | |
void | setChangeIndex (int index) |
When setting the change-index we sometimes must emit a persisted change. More... | |
This is the undo stack for the texteditor. This stack is SHARED by all views of the document The stack also stores view-specific commands of all views.
Every view has got it's own pointer on the stack. This pointer points at the index AFTER the last item on the stack that's used for this view.
When a view-performs a view-specific undo (soft-undo) it's own pointer is stepped back. Only view-specific commands are undone When a view performs a document undo. ALL view-pointers a are undone to the point of the document undo.
This enumeration is signaled to the listeners to notify what happend when ending an undo group.
|
explicit |
Constructs the main undostack.
|
virtual |
the undo stack items
Change * edbee::TextUndoStack::at | ( | int | idx | ) |
returns the change at the given index
void edbee::TextUndoStack::beginUndoGroup | ( | ChangeGroup * | group | ) |
Starts an undo group (or increase nest-level-counter)
bool edbee::TextUndoStack::canRedo | ( | TextEditorController * | controller = 0 | ) |
Should check if a redo operation can be performed. When no controller is given a document-redo is checkd else a view specific soft redo is tested.
bool edbee::TextUndoStack::canUndo | ( | TextEditorController * | controller = 0 | ) |
Should check if a undo operation can be performed. When no controller is given a document-undo is checkd else a view specific soft undo is tested.
|
signal |
void edbee::TextUndoStack::clear | ( | ) |
clears both stacks
|
protected |
Clears all redo's for the given controller.
ChangeGroup * edbee::TextUndoStack::currentGroup | ( | ) |
This method returns the current active group.
int edbee::TextUndoStack::currentIndex | ( | TextEditorController * | controller = 0 | ) |
This method return the index that's active for the given controller The currentIndex points directly AFTER the last placed item on the stack.
int edbee::TextUndoStack::currentIndexInDocChanges | ( | ) |
This method returns the current doc change index.
|
inline |
QString edbee::TextUndoStack::dumpStack | ( | ) |
makes a dump of the current stack
build the stack overview
void edbee::TextUndoStack::dumpStackInternal | ( | ) |
Dumps the internal stack.
void edbee::TextUndoStack::endUndoGroup | ( | int | coalesceId, |
bool | flatten | ||
) |
Ends the undogroup.
coalesceId | the coalesceId to use |
flatten | should the textchange groups be flattened |
void edbee::TextUndoStack::endUndoGroupAndDiscard | ( | ) |
Ends the undo-group and discards all content.
Change * edbee::TextUndoStack::findRedoChange | ( | TextEditorController * | controller = 0 | ) |
This method returns the current redo change. This maybe the change for the given context or the document change depending on what comes first.
controller | the controller this change is for |
|
protected |
This method finds the next redo-item.
index | the index to search it from |
controller | the controller context |
Change * edbee::TextUndoStack::findUndoChange | ( | TextEditorController * | controller = 0 | ) |
This method returns the last change (TOS) for the given controller.
|
protected |
This method finds the index of the given stackitem from the given index.
index | the previous index |
controller | the controller context |
This method gives the command and tries to coalesce the command if possible Warning when a change is MERGED, the original change is deleted!!! And the original pointer is invalid!!!!
change | the change that's added |
coalesceId | the coalseceId to use for this text change. / |
|
inline |
bool edbee::TextUndoStack::isControllerRegistered | ( | TextEditorController * | controller | ) |
Checks if the given controller is registered.
bool edbee::TextUndoStack::isPersisted | ( | ) |
returns true if the undo-stack is on a persisted index
|
inline |
|
inline |
Change * edbee::TextUndoStack::last | ( | TextEditorController * | controller = 0 | ) |
Returns last textchange on the undo stack.
controller | the controller |
int edbee::TextUndoStack::lastCoalesceIdAtCurrentLevel | ( | ) |
returns the last coalesceId at the given level
int edbee::TextUndoStack::lastIndex | ( | TextEditorController * | controller = 0 | ) |
This method returns the last index for a given controller The lastIndex points to the index on the stack.
|
signal |
This signal is emitted if the persisted state is changed.
int edbee::TextUndoStack::persistedIndex | ( | ) |
This method returns the current persisted index.
void edbee::TextUndoStack::redo | ( | TextEditorController * | controller = 0 , |
bool | controllerOnly = false |
||
) |
performs the redo operation for the given controller
controller | the controller to execute the redo for |
controllerOnly | undo controller undo's only? |
|
protected |
undo's the given controller change
|
protected |
redo a document change
|
signal |
void edbee::TextUndoStack::registerContoller | ( | TextEditorController * | controller | ) |
Registers acontroller for it's own view pointer.
void edbee::TextUndoStack::resetAllLastCoalesceIds | ( | ) |
Resets all coalsceIds.
|
protected |
When setting the change-index we sometimes must emit a persisted change.
|
inline |
void edbee::TextUndoStack::setLastCoalesceIdAtCurrentLevel | ( | int | id | ) |
Sets the last coalesceId at the current level.
void edbee::TextUndoStack::setPersisted | ( | bool | enabled | ) |
Marks the current documentIndex as persisted.
|
protected |
Sets the persisted in dex and fires a signal.
int edbee::TextUndoStack::size | ( | ) |
returns the number of changes on the stack
int edbee::TextUndoStack::sizeInDocChanges | ( | ) |
The number of doc-'undo' items on the stack.
void edbee::TextUndoStack::undo | ( | TextEditorController * | controller = 0 , |
bool | controllerOnly = false |
||
) |
performs an undo operation
controller | this method is called |
|
protected |
This method undos the given controller change. This method does NOT undo document changes.
controller | the controller to undo the change form |
|
protected |
Performs an document-change undo.
|
signal |
|
signal |
This signal is fired when the group is ended. Warning, when the group is merged the group pointer will be 0!!
int edbee::TextUndoStack::undoGroupLevel | ( | ) |
returns the number of stacked undo-groups
|
signal |
void edbee::TextUndoStack::unregisterController | ( | TextEditorController * | controller | ) |
Unregisters the given controller.