\section{KHistory\-Combo Class Reference}
\label{classKHistoryCombo}\index{KHistoryCombo@{KHistoryCombo}}
A combobox which implements a history like a unix shell. A combobox for offering a history and completion.  


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

Inheritance diagram for KHistory\-Combo:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=113pt]{classKHistoryCombo__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KHistory\-Combo:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=184pt]{classKHistoryCombo__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
void {\bf add\-To\-History} (const  {\bf QString} \&item)
\begin{CompactList}\small\item\em Adds an item to the end of the history list and to the completion list. \item\end{CompactList}\item 
void {\bf clear\-History} ()
\begin{CompactList}\small\item\em Clears the history and the completion list. \item\end{CompactList}\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf cleared} ()
\begin{CompactList}\small\item\em Emitted when the history was cleared by the entry in the popup menu. \item\end{CompactList}\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KHistory\-Combo} ({\bf QWidget} $\ast$parent=0L, const  char $\ast$name=0L)
\begin{CompactList}\small\item\em Constructs a \char`\"{}read-write\char`\"{} combobox. \item\end{CompactList}\item 
{\bf KHistory\-Combo} (bool use\-Completion, {\bf QWidget} $\ast$parent=0L, const  char $\ast$name=0L)
\begin{CompactList}\small\item\em Same as the previous constructor, but additionally has the option to specify whether you want to let KHistory\-Combo handle completion or not. \item\end{CompactList}\item 
{\bf $\sim$KHistory\-Combo} ()
\begin{CompactList}\small\item\em Destructs the combo, the completion-object and the pixmap-provider. \item\end{CompactList}\item 
void {\bf set\-History\-Items} ({\bf QString\-List} items)
\begin{CompactList}\small\item\em Inserts {\tt items} into the combobox. \item\end{CompactList}\item 
void {\bf set\-History\-Items} ({\bf QString\-List} items, bool set\-Completion\-List)
\begin{CompactList}\small\item\em Inserts {\tt items} into the combobox. \item\end{CompactList}\item 
{\bf QString\-List} {\bf history\-Items} () const 
\begin{CompactList}\small\item\em Returns the list of history items. \item\end{CompactList}\item 
bool {\bf remove\-From\-History} (const  {\bf QString} \&item)
\begin{CompactList}\small\item\em Removes all items named {\tt item}. \item\end{CompactList}\item 
void {\bf set\-Pixmap\-Provider} ({\bf KPixmap\-Provider} $\ast$prov)
\begin{CompactList}\small\item\em Sets a pixmap provider, so that items in the combobox can have a pixmap. \item\end{CompactList}\item 
{\bf KPixmap\-Provider} $\ast$ {\bf pixmap\-Provider} () const 
\item 
void {\bf reset} ()
\begin{CompactList}\small\item\em Resets the current position of the up/down history. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual void {\bf key\-Press\-Event} ({\bf QKey\-Event} $\ast$)
\begin{CompactList}\small\item\em Handling key-events, the shortcuts to rotate the items. \item\end{CompactList}\item 
virtual void {\bf wheel\-Event} ({\bf QWheel\-Event} $\ast$ev)
\begin{CompactList}\small\item\em Handling wheel-events, to rotate the items. \item\end{CompactList}\item 
void {\bf insert\-Items} (const  {\bf QString\-List} \&items)
\begin{CompactList}\small\item\em Inserts {\tt items} into the combo, honouring {\bf pixmap\-Provider}{\rm (p.\,\pageref{classKHistoryCombo_a8})}() Does not update the completion\-Object. \item\end{CompactList}\item 
bool {\bf use\-Completion} () const 
\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKHistoryCombo_b4}

\end{CompactItemize}


\subsection{Detailed Description}
A combobox which implements a history like a unix shell. A combobox for offering a history and completion. 

You can navigate through all the items by using the Up or Down arrows (configurable of course). Additionally, weighted completion is available. So you should load and save the completion list to preserve the weighting between sessions.

KHistory\-Combo obeys the HISTCONTROL environment variable to determine whether duplicates in the history should be tolerated in {\bf add\-To\-History}{\rm (p.\,\pageref{classKHistoryCombo_i0})}() or not. During construction of KHistory\-Combo, duplicates will be disabled when HISTCONTROL is set to \char`\"{}ignoredups\char`\"{} or \char`\"{}ignoreboth\char`\"{}. Otherwise, duplicates are enabled by default.

\begin{Desc}
\item[Author:]Carsten Pfeiffer $<${\tt pfeiffer@kde.org}$>$ \end{Desc}




Definition at line 535 of file kcombobox.h.

\subsection{Constructor \& Destructor Documentation}
\index{KHistoryCombo@{KHistory\-Combo}!KHistoryCombo@{KHistoryCombo}}
\index{KHistoryCombo@{KHistoryCombo}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KHistory\-Combo::KHistory\-Combo ({\bf QWidget} $\ast$ {\em parent} = 0L, const char $\ast$ {\em name} = 0L)}\label{classKHistoryCombo_a0}


Constructs a \char`\"{}read-write\char`\"{} combobox. 

A read-only history combobox doesn't make much sense, so it is only available as read-write. Completion will be used automatically for the items in the combo.

The insertion-policy is set to No\-Insertion, you have to add the items yourself via the slot {\bf add\-To\-History}{\rm (p.\,\pageref{classKHistoryCombo_i0})}. If you want every item added, use

\small\begin{alltt}
 connect( combo, SIGNAL( {\bf activated( const QString& )}),
          combo, SLOT( {\bf addToHistory( const QString& )}{\rm (p.\,\pageref{classKHistoryCombo_i0})}));
 \end{alltt}\normalsize 


Use {\bf QCombo\-Box::set\-Max\-Count}() to limit the history.

{\tt parent} the parent object of this widget. {\tt name} the name of this widget. 

Definition at line 356 of file kcombobox.cpp.

References KStd\-Accel::name().\index{KHistoryCombo@{KHistory\-Combo}!KHistoryCombo@{KHistoryCombo}}
\index{KHistoryCombo@{KHistoryCombo}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KHistory\-Combo::KHistory\-Combo (bool {\em use\-Completion}, {\bf QWidget} $\ast$ {\em parent} = 0L, const char $\ast$ {\em name} = 0L)}\label{classKHistoryCombo_a1}


Same as the previous constructor, but additionally has the option to specify whether you want to let KHistory\-Combo handle completion or not. 

If set to {\tt true}, KHistory\-Combo will sync the completion to the contents of the combobox. 

Definition at line 363 of file kcombobox.cpp.

References KStd\-Accel::name().\index{KHistoryCombo@{KHistory\-Combo}!~KHistoryCombo@{$\sim$KHistoryCombo}}
\index{~KHistoryCombo@{$\sim$KHistoryCombo}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KHistory\-Combo::$\sim${\bf KHistory\-Combo} ()}\label{classKHistoryCombo_a2}


Destructs the combo, the completion-object and the pixmap-provider. 



Definition at line 391 of file kcombobox.cpp.

\subsection{Member Function Documentation}
\index{KHistoryCombo@{KHistory\-Combo}!setHistoryItems@{setHistoryItems}}
\index{setHistoryItems@{setHistoryItems}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::set\-History\-Items ({\bf QString\-List} {\em items})\hspace{0.3cm}{\tt  [inline]}}\label{classKHistoryCombo_a3}


Inserts {\tt items} into the combobox. 

{\tt items} might get truncated if it is longer than {\bf max\-Count}()

\begin{Desc}
\item[See also:]{\bf history\-Items}{\rm (p.\,\pageref{classKHistoryCombo_a5})} \end{Desc}


Definition at line 583 of file kcombobox.h.\index{KHistoryCombo@{KHistory\-Combo}!setHistoryItems@{setHistoryItems}}
\index{setHistoryItems@{setHistoryItems}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::set\-History\-Items ({\bf QString\-List} {\em items}, bool {\em set\-Completion\-List})}\label{classKHistoryCombo_a4}


Inserts {\tt items} into the combobox. 

{\tt items} might get truncated if it is longer than {\bf max\-Count}()

Set {\tt set\-Completion\-List} to true, if you don't have a list of completions. This tells KHistory\-Combo to use all the items for the completion object as well. You won't have the benefit of weighted completion though, so normally you should do something like \small\begin{alltt}
 {\bf KConfig} *config = kapp-$>$config();
 {\bf QStringList} list;\end{alltt}\normalsize 


\small\begin{alltt} // load the history and completion list after creating the history combo
 list = config-$>$readListEntry( "Completion list" );
 combo-$>${\bf completionObject()}-$>$setItems( list );
 list = config-$>$readListEntry( "History list" );
 combo-$>$setHistoryItems( list );\end{alltt}\normalsize 


\small\begin{alltt} [...]\end{alltt}\normalsize 


\small\begin{alltt} // save the history and completion list when the history combo is
 // destroyed
 list = combo-$>${\bf completionObject()}-$>$items()
 config-$>$writeEntry( "Completion list", list );
 list = combo-$>${\bf historyItems()}{\rm (p.\,\pageref{classKHistoryCombo_a5})};
 config-$>$writeEntry( "History list", list );
 \end{alltt}\normalsize 


Be sure to use different names for saving with {\bf KConfig} if you have more than one KHistory\-Combo.

Note: When {\tt set\-Completion\-List} is true, the items are inserted into the {\bf KCompletion} object with mode {\bf KCompletion::Insertion} and the mode is set to {\bf KCompletion::Weighted} afterwards.

\begin{Desc}
\item[See also:]{\bf history\-Items}{\rm (p.\,\pageref{classKHistoryCombo_a5})} 

{\bf KCombo\-Box::completion\-Object} 

{\bf KCompletion::set\-Items} 

{\bf KCompletion::items} \end{Desc}


Definition at line 396 of file kcombobox.cpp.

References QCombo\-Box::clear(), QCombo\-Box::clear\-Edit(), KCompletion\-Base::completion\-Object(), KCompletion::Insertion, insert\-Items(), QCombo\-Box::max\-Count(), KCompletion::set\-Items(), KCompletion::set\-Order(), use\-Completion(), and KCompletion::Weighted.\index{KHistoryCombo@{KHistory\-Combo}!historyItems@{historyItems}}
\index{historyItems@{historyItems}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString\-List} KHistory\-Combo::history\-Items () const}\label{classKHistoryCombo_a5}


Returns the list of history items. 

Empty, when this is not a read-write combobox.

\begin{Desc}
\item[See also:]{\bf set\-History\-Items}{\rm (p.\,\pageref{classKHistoryCombo_a3})} \end{Desc}


Definition at line 418 of file kcombobox.cpp.

References QCombo\-Box::count(), and QCombo\-Box::text().

Referenced by set\-Pixmap\-Provider().\index{KHistoryCombo@{KHistory\-Combo}!removeFromHistory@{removeFromHistory}}
\index{removeFromHistory@{removeFromHistory}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KHistory\-Combo::remove\-From\-History (const {\bf QString} \& {\em item})}\label{classKHistoryCombo_a6}


Removes all items named {\tt item}. 

\begin{Desc}
\item[Returns:]{\tt true} if at least one item was removed.\end{Desc}
\begin{Desc}
\item[See also:]{\bf add\-To\-History}{\rm (p.\,\pageref{classKHistoryCombo_i0})} \end{Desc}


Definition at line 489 of file kcombobox.cpp.

References KCompletion\-Base::completion\-Object(), QCombo\-Box::count(), QCombo\-Box::current\-Text(), QString::is\-Empty(), KCompletion::remove\-Item(), QCombo\-Box::remove\-Item(), QCombo\-Box::set\-Edit\-Text(), QCombo\-Box::text(), and use\-Completion().\index{KHistoryCombo@{KHistory\-Combo}!setPixmapProvider@{setPixmapProvider}}
\index{setPixmapProvider@{setPixmapProvider}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::set\-Pixmap\-Provider ({\bf KPixmap\-Provider} $\ast$ {\em prov})}\label{classKHistoryCombo_a7}


Sets a pixmap provider, so that items in the combobox can have a pixmap. 

{\bf KPixmap\-Provider} is just an abstract class with the one pure virtual method {\bf KPixmap\-Provider::pixmap\-For}(). This method is called whenever an item is added to the KHistory\-Combo\-Box. Implement it to return your own custom pixmaps, or use the {\bf KURLPixmap\-Provider} from libkio, which uses {\bf KMime\-Type::pixmap\-For\-URL} to resolve icons.

Set {\tt prov} to 0L if you want to disable pixmaps. Default no pixmaps.

\begin{Desc}
\item[See also:]{\bf pixmap\-Provider}{\rm (p.\,\pageref{classKHistoryCombo_a8})} \end{Desc}


Definition at line 615 of file kcombobox.cpp.

References QCombo\-Box::clear(), QCombo\-Box::count(), history\-Items(), and insert\-Items().\index{KHistoryCombo@{KHistory\-Combo}!pixmapProvider@{pixmapProvider}}
\index{pixmapProvider@{pixmapProvider}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KPixmap\-Provider}$\ast$ KHistory\-Combo::pixmap\-Provider () const\hspace{0.3cm}{\tt  [inline]}}\label{classKHistoryCombo_a8}


\begin{Desc}
\item[Returns:]the current pixmap provider. \end{Desc}
\begin{Desc}
\item[See also:]{\bf set\-Pixmap\-Provider}{\rm (p.\,\pageref{classKHistoryCombo_a7})} 

{\bf KPixmap\-Provider} \end{Desc}


Definition at line 666 of file kcombobox.h.\index{KHistoryCombo@{KHistory\-Combo}!reset@{reset}}
\index{reset@{reset}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::reset ()\hspace{0.3cm}{\tt  [inline]}}\label{classKHistoryCombo_a9}


Resets the current position of the up/down history. 

Call this when you manually call {\bf set\-Current\-Item}{\rm (p.\,\pageref{classKComboBox_i3})}() or {\bf clear\-Edit}(). 

Definition at line 672 of file kcombobox.h.\index{KHistoryCombo@{KHistory\-Combo}!addToHistory@{addToHistory}}
\index{addToHistory@{addToHistory}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::add\-To\-History (const {\bf QString} \& {\em item})\hspace{0.3cm}{\tt  [slot]}}\label{classKHistoryCombo_i0}


Adds an item to the end of the history list and to the completion list. 

If {\bf max\-Count}() is reached, the first item of the list will be removed.

If the last inserted item is the same as {\tt item}, it will not be inserted again.

If {\bf duplicates\-Enabled}() is false, any equal existing item will be removed before {\tt item} is added.

Note: By using this method and not the Q and {\bf KCombo\-Box}{\rm (p.\,\pageref{classKComboBox})} {\bf insert\-Item()} methods, you make sure that the combobox stays in sync with the completion. It would be annoying if completion would give an item not in the combobox, and vice versa.

\begin{Desc}
\item[See also:]{\bf remove\-From\-History}{\rm (p.\,\pageref{classKHistoryCombo_a6})} 

{\bf QCombo\-Box::set\-Duplicates\-Enabled} \end{Desc}


Definition at line 443 of file kcombobox.cpp.

References KCompletion::add\-Item(), KCompletion\-Base::completion\-Object(), KCombo\-Box::contains(), QCombo\-Box::count(), QCombo\-Box::current\-Item(), QCombo\-Box::duplicates\-Enabled(), QCombo\-Box::insert\-Item(), QString::is\-Empty(), QCombo\-Box::max\-Count(), KPixmap\-Provider::pixmap\-For(), KCompletion::remove\-Item(), QCombo\-Box::remove\-Item(), KCombo\-Box::set\-Current\-Item(), KIcon::Size\-Small, QCombo\-Box::text(), and use\-Completion().\index{KHistoryCombo@{KHistory\-Combo}!clearHistory@{clearHistory}}
\index{clearHistory@{clearHistory}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::clear\-History ()\hspace{0.3cm}{\tt  [slot]}}\label{classKHistoryCombo_i1}


Clears the history and the completion list. 



Definition at line 427 of file kcombobox.cpp.

References KCompletion::clear(), QCombo\-Box::clear(), KCompletion\-Base::completion\-Object(), and use\-Completion().\index{KHistoryCombo@{KHistory\-Combo}!cleared@{cleared}}
\index{cleared@{cleared}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::cleared ()\hspace{0.3cm}{\tt  [signal]}}\label{classKHistoryCombo_l0}


Emitted when the history was cleared by the entry in the popup menu. 

\index{KHistoryCombo@{KHistory\-Combo}!keyPressEvent@{keyPressEvent}}
\index{keyPressEvent@{keyPressEvent}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::key\-Press\-Event ({\bf QKey\-Event} $\ast$)\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKHistoryCombo_b0}


Handling key-events, the shortcuts to rotate the items. 



Definition at line 575 of file kcombobox.cpp.

References KStd\-Accel::is\-Equal().\index{KHistoryCombo@{KHistory\-Combo}!wheelEvent@{wheelEvent}}
\index{wheelEvent@{wheelEvent}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::wheel\-Event ({\bf QWheel\-Event} $\ast$ {\em ev})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKHistoryCombo_b1}


Handling wheel-events, to rotate the items. 



Reimplemented from {\bf KCombo\-Box} {\rm (p.\,\pageref{classKComboBox})}.

Definition at line 590 of file kcombobox.cpp.

References QWheel\-Event::accept(), QWheel\-Event::delta(), QCombo\-Box::list\-Box(), and QApplication::send\-Event().\index{KHistoryCombo@{KHistory\-Combo}!insertItems@{insertItems}}
\index{insertItems@{insertItems}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KHistory\-Combo::insert\-Items (const {\bf QString\-List} \& {\em items})\hspace{0.3cm}{\tt  [protected]}}\label{classKHistoryCombo_b2}


Inserts {\tt items} into the combo, honouring {\bf pixmap\-Provider}{\rm (p.\,\pageref{classKHistoryCombo_a8})}() Does not update the completion\-Object. 

Note: {\bf duplicates\-Enabled}() is not honored here.

Called from {\bf set\-History\-Items}{\rm (p.\,\pageref{classKHistoryCombo_a3})}() and {\bf set\-Pixmap\-Provider}{\rm (p.\,\pageref{classKHistoryCombo_a7})}() 

Definition at line 633 of file kcombobox.cpp.

References QCombo\-Box::insert\-Item(), QString::is\-Empty(), KPixmap\-Provider::pixmap\-For(), and KIcon::Size\-Small.

Referenced by set\-History\-Items(), and set\-Pixmap\-Provider().\index{KHistoryCombo@{KHistory\-Combo}!useCompletion@{useCompletion}}
\index{useCompletion@{useCompletion}!KHistoryCombo@{KHistory\-Combo}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KHistory\-Combo::use\-Completion () const\hspace{0.3cm}{\tt  [inline, protected]}}\label{classKHistoryCombo_b3}


\begin{Desc}
\item[Returns:]if we can modify the completion object or not. \end{Desc}


Definition at line 731 of file kcombobox.h.

References KCompletion\-Base::comp\-Obj().

Referenced by add\-To\-History(), clear\-History(), remove\-From\-History(), and set\-History\-Items().

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