\section{KCommand\-History Class Reference}
\label{classKCommandHistory}\index{KCommandHistory@{KCommandHistory}}
The command history stores a (user) configurable amount of Commands.  


{\tt \#include $<$kcommand.h$>$}

Inheritance diagram for KCommand\-History:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=68pt]{classKCommandHistory__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KCommand\-History:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=185pt]{classKCommandHistory__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
virtual void {\bf undo} ()
\item 
virtual void {\bf redo} ()
\item 
virtual void {\bf document\-Saved} ()
\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf command\-Executed} ()
\item 
void {\bf document\-Restored} ()
\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KCommand\-History} ()
\item 
{\bf KCommand\-History} ({\bf KAction\-Collection} $\ast$action\-Collection, bool with\-Menus=true)
\item 
virtual {\bf $\sim$KCommand\-History} ()
\item 
void {\bf clear} ()
\item 
void {\bf add\-Command} ({\bf KCommand} $\ast$command, bool execute=true)
\item 
int {\bf undo\-Limit} () const 
\item 
void {\bf set\-Undo\-Limit} (int limit)
\item 
int {\bf redo\-Limit} () const 
\item 
void {\bf set\-Redo\-Limit} (int limit)
\item 
void {\bf update\-Actions} ()
\end{CompactItemize}
\subsection*{Protected Slots}
\begin{CompactItemize}
\item 
void {\bf slot\-Undo\-About\-To\-Show} ()\label{classKCommandHistory_j0}

\item 
void {\bf slot\-Undo\-Activated} (int)\label{classKCommandHistory_j1}

\item 
void {\bf slot\-Redo\-About\-To\-Show} ()\label{classKCommandHistory_j2}

\item 
void {\bf slot\-Redo\-Activated} (int)\label{classKCommandHistory_j3}

\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKCommandHistory_b0}

\end{CompactItemize}


\subsection{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 KCommand\-History keeps track of the \char`\"{}borders\char`\"{} 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 156 of file kcommand.h.

\subsection{Constructor \& Destructor Documentation}
\index{KCommandHistory@{KCommand\-History}!KCommandHistory@{KCommandHistory}}
\index{KCommandHistory@{KCommandHistory}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KCommand\-History::KCommand\-History ()}\label{classKCommandHistory_a0}


Creates a command history, to store commands. 

This constructor doesn't create actions, so you need to call {\bf undo}{\rm (p.\,\pageref{classKCommandHistory_i0})} and {\bf redo}{\rm (p.\,\pageref{classKCommandHistory_i1})} yourself. 

Definition at line 72 of file kcommand.cpp.

References clear(), and QPtr\-List::set\-Auto\-Delete().\index{KCommandHistory@{KCommand\-History}!KCommandHistory@{KCommandHistory}}
\index{KCommandHistory@{KCommandHistory}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KCommand\-History::KCommand\-History ({\bf KAction\-Collection} $\ast$ {\em action\-Collection}, bool {\em with\-Menus} = {\tt true})}\label{classKCommandHistory_a1}


Creates a command history, to store commands. 

This also creates an undo and a redo action, in the {\tt action\-Collection}, using the standard names (\char`\"{}edit\_\-undo\char`\"{} and \char`\"{}edit\_\-redo\char`\"{}). \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em with\-Menus}]if true, the actions will display a menu when plugged into a toolbar. \item[{\em action\-Collection}]the parent collection \end{description}
\end{Desc}


Definition at line 80 of file kcommand.cpp.

References clear(), QObject::connect(), KStd\-Action::redo(), redo(), QPtr\-List::set\-Auto\-Delete(), KStd\-Action::undo(), and undo().\index{KCommandHistory@{KCommand\-History}!~KCommandHistory@{$\sim$KCommandHistory}}
\index{~KCommandHistory@{$\sim$KCommandHistory}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KCommand\-History::$\sim${\bf KCommand\-History} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKCommandHistory_a2}


Destructs the command history object. 



Definition at line 113 of file kcommand.cpp.

\subsection{Member Function Documentation}
\index{KCommandHistory@{KCommand\-History}!clear@{clear}}
\index{clear@{clear}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::clear ()}\label{classKCommandHistory_a3}


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::set\-Enabled(), and KAction::set\-Text().

Referenced by KCommand\-History().\index{KCommandHistory@{KCommand\-History}!addCommand@{addCommand}}
\index{addCommand@{addCommand}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::add\-Command ({\bf KCommand} $\ast$ {\em command}, bool {\em execute} = {\tt true})}\label{classKCommandHistory_a4}


Adds a command to the history. 

Call this for each {\tt command} you create. Unless you set {\tt execute} to false, this will also execute the command. This means, most of the application's code will look like My\-Command $\ast$ cmd = new My\-Command(i18n(\char`\"{}Capitalized Name\char`\"{}), parameters); m\_\-history\-Command.add\-Command( cmd ); 

Definition at line 130 of file kcommand.cpp.

References QPtr\-List::append(), QPtr\-List::clear(), command\-Executed(), QPtr\-List::count(), endl(), QPtr\-List::find\-Ref(), QPtr\-List::insert(), KAction::is\-Enabled(), kd\-Debug(), QPtr\-List::remove\-Last(), KAction::set\-Enabled(), and KAction::set\-Text().\index{KCommandHistory@{KCommand\-History}!undoLimit@{undoLimit}}
\index{undoLimit@{undoLimit}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KCommand\-History::undo\-Limit () const\hspace{0.3cm}{\tt  [inline]}}\label{classKCommandHistory_a5}


\begin{Desc}
\item[Returns:]the maximum number of items in the undo history \end{Desc}


Definition at line 200 of file kcommand.h.\index{KCommandHistory@{KCommand\-History}!setUndoLimit@{setUndoLimit}}
\index{setUndoLimit@{setUndoLimit}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::set\-Undo\-Limit (int {\em limit})}\label{classKCommandHistory_a6}


Sets the maximum number of items in the undo history. 



Definition at line 264 of file kcommand.cpp.\index{KCommandHistory@{KCommand\-History}!redoLimit@{redoLimit}}
\index{redoLimit@{redoLimit}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KCommand\-History::redo\-Limit () const\hspace{0.3cm}{\tt  [inline]}}\label{classKCommandHistory_a7}


\begin{Desc}
\item[Returns:]the maximum number of items in the redo history \end{Desc}


Definition at line 208 of file kcommand.h.\index{KCommandHistory@{KCommand\-History}!setRedoLimit@{setRedoLimit}}
\index{setRedoLimit@{setRedoLimit}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::set\-Redo\-Limit (int {\em limit})}\label{classKCommandHistory_a8}


Sets the maximum number of items in the redo history. 



Definition at line 272 of file kcommand.cpp.\index{KCommandHistory@{KCommand\-History}!updateActions@{updateActions}}
\index{updateActions@{updateActions}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::update\-Actions ()}\label{classKCommandHistory_a9}


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 \char`\"{}readonly\char`\"{} state), and then want to come back to a readwrite mode. 

Definition at line 354 of file kcommand.cpp.

References QPtr\-List::find\-Ref(), QPtr\-List::next(), and KAction::set\-Enabled().\index{KCommandHistory@{KCommand\-History}!undo@{undo}}
\index{undo@{undo}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::undo ()\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKCommandHistory_i0}


Undoes the last action. 

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

Definition at line 181 of file kcommand.cpp.

References command\-Executed(), QPtr\-List::current(), document\-Restored(), QPtr\-List::find\-Ref(), QPtr\-List::prev(), KAction::set\-Enabled(), and KAction::set\-Text().

Referenced by KCommand\-History().\index{KCommandHistory@{KCommand\-History}!redo@{redo}}
\index{redo@{redo}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::redo ()\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKCommandHistory_i1}


Redoes the last undone action. 

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

Definition at line 215 of file kcommand.cpp.

References command\-Executed(), QPtr\-List::current(), document\-Restored(), QPtr\-List::find\-Ref(), QPtr\-List::first(), KAction::is\-Enabled(), QPtr\-List::next(), KAction::set\-Enabled(), and KAction::set\-Text().

Referenced by KCommand\-History().\index{KCommandHistory@{KCommand\-History}!documentSaved@{documentSaved}}
\index{documentSaved@{documentSaved}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::document\-Saved ()\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKCommandHistory_i2}


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 document\-Restored If you implemented undo/redo properly the document is the same you saved before. 

Definition at line 254 of file kcommand.cpp.

References QPtr\-List::find\-Ref().\index{KCommandHistory@{KCommand\-History}!commandExecuted@{commandExecuted}}
\index{commandExecuted@{commandExecuted}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::command\-Executed ()\hspace{0.3cm}{\tt  [signal]}}\label{classKCommandHistory_l0}


Emitted every time a command is executed (whether by add\-Command, undo or redo). 

You can use this to update the GUI, for instance. 

Referenced by add\-Command(), redo(), and undo().\index{KCommandHistory@{KCommand\-History}!documentRestored@{documentRestored}}
\index{documentRestored@{documentRestored}!KCommandHistory@{KCommand\-History}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCommand\-History::document\-Restored ()\hspace{0.3cm}{\tt  [signal]}}\label{classKCommandHistory_l1}


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

See document\-Saved 

Referenced by redo(), and undo().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kcommand.h\item 
kcommand.cpp\end{CompactItemize}
