The ComboAction class. More...
#include <comboaction.h>
Public Member Functions | |
ComboAction () | |
ComboAction Constructor. Currently empty. More... | |
virtual | ~ComboAction () override |
~ComboAction Destructor. Cleans up all QUndoCommand classes that have been added to it. More... | |
virtual void | undo () override |
Undo Function. More... | |
virtual void | redo () override |
Redo Function. More... | |
void | append (QUndoCommand *u) |
Add an undo action. More... | |
void | appendPost (QUndoCommand *u) |
Add a post-undo PostAction. More... | |
bool | hasActions () |
Returns whether actions have been appended or not. More... | |
Private Attributes | |
QVector< QUndoCommand * > | commands |
Internal array of QUndoCommand objects. More... | |
QVector< QUndoCommand * > | post_commands |
Internal array of PostAction objects. More... | |
The ComboAction class.
The Undo/Redo system works by stacking an action that knows how to "do" and also "undo" itself. As Olive is a very complex program, there are many actions that can in one "user action". For example, moving a clip over another will delete the clip under it, which is at least two actions that need to be undone if the user clicks undo, however the user only (knowingly) did one thing and would find it confusing if this one user action required to undos to complete undo.
To address this, ComboAction is an undo action that simply compiles several possible actions into one, doing them all on every redo, and undoing them all on every undo.
ComboAction::ComboAction | ( | ) |
ComboAction Constructor. Currently empty.
|
overridevirtual |
~ComboAction Destructor. Cleans up all QUndoCommand classes that have been added to it.
void ComboAction::append | ( | QUndoCommand * | u | ) |
Add an undo action.
Add an action to be done/undone. ComboAction takes ownership of this QUndoCommand and will delete it when it is deleted.
u | The QUndoCommand to add. |
void ComboAction::appendPost | ( | QUndoCommand * | u | ) |
Add a post-undo PostAction.
Sometimes the results of all the actions require another function to be called (e.g. repainting the Viewer). QUndoCommand objects added by appendPost() will run after EVERY QUndoCommand added by append() has been run.
u | The PostAction to add |
bool ComboAction::hasActions | ( | ) |
Returns whether actions have been appended or not.
|
overridevirtual |
Redo Function.
Called by the QUndoStack to redo.
Calls QUndoCommand::redo() on all QUndoCommand objects added by append() in the order they were added. Then calls QUndoCommand::redo() on every action added by appendPost() in the order they were added.
|
overridevirtual |
Undo Function.
Called by the QUndoStack to undo.
Calls QUndoCommand::undo() on all QUndoCommand objects added by append() in REVERSE order to how they were added. Then calls QUndoCommand::redo() on every action added by appendPost() in the order they were added (not in reverse).
|
private |
Internal array of QUndoCommand objects.
|
private |
Internal array of PostAction objects.