lib Library API Documentation

KoCommandHistory Class Reference

The command history stores a (user) configurable amount of Commands. History of user commands (for undo/redo). More...

#include <kocommandhistory.h>

Inheritance diagram for KoCommandHistory:

Inheritance graph
[legend]
Collaboration diagram for KoCommandHistory:

Collaboration graph
[legend]
List of all members.

Public Slots

virtual void undo ()
virtual void redo ()
virtual void documentSaved ()

Signals

void commandExecuted ()
void documentRestored ()

Public Member Functions

 KoCommandHistory ()
 KoCommandHistory (KActionCollection *actionCollection, bool withMenus=true)
virtual ~KoCommandHistory ()
void clear ()
void addCommand (KCommand *command, bool execute=true)
int undoLimit () const
void setUndoLimit (int limit)
int redoLimit () const
void setRedoLimit (int limit)
void updateActions ()

Protected Slots

void slotUndoAboutToShow ()
void slotUndoActivated (int)
void slotRedoAboutToShow ()
void slotRedoActivated (int)
void slotUndoActivated (QListBoxItem *)
void slotRedoActivated (QListBoxItem *)
void slotChangeRedoNumberOfSelectedItem (int)
void slotChangeUndoNumberOfSelectedItem (int)

Protected Member Functions

virtual void virtual_hook (int id, void *data)

Detailed Description

The command history stores a (user) configurable amount of Commands. History of user commands (for undo/redo).

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 KoCommandHistory 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 56 of file kocommandhistory.h.


Constructor & Destructor Documentation

KoCommandHistory::KoCommandHistory  ) 
 

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 70 of file kocommandhistory.cpp.

References clear().

KoCommandHistory::KoCommandHistory KActionCollection *  actionCollection,
bool  withMenus = true
 

Creates a command history, to store commands.

This also creates an undo and a redo action, in the actionCollection, using the standard names ("edit_undo" and "edit_redo").

Parameters:
withMenus if true, the actions will display a menu when plugged into a toolbar.

Definition at line 78 of file kocommandhistory.cpp.

References clear(), redo(), and undo().

KoCommandHistory::~KoCommandHistory  )  [virtual]
 

Destructs the command history object.

Definition at line 141 of file kocommandhistory.cpp.


Member Function Documentation

void KoCommandHistory::clear  ) 
 

Erases all the undo/redo history.

Use this when reloading the data, for instance, since this invalidates all the commands.

Definition at line 145 of file kocommandhistory.cpp.

Referenced by KoCommandHistory(), and Container::loadMathML().

void KoCommandHistory::addCommand KCommand *  command,
bool  execute = true
 

Adds a command to the history.

Call this for each command you create. Unless you set execute to false, this will also execute the command. This means, most of the application's code will look like:

MyCommand * cmd = new MyCommand(i18n("The Name"), parameters); m_historyCommand.addCommand( cmd );

Definition at line 158 of file kocommandhistory.cpp.

References commandExecuted().

int KoCommandHistory::undoLimit  )  const [inline]
 

Returns:
the maximum number of items in the undo history

Definition at line 101 of file kocommandhistory.h.

void KoCommandHistory::setUndoLimit int  limit  ) 
 

Sets the maximum number of items in the undo history.

Definition at line 292 of file kocommandhistory.cpp.

int KoCommandHistory::redoLimit  )  const [inline]
 

Returns:
the maximum number of items in the redo history

Definition at line 109 of file kocommandhistory.h.

void KoCommandHistory::setRedoLimit int  limit  ) 
 

Sets the maximum number of items in the redo history.

Definition at line 300 of file kocommandhistory.cpp.

void KoCommandHistory::updateActions  ) 
 

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 414 of file kocommandhistory.cpp.

void KoCommandHistory::undo  )  [virtual, slot]
 

Undoes the last action.

Call this if you don't use the builtin KActions.

Definition at line 209 of file kocommandhistory.cpp.

References commandExecuted(), and documentRestored().

Referenced by KoCommandHistory().

void KoCommandHistory::redo  )  [virtual, slot]
 

Redoes the last undone action.

Call this if you don't use the builtin KActions.

Definition at line 243 of file kocommandhistory.cpp.

References commandExecuted(), and documentRestored().

Referenced by KoCommandHistory().

void KoCommandHistory::documentSaved  )  [virtual, slot]
 

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 282 of file kocommandhistory.cpp.

void KoCommandHistory::commandExecuted  )  [signal]
 

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

void KoCommandHistory::documentRestored  )  [signal]
 

Emitted every time we reach the index where you saved the document for the last time.

See documentSaved

Referenced by redo(), and undo().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:48:38 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003