KCommandHistory Class Reference
The command history stores a (user) configurable amount of Commands. More...
#include <kcommand.h>
Inheritance diagram for KCommandHistory:

Public Slots | |
virtual void | undo () |
Undoes the last action. | |
virtual void | redo () |
Redoes the last undone action. | |
virtual void | documentSaved () |
Remembers when you saved the document. | |
Signals | |
void | commandExecuted () |
Emitted every time a command is executed (whether by addCommand, undo or redo). | |
void | documentRestored () |
Emitted everytime we reach the index where you saved the document for the last time. | |
Public Member Functions | |
KCommandHistory () | |
Creates a command history, to store commands. | |
KCommandHistory (KActionCollection *actionCollection, bool withMenus=true) | |
Creates a command history, to store commands. | |
virtual | ~KCommandHistory () |
Destructs the command history object. | |
void | clear () |
Erases all the undo/redo history. | |
void | addCommand (KCommand *command, bool execute=true) |
Adds a command to the history. | |
int | undoLimit () const |
void | setUndoLimit (int limit) |
Sets the maximum number of items in the undo history. | |
int | redoLimit () const |
void | setRedoLimit (int limit) |
Sets the maximum number of items in the redo history. | |
void | updateActions () |
Enable or disable the undo and redo actions. | |
Protected Slots | |
void | slotUndoAboutToShow () |
void | slotUndoActivated (int) |
void | slotRedoAboutToShow () |
void | slotRedoActivated (int) |
Protected Member Functions | |
virtual void | virtual_hook (int id, void *data) |
Detailed Description
The command history stores a (user) configurable amount of Commands.It keeps track of its size and deletes commands if it gets too large. The user can set a maximum undo and a maximum redo limit (e.g. max. 50 undo / 30 redo commands). The KCommandHistory keeps track of the "borders" and deletes commands, if appropriate. It also activates/deactivates the undo/redo actions in the menu and changes the text according to the name of the command.
Definition at line 155 of file kcommand.h.
Constructor & Destructor Documentation
|
Creates a command history, to store commands. This constructor doesn't create actions, so you need to call undo and redo yourself. Definition at line 72 of file kcommand.cpp. References clear(), and QPtrList< KCommand >::setAutoDelete(). |
|
Creates a command history, to store commands.
This also creates an undo and a redo action, in the
Definition at line 80 of file kcommand.cpp. References clear(), QObject::connect(), KStdAction::redo(), KStdAccel::redo(), redo(), QPtrList< KCommand >::setAutoDelete(), KStdAction::undo(), KStdAccel::undo(), and undo(). |
|
Destructs the command history object.
Definition at line 113 of file kcommand.cpp. |
Member Function Documentation
|
Erases all the undo/redo history. Use this when reloading the data, for instance, since this invalidates all the commands. Definition at line 117 of file kcommand.cpp. References KAction::setEnabled(), and KAction::setText(). Referenced by KCommandHistory(). |
|
Adds a command to the history.
Call this for each Definition at line 130 of file kcommand.cpp. References QPtrList< KCommand >::append(), QPtrList< KCommand >::clear(), commandExecuted(), QPtrList< KCommand >::count(), KCommand::execute(), QPtrList< KCommand >::findRef(), QPtrList< KCommand >::insert(), KAction::isEnabled(), QPtrList< KCommand >::removeLast(), KAction::setEnabled(), and KAction::setText(). |
|
Definition at line 198 of file kcommand.h. |
|
Sets the maximum number of items in the undo history.
Definition at line 264 of file kcommand.cpp. |
|
Definition at line 206 of file kcommand.h. |
|
Sets the maximum number of items in the redo history.
Definition at line 272 of file kcommand.cpp. |
|
Enable or disable the undo and redo actions. This isn't usually necessary, but this method can be useful if you disable all actions (to go to a "readonly" state), and then want to come back to a readwrite mode. Definition at line 354 of file kcommand.cpp. References QPtrList< KCommand >::findRef(), QPtrList< KCommand >::next(), and KAction::setEnabled(). |
|
Undoes the last action. Call this if you don't use the builtin KActions. Definition at line 181 of file kcommand.cpp. References commandExecuted(), QPtrList< KCommand >::current(), documentRestored(), QPtrList< KCommand >::findRef(), QPtrList< KCommand >::prev(), KAction::setEnabled(), and KAction::setText(). Referenced by KCommandHistory(). |
|
Redoes the last undone action. Call this if you don't use the builtin KActions. Definition at line 215 of file kcommand.cpp. References commandExecuted(), QPtrList< KCommand >::current(), documentRestored(), QPtrList< KCommand >::findRef(), QPtrList< KCommand >::first(), KAction::isEnabled(), QPtrList< KCommand >::next(), KAction::setEnabled(), and KAction::setText(). Referenced by KCommandHistory(). |
|
Remembers when you saved the document. Call this right after saving the document. As soon as the history reaches the current index again (via some undo/redo operations) it will emit documentRestored If you implemented undo/redo properly the document is the same you saved before. Definition at line 254 of file kcommand.cpp. References QPtrList< KCommand >::findRef(). |
|
Emitted every time a command is executed (whether by addCommand, undo or redo). You can use this to update the GUI, for instance. Referenced by addCommand(), redo(), and undo(). |
|
Emitted everytime we reach the index where you saved the document for the last time. See documentSaved |
The documentation for this class was generated from the following files: