|
|
The history of which Command objects have been executed. Once a Command has been executed, it should be placed into the CommandHistory so that an undo/redo mechanism can be operated by the user.
In the TSE3 system there could be be one CommandHistroy object per TSE3::Song or one global CommandHistory.
When the availablity of either undos or redos changes, a notification is sent.
The CommandHistory class has a size limit facility. When either the undo or redo list goes over a certain threshold (see limit) Commands will be deleted. This can be set to 'infinite'.
See also: Command
CommandHistory (int limit = defaultLimit)
| CommandHistory |
Create a CommandHistory with the given limit size. This limit defaults to the value of defaultLimit.
Parameters:
limit | CommandHistory size limit |
void add (Command *command)
| add |
Adds a Command to the CommandHistory. The Command must have been executed. Placing it in the CommandHistory ties it's lifetime to that of the CommandHistory object.
Adding a Command will wipe any redos that may have been possible.
Parameters:
command | New Command to add |
bool undos ()
| undos |
[const]
Returns whether there are any Command objects that can be undone.
When this information changes a notification will be sent.
Returns: True if there are any undos
void undo ()
| undo |
Undoes the last Command, and places it on the redo list.
Command * undoCommand (size_t pos)
| undoCommand |
Returns the command places
down in the undo history.
For example, undoCommand(0) returns the next Command
to be undone.
If there is no command to be undone at this pos
then
returns zero.
Parameters:
pos | Index into undo history |
Returns: Command at this position
bool redos ()
| redos |
[const]
Returns whether there are any Command objects that can be redone.
When this information changes a notification will be sent.
Returns: True if there are any redos
void redo ()
| redo |
Redoes the last undone Command.
Command * redoCommand (size_t pos)
| redoCommand |
Returns the command places
down in the redo history.
For example, redoCommand(0) returns the next Command
to be redone.
If there is no command to be redone at this pos
then
returns zero.
Parameters:
pos | Index into redo history |
Returns: Command at this position
int limit ()
| limit |
[const]
Returns the value of the history size limit. This is the number of Command objects that are stored.
If the value is -1 then the number of undos is unlimited.
Clearly, if the value is 0 then undo is effectively 'off'.
Returns: CommandHistory size limit
void setLimit (int limit)
| setLimit |
Sets the CommandHistory limit value. If there are more Command objects than the new limit currently in the CommandHistory, they will be removed.
Parameters:
limit | New CommandHistory size limit |
void clear ()
| clear |
Clears all undo and redo actions in the CommandHistory.
See also: clearUndos, clearRedos
void clearUndos ()
| clearUndos |
Clears all undo actions in the CommandHistory.
See also: clear, clearRedos
void clearRedos ()
| clearRedos |
Clears all redo actions in the CommandHistory.
See also: clear, clearUndos
static const int defaultLimit | defaultLimit |