Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Private Attributes | List of all members
ComboAction Class Reference

The ComboAction class. More...

#include <comboaction.h>

Inheritance diagram for ComboAction:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

ComboAction::ComboAction ( )

ComboAction Constructor. Currently empty.

ComboAction::~ComboAction ( )
overridevirtual

~ComboAction Destructor. Cleans up all QUndoCommand classes that have been added to it.

Member Function Documentation

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.

Parameters
uThe 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.

Parameters
uThe PostAction to add
bool ComboAction::hasActions ( )

Returns whether actions have been appended or not.

Returns
TRUE if actions have been appended, FALSE if not.
void ComboAction::redo ( )
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.

void ComboAction::undo ( )
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).

Member Data Documentation

QVector<QUndoCommand*> ComboAction::commands
private

Internal array of QUndoCommand objects.

QVector<QUndoCommand*> ComboAction::post_commands
private

Internal array of PostAction objects.


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