.TH "KCommandHistory" 3 "28 Jan 2004" "kdeui Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KCommandHistory \- The command history stores a (user) configurable amount of Commands.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kcommand.h>\fP
.PP
Inherits \fBQObject\fP.
.PP
.SS "Public Slots"

.in +1c
.ti -1c
.RI "virtual void \fBundo\fP ()"
.br
.RI "\fIUndoes the last action. \fP"
.ti -1c
.RI "virtual void \fBredo\fP ()"
.br
.RI "\fIRedoes the last undone action. \fP"
.ti -1c
.RI "virtual void \fBdocumentSaved\fP ()"
.br
.RI "\fIRemembers when you saved the document. \fP"
.in -1c
.SS "Signals"

.in +1c
.ti -1c
.RI "void \fBcommandExecuted\fP ()"
.br
.RI "\fIEmitted every time a command is executed (whether by addCommand, undo or redo). \fP"
.ti -1c
.RI "void \fBdocumentRestored\fP ()"
.br
.RI "\fIEmitted everytime we reach the index where you saved the document for the last time. \fP"
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKCommandHistory\fP ()"
.br
.RI "\fICreates a command history, to store commands. \fP"
.ti -1c
.RI "\fBKCommandHistory\fP (\fBKActionCollection\fP *actionCollection, bool withMenus=true)"
.br
.RI "\fICreates a command history, to store commands. \fP"
.ti -1c
.RI "virtual \fB~KCommandHistory\fP ()"
.br
.RI "\fIDestructs the command history object. \fP"
.ti -1c
.RI "void \fBclear\fP ()"
.br
.RI "\fIErases all the undo/redo history. \fP"
.ti -1c
.RI "void \fBaddCommand\fP (\fBKCommand\fP *command, bool execute=true)"
.br
.RI "\fIAdds a command to the history. \fP"
.ti -1c
.RI "int \fBundoLimit\fP () const "
.br
.ti -1c
.RI "void \fBsetUndoLimit\fP (int limit)"
.br
.RI "\fISets the maximum number of items in the undo history. \fP"
.ti -1c
.RI "int \fBredoLimit\fP () const "
.br
.ti -1c
.RI "void \fBsetRedoLimit\fP (int limit)"
.br
.RI "\fISets the maximum number of items in the redo history. \fP"
.ti -1c
.RI "void \fBupdateActions\fP ()"
.br
.RI "\fIEnable or disable the undo and redo actions. \fP"
.in -1c
.SS "Protected Slots"

.in +1c
.ti -1c
.RI "void \fBslotUndoAboutToShow\fP ()"
.br
.ti -1c
.RI "void \fBslotUndoActivated\fP (int)"
.br
.ti -1c
.RI "void \fBslotRedoAboutToShow\fP ()"
.br
.ti -1c
.RI "void \fBslotRedoActivated\fP (int)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual void \fBvirtual_hook\fP (int id, void *data)"
.br
.in -1c
.SH "Detailed Description"
.PP 
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. 
.PP
Definition at line 155 of file kcommand.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KCommandHistory::KCommandHistory ()"
.PP
Creates a command history, to store commands. This constructor doesn't create actions, so you need to call \fBundo\fP and \fBredo\fP yourself. Definition at line 72 of file kcommand.cpp.
.PP
References clear(), and QPtrList< KCommand >::setAutoDelete().
.SS "KCommandHistory::KCommandHistory (\fBKActionCollection\fP * actionCollection, bool withMenus = true)"
.PP
Creates a command history, to store commands. This also creates an undo and a redo action, in the \fCactionCollection\fP, using the standard names ('edit_undo' and 'edit_redo'). 
.PP
\fBParameters:\fP
.RS 4
\fIwithMenus\fP if true, the actions will display a menu when plugged into a toolbar. 
.RE
.PP
Definition at line 80 of file kcommand.cpp.
.PP
References clear(), QObject::connect(), KStdAction::redo(), KStdAccel::redo(), redo(), QPtrList< KCommand >::setAutoDelete(), KStdAction::undo(), KStdAccel::undo(), and undo().
.SS "KCommandHistory::~\fBKCommandHistory\fP ()\fC [virtual]\fP"
.PP
Destructs the command history object. Definition at line 113 of file kcommand.cpp.
.SH "Member Function Documentation"
.PP 
.SS "void KCommandHistory::clear ()"
.PP
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.
.PP
References KAction::setEnabled(), and KAction::setText().
.PP
Referenced by KCommandHistory().
.SS "void KCommandHistory::addCommand (\fBKCommand\fP * command, bool execute = true)"
.PP
Adds a command to the history. Call this for each \fCcommand\fP you create. Unless you set \fCexecute\fP 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 130 of file kcommand.cpp.
.PP
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().
.SS "int KCommandHistory::undoLimit () const\fC [inline]\fP"
.PP
\fBReturns:\fP
.RS 4
the maximum number of items in the undo history 
.RE
.PP
Definition at line 198 of file kcommand.h.
.SS "void KCommandHistory::setUndoLimit (int limit)"
.PP
Sets the maximum number of items in the undo history. Definition at line 264 of file kcommand.cpp.
.SS "int KCommandHistory::redoLimit () const\fC [inline]\fP"
.PP
\fBReturns:\fP
.RS 4
the maximum number of items in the redo history 
.RE
.PP
Definition at line 206 of file kcommand.h.
.SS "void KCommandHistory::setRedoLimit (int limit)"
.PP
Sets the maximum number of items in the redo history. Definition at line 272 of file kcommand.cpp.
.SS "void KCommandHistory::updateActions ()"
.PP
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.
.PP
References QPtrList< KCommand >::findRef(), QPtrList< KCommand >::next(), and KAction::setEnabled().
.SS "void KCommandHistory::undo ()\fC [virtual, slot]\fP"
.PP
Undoes the last action. Call this if you don't use the builtin KActions. Definition at line 181 of file kcommand.cpp.
.PP
References commandExecuted(), QPtrList< KCommand >::current(), documentRestored(), QPtrList< KCommand >::findRef(), QPtrList< KCommand >::prev(), KAction::setEnabled(), and KAction::setText().
.PP
Referenced by KCommandHistory().
.SS "void KCommandHistory::redo ()\fC [virtual, slot]\fP"
.PP
Redoes the last undone action. Call this if you don't use the builtin KActions. Definition at line 215 of file kcommand.cpp.
.PP
References commandExecuted(), QPtrList< KCommand >::current(), documentRestored(), QPtrList< KCommand >::findRef(), QPtrList< KCommand >::first(), KAction::isEnabled(), QPtrList< KCommand >::next(), KAction::setEnabled(), and KAction::setText().
.PP
Referenced by KCommandHistory().
.SS "void KCommandHistory::documentSaved ()\fC [virtual, slot]\fP"
.PP
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 \fBdocumentRestored\fP If you implemented undo/redo properly the document is the same you saved before. Definition at line 254 of file kcommand.cpp.
.PP
References QPtrList< KCommand >::findRef().
.SS "void KCommandHistory::commandExecuted ()\fC [signal]\fP"
.PP
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().
.SS "void KCommandHistory::documentRestored ()\fC [signal]\fP"
.PP
Emitted everytime we reach the index where you saved the document for the last time. See \fBdocumentSaved\fP Referenced by redo(), and undo().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdeui Library from the source code.
