\section{KHistory\-Combo Class Reference}
\label{classKHistoryCombo}\index{KHistoryCombo@{KHistoryCombo}}
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=111pt]{classKHistoryCombo__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KHistory\-Combo:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=178pt]{classKHistoryCombo__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
void {\bf add\-To\-History} (const {\bf QString} \&item)
\item 
void {\bf clear\-History} ()
\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf cleared} ()
\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KHistory\-Combo} ({\bf QWidget} $\ast$parent=0L, const char $\ast$name=0L)
\item 
{\bf KHistory\-Combo} (bool use\-Completion, {\bf QWidget} $\ast$parent=0L, const char $\ast$name=0L)
\item 
{\bf $\sim$KHistory\-Combo} ()
\item 
void {\bf set\-History\-Items} ({\bf QString\-List} items)
\item 
void {\bf set\-History\-Items} ({\bf QString\-List} items, bool set\-Completion\-List)
\item 
{\bf QString\-List} {\bf history\-Items} () const 
\item 
bool {\bf remove\-From\-History} (const {\bf QString} \&item)
\item 
void {\bf set\-Pixmap\-Provider} ({\bf KPixmap\-Provider} $\ast$prov)
\item 
{\bf KPixmap\-Provider} $\ast$ {\bf pixmap\-Provider} () const 
\item 
void {\bf reset} ()
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual void {\bf key\-Press\-Event} ({\bf QKey\-Event} $\ast$)
\item 
virtual void {\bf wheel\-Event} ({\bf QWheel\-Event} $\ast$ev)
\item 
void {\bf insert\-Items} (const {\bf QString\-List} \&items)
\item 
bool {\bf use\-Completion} () const 
\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKHistoryCombo_b4}

\end{CompactItemize}
\subsection*{Properties}
\begin{CompactItemize}
\item 
{\bf QString\-List} {\bf history\-Items}\label{classKHistoryCombo_00}

\end{CompactItemize}


\subsection{Detailed Description}
A combobox for offering a history and completion. 

A combobox which implements a history like a unix shell. 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 533 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} = {\tt 0L}, const char $\ast$ {\em name} = {\tt 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 add\-To\-History. If you want every item added, use



\footnotesize\begin{verbatim} connect( combo, SIGNAL( activated( const QString& )),
          combo, SLOT( addToHistory( const QString& )));
\end{verbatim}
\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 348 of file kcombobox.cpp.\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} = {\tt 0L}, const char $\ast$ {\em name} = {\tt 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 355 of file kcombobox.cpp.\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 383 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 581 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 

\footnotesize\begin{verbatim} KConfig *config = kapp->config();
 QStringList list;

 // load the history and completion list after creating the history combo
 list = config->readListEntry( "Completion list" );
 combo->completionObject()->setItems( list );
 list = config->readListEntry( "History list" );
 combo->setHistoryItems( list );

 [...]

 // save the history and completion list when the history combo is
 // destroyed
 list = combo->completionObject()->items()
 config->writeEntry( "Completion list", list );
 list = combo->historyItems();
 config->writeEntry( "History list", list );
\end{verbatim}
\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 388 of file kcombobox.cpp.

References QCombo\-Box::clear(), QCombo\-Box::clear\-Edit(), KCompletion\-Base::completion\-Object(), insert\-Items(), QCombo\-Box::max\-Count(), KCompletion::set\-Items(), KCompletion::set\-Order(), and use\-Completion().\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}


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 499 of file kcombobox.cpp.

References KCompletion\-Base::completion\-Object(), QCombo\-Box::count(), QCombo\-Box::current\-Text(), 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 635 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 664 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 670 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 447 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(), QCombo\-Box::max\-Count(), KPixmap\-Provider::pixmap\-For(), KCompletion::remove\-Item(), QCombo\-Box::remove\-Item(), KCombo\-Box::set\-Current\-Item(), 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(), QCombo\-Box::current\-Text(), QCombo\-Box::set\-Edit\-Text(), 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 594 of file kcombobox.cpp.

References KCombo\-Box::contains().\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 610 of file kcombobox.cpp.

References 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, honoring {\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 653 of file kcombobox.cpp.

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

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 729 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}
