\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=72pt]{classKCommandHistory__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KCommand\-History:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=202pt]{classKCommandHistory__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
virtual void {\bf undo} ()
\begin{CompactList}\small\item\em Undoes the last action. \item\end{CompactList}\item 
virtual void {\bf redo} ()
\begin{CompactList}\small\item\em Redoes the last undone action. \item\end{CompactList}\item 
virtual void {\bf document\-Saved} ()
\begin{CompactList}\small\item\em Remembers when you saved the document. \item\end{CompactList}\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf command\-Executed} ()
\begin{CompactList}\small\item\em Emitted every time a command is executed (whether by add\-Command, undo or redo). \item\end{CompactList}\item 
void {\bf document\-Restored} ()
\begin{CompactList}\small\item\em Emitted everytime we reach the index where you saved the document for the last time. \item\end{CompactList}\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KCommand\-History} ()
\begin{CompactList}\small\item\em Creates a command history, to store commands. \item\end{CompactList}\item 
{\bf KCommand\-History} ({\bf KAction\-Collection} $\ast$action\-Collection, bool with\-Menus=true)
\begin{CompactList}\small\item\em Creates a command history, to store commands. \item\end{CompactList}\item 
virtual {\bf $\sim$KCommand\-History} ()
\begin{CompactList}\small\item\em Destructs the command history object. \item\end{CompactList}\item 
void {\bf clear} ()
\begin{CompactList}\small\item\em Erases all the undo/redo history. \item\end{CompactList}\item 
void {\bf add\-Command} ({\bf KCommand} $\ast$command, bool execute=true)
\begin{CompactList}\small\item\em Adds a command to the history. \item\end{CompactList}\item 
int {\bf undo\-Limit} () const 
\item 
void {\bf set\-Undo\-Limit} (int limit)
\begin{CompactList}\small\item\em Sets the maximum number of items in the undo history. \item\end{CompactList}\item 
int {\bf redo\-Limit} () const 
\item 
void {\bf set\-Redo\-Limit} (int limit)
\begin{CompactList}\small\item\em Sets the maximum number of items in the redo history. \item\end{CompactList}\item 
void {\bf update\-Actions} ()
\begin{CompactList}\small\item\em Enable or disable the undo and redo actions. \item\end{CompactList}\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 155 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$<$ KCommand $>$::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} = 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. \end{description}
\end{Desc}


Definition at line 80 of file kcommand.cpp.

References clear(), QObject::connect(), KStd\-Action::redo(), KStd\-Accel::redo(), redo(), QPtr\-List$<$ KCommand $>$::set\-Auto\-Delete(), KStd\-Action::undo(), KStd\-Accel::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} = 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`\"{}The name\char`\"{}), parameters); m\_\-history\-Command.add\-Command( cmd ); 

Definition at line 130 of file kcommand.cpp.

References QPtr\-List$<$ KCommand $>$::append(), QPtr\-List$<$ KCommand $>$::clear(), command\-Executed(), QPtr\-List$<$ KCommand $>$::count(), KCommand::execute(), QPtr\-List$<$ KCommand $>$::find\-Ref(), QPtr\-List$<$ KCommand $>$::insert(), KAction::is\-Enabled(), QPtr\-List$<$ KCommand $>$::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 198 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 206 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$<$ KCommand $>$::find\-Ref(), QPtr\-List$<$ KCommand $>$::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$<$ KCommand $>$::current(), document\-Restored(), QPtr\-List$<$ KCommand $>$::find\-Ref(), QPtr\-List$<$ KCommand $>$::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$<$ KCommand $>$::current(), document\-Restored(), QPtr\-List$<$ KCommand $>$::find\-Ref(), QPtr\-List$<$ KCommand $>$::first(), KAction::is\-Enabled(), QPtr\-List$<$ KCommand $>$::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 {\bf document\-Restored}{\rm (p.\,\pageref{classKCommandHistory_l1})} 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$<$ KCommand $>$::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 everytime we reach the index where you saved the document for the last time. 

See {\bf document\-Saved}{\rm (p.\,\pageref{classKCommandHistory_i2})} 

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}
