\section{KCompletion\-Box Class Reference}
\label{classKCompletionBox}\index{KCompletionBox@{KCompletionBox}}
A helper widget for \char`\"{}completion-widgets\char`\"{} ({\bf KLine\-Edit}{\rm (p.\,\pageref{classKLineEdit})}, {\bf KCombo\-Box}{\rm (p.\,\pageref{classKComboBox})})).  


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

Inheritance diagram for KCompletion\-Box:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=63pt]{classKCompletionBox__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KCompletion\-Box:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=155pt]{classKCompletionBox__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
{\bf QString\-List} {\bf items} () const 
\item 
void {\bf insert\-Items} (const {\bf QString\-List} \&items, int {\bf index}=-1)
\item 
void {\bf set\-Items} (const {\bf QString\-List} \&items)
\item 
virtual void {\bf popup} ()
\item 
void {\bf set\-Tab\-Handling} (bool enable)
\item 
bool {\bf is\-Tab\-Handling} () const 
\item 
void {\bf set\-Cancelled\-Text} (const {\bf QString} \&txt)
\item 
{\bf QString} {\bf cancelled\-Text} () const 
\item 
void {\bf set\-Activate\-On\-Select} (bool state)
\item 
void {\bf down} ()
\item 
void {\bf up} ()
\item 
void {\bf page\-Down} ()
\item 
void {\bf page\-Up} ()
\item 
void {\bf home} ()
\item 
void {\bf end} ()
\item 
virtual void {\bf show} ()
\item 
virtual void {\bf hide} ()
\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf activated} (const {\bf QString} \&)
\item 
void {\bf user\-Cancelled} (const {\bf QString} \&)
\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KCompletion\-Box} ({\bf QWidget} $\ast$parent, const char $\ast$name=0)
\item 
{\bf $\sim$KCompletion\-Box} ()
\item 
virtual {\bf QSize} {\bf size\-Hint} () const \label{classKCompletionBox_a2}

\item 
bool {\bf activate\-On\-Select} () const 
\end{CompactItemize}
\subsection*{Protected Slots}
\begin{CompactItemize}
\item 
virtual void {\bf slot\-Activated} ({\bf QList\-Box\-Item} $\ast$)
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
{\bf QRect} {\bf calculate\-Geometry} () const 
\item 
void {\bf size\-And\-Position} ()
\item 
virtual bool {\bf event\-Filter} ({\bf QObject} $\ast$, {\bf QEvent} $\ast$)
\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKCompletionBox_b3}

\end{CompactItemize}
\subsection*{Properties}
\begin{CompactItemize}
\item 
bool {\bf is\-Tab\-Handling}\label{classKCompletionBox_00}

\item 
{\bf QString} {\bf cancelled\-Text}\label{classKCompletionBox_01}

\item 
bool {\bf activate\-On\-Select}\label{classKCompletionBox_02}

\end{CompactItemize}


\subsection{Detailed Description}
A helper widget for \char`\"{}completion-widgets\char`\"{} ({\bf KLine\-Edit}{\rm (p.\,\pageref{classKLineEdit})}, {\bf KCombo\-Box}{\rm (p.\,\pageref{classKComboBox})})). 

A little utility class for \char`\"{}completion-widgets\char`\"{}, like {\bf KLine\-Edit}{\rm (p.\,\pageref{classKLineEdit})} or {\bf KCombo\-Box}{\rm (p.\,\pageref{classKComboBox})}. KCompletion\-Box is a listbox, displayed as a rectangle without any window decoration, usually directly under the lineedit or combobox. It is filled with all possible matches for a completion, so the user can select the one he wants.

It is used when {\bf KGlobal\-Settings::Completion} == Completion\-Popup or Completion\-Popup\-Auto.

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




Definition at line 43 of file kcompletionbox.h.

\subsection{Constructor \& Destructor Documentation}
\index{KCompletionBox@{KCompletion\-Box}!KCompletionBox@{KCompletionBox}}
\index{KCompletionBox@{KCompletionBox}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KCompletion\-Box::KCompletion\-Box ({\bf QWidget} $\ast$ {\em parent}, const char $\ast$ {\em name} = {\tt 0})}\label{classKCompletionBox_a0}


Constructs a KCompletion\-Box. 

The parent widget is used to give the focus back when pressing the up-button on the very first item. 

Definition at line 47 of file kcompletionbox.cpp.

References QList\-Box::clicked(), QList\-Box::current\-Changed(), KList\-Box::double\-Clicked(), QList\-Box::set\-Column\-Mode(), and slot\-Activated().\index{KCompletionBox@{KCompletion\-Box}!~KCompletionBox@{$\sim$KCompletionBox}}
\index{~KCompletionBox@{$\sim$KCompletionBox}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KCompletion\-Box::$\sim${\bf KCompletion\-Box} ()}\label{classKCompletionBox_a1}


Destroys the box. 



Definition at line 79 of file kcompletionbox.cpp.

\subsection{Member Function Documentation}
\index{KCompletionBox@{KCompletion\-Box}!activateOnSelect@{activateOnSelect}}
\index{activateOnSelect@{activateOnSelect}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KCompletion\-Box::activate\-On\-Select () const}\label{classKCompletionBox_a3}


\begin{Desc}
\item[Returns:]true if selecting an item results in the emition of the {\bf selected} signal.\end{Desc}
\begin{Desc}
\item[Since:]3.4.1 \end{Desc}
\index{KCompletionBox@{KCompletion\-Box}!items@{items}}
\index{items@{items}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString\-List} KCompletion\-Box::items () const\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i0}


Returns a list of all items currently in the box. 



Definition at line 85 of file kcompletionbox.cpp.

References QList\-Box::first\-Item(), QList\-Box\-Item::next(), and QList\-Box\-Item::text().

Referenced by set\-Items().\index{KCompletionBox@{KCompletion\-Box}!insertItems@{insertItems}}
\index{insertItems@{insertItems}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::insert\-Items (const {\bf QString\-List} \& {\em items}, int {\em index} = {\tt -1})\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i1}


Inserts {\tt items} into the box. 

Does not clear the items before. {\tt index} determines at which position {\tt items} will be inserted. (defaults to appending them at the end) 

Definition at line 468 of file kcompletionbox.cpp.

References QList\-Box::insert\-String\-List().\index{KCompletionBox@{KCompletion\-Box}!setItems@{setItems}}
\index{setItems@{setItems}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::set\-Items (const {\bf QString\-List} \& {\em items})\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i2}


Clears the box and inserts {\tt items}. 



Definition at line 477 of file kcompletionbox.cpp.

References QList\-Box::first\-Item(), QList\-Box::insert\-Item(), QList\-Box::insert\-String\-List(), items(), QList\-Box\-Item::next(), size\-And\-Position(), and QList\-Box::trigger\-Update().

Referenced by KLine\-Edit::set\-Completed\-Items().\index{KCompletionBox@{KCompletion\-Box}!popup@{popup}}
\index{popup@{popup}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::popup ()\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKCompletionBox_i3}


Adjusts the size of the box to fit the width of the parent given in the constructor and pops it up at the most appropriate place, relative to the parent. 

Depending on the screensize and the position of the parent, this may be a different place, however the default is to pop it up and the lower left corner of the parent.

Make sure to {\bf hide()}{\rm (p.\,\pageref{classKCompletionBox_i16})} the box when appropriate. 

Definition at line 250 of file kcompletionbox.cpp.

References QList\-Box::clear\-Selection(), QList\-Box::count(), QList\-Box::ensure\-Current\-Visible(), hide(), QList\-Box::set\-Current\-Item(), show(), and size\-And\-Position().\index{KCompletionBox@{KCompletion\-Box}!setTabHandling@{setTabHandling}}
\index{setTabHandling@{setTabHandling}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::set\-Tab\-Handling (bool {\em enable})\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i4}


Makes this widget (when visible) capture Tab-key events to traverse the items in the dropdown list. 

Default off, as it conflicts with the usual behavior of Tab to traverse widgets. It is useful for cases like Konqueror's Location Bar, though.

\begin{Desc}
\item[See also:]{\bf is\-Tab\-Handling}{\rm (p.\,\pageref{classKCompletionBox_i5})} \end{Desc}


Definition at line 426 of file kcompletionbox.cpp.\index{KCompletionBox@{KCompletion\-Box}!isTabHandling@{isTabHandling}}
\index{isTabHandling@{isTabHandling}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KCompletion\-Box::is\-Tab\-Handling () const\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i5}


\begin{Desc}
\item[Returns:]true if this widget is handling Tab-key events to traverse the items in the dropdown list, otherwise false.\end{Desc}
Default is false.

\begin{Desc}
\item[See also:]{\bf set\-Tab\-Handling}{\rm (p.\,\pageref{classKCompletionBox_i4})} \end{Desc}
\index{KCompletionBox@{KCompletion\-Box}!setCancelledText@{setCancelledText}}
\index{setCancelledText@{setCancelledText}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::set\-Cancelled\-Text (const {\bf QString} \& {\em txt})\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i6}


Sets the text to be emitted if the user chooses not to pick from the available matches. 

If the canceled text is not set through this function, the user\-Cancelled signal will not be emitted.

\begin{Desc}
\item[See also:]{\bf user\-Cancelled( const QString\& )}{\rm (p.\,\pageref{classKCompletionBox_l1})} \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em txt}]the text to be emitted if the user cancels this box \end{description}
\end{Desc}


Definition at line 436 of file kcompletionbox.cpp.\index{KCompletionBox@{KCompletion\-Box}!cancelledText@{cancelledText}}
\index{cancelledText@{cancelledText}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KCompletion\-Box::cancelled\-Text () const\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i7}


\begin{Desc}
\item[Returns:]the text set via {\bf set\-Cancelled\-Text()}{\rm (p.\,\pageref{classKCompletionBox_i6})} or QString::null. \end{Desc}
\index{KCompletionBox@{KCompletion\-Box}!setActivateOnSelect@{setActivateOnSelect}}
\index{setActivateOnSelect@{setActivateOnSelect}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::set\-Activate\-On\-Select (bool {\em state})\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i8}


Set whether or not the selected signal should be emitted when an item is selected. 

By default the selevted signal is emitted.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em state}]false if the signal should not be emitted. \end{description}
\end{Desc}
\begin{Desc}
\item[Since:]3.4.1 \end{Desc}


Definition at line 549 of file kcompletionbox.cpp.\index{KCompletionBox@{KCompletion\-Box}!down@{down}}
\index{down@{down}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::down ()\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i9}


Moves the selection one line down or select the first item if nothing is selected yet. 



Definition at line 381 of file kcompletionbox.cpp.

References QList\-Box::count(), QList\-Box::current\-Item(), QList\-Box::current\-Text(), QList\-Box::highlighted(), QList\-Box::set\-Current\-Item(), and QList\-Box::set\-Selected().

Referenced by event\-Filter().\index{KCompletionBox@{KCompletion\-Box}!up@{up}}
\index{up@{up}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::up ()\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i10}


Moves the selection one line up or select the first item if nothing is selected yet. 



Definition at line 396 of file kcompletionbox.cpp.

References QList\-Box::current\-Item(), and QList\-Box::set\-Current\-Item().

Referenced by event\-Filter().\index{KCompletionBox@{KCompletion\-Box}!pageDown@{pageDown}}
\index{pageDown@{pageDown}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::page\-Down ()\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i11}


Moves the selection one page down. 



Definition at line 402 of file kcompletionbox.cpp.

References QList\-Box::count(), QList\-Box::current\-Item(), QList\-Box::num\-Items\-Visible(), and QList\-Box::set\-Current\-Item().

Referenced by event\-Filter().\index{KCompletionBox@{KCompletion\-Box}!pageUp@{pageUp}}
\index{pageUp@{pageUp}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::page\-Up ()\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i12}


Moves the selection one page up. 



Definition at line 409 of file kcompletionbox.cpp.

References QList\-Box::current\-Item(), QList\-Box::num\-Items\-Visible(), and QList\-Box::set\-Current\-Item().

Referenced by event\-Filter().\index{KCompletionBox@{KCompletion\-Box}!home@{home}}
\index{home@{home}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::home ()\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i13}


Moves the selection up to the first item. 



Definition at line 416 of file kcompletionbox.cpp.

References QList\-Box::set\-Current\-Item().

Referenced by event\-Filter().\index{KCompletionBox@{KCompletion\-Box}!end@{end}}
\index{end@{end}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::end ()\hspace{0.3cm}{\tt  [slot]}}\label{classKCompletionBox_i14}


Moves the selection down to the last item. 



Definition at line 421 of file kcompletionbox.cpp.

References QList\-Box::count(), and QList\-Box::set\-Current\-Item().

Referenced by event\-Filter().\index{KCompletionBox@{KCompletion\-Box}!show@{show}}
\index{show@{show}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::show ()\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKCompletionBox_i15}


Re-implemented for internal reasons. 

API is unaffected. 

Definition at line 300 of file kcompletionbox.cpp.

References size\-And\-Position().

Referenced by popup().\index{KCompletionBox@{KCompletion\-Box}!hide@{hide}}
\index{hide@{hide}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::hide ()\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKCompletionBox_i16}


Re-implemented for internal reasons. 

API is unaffected. 

Definition at line 324 of file kcompletionbox.cpp.

Referenced by event\-Filter(), popup(), and slot\-Activated().\index{KCompletionBox@{KCompletion\-Box}!activated@{activated}}
\index{activated@{activated}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::activated (const {\bf QString} \&)\hspace{0.3cm}{\tt  [signal]}}\label{classKCompletionBox_l0}


Emitted when an item was selected, contains the text of the selected item. 



Referenced by slot\-Activated().\index{KCompletionBox@{KCompletion\-Box}!userCancelled@{userCancelled}}
\index{userCancelled@{userCancelled}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::user\-Cancelled (const {\bf QString} \&)\hspace{0.3cm}{\tt  [signal]}}\label{classKCompletionBox_l1}


Emitted whenever the user chooses to ignore the available selections and close the this box. 

\index{KCompletionBox@{KCompletion\-Box}!calculateGeometry@{calculateGeometry}}
\index{calculateGeometry@{calculateGeometry}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QRect} KCompletion\-Box::calculate\-Geometry () const\hspace{0.3cm}{\tt  [protected]}}\label{classKCompletionBox_b0}


This calculates the size of the dropdown and the relative position of the top left corner with respect to the parent widget. 

This matches the geometry and position normally used by K/QCombo\-Box when used with one. 

Definition at line 332 of file kcompletionbox.cpp.

References QList\-Box::count(), QObject::inherits(), QRect::is\-Null(), QList\-Box::item\-Height(), QObject::parent(), QRect::width(), QPoint::x(), and QPoint::y().

Referenced by size\-And\-Position().\index{KCompletionBox@{KCompletion\-Box}!sizeAndPosition@{sizeAndPosition}}
\index{sizeAndPosition@{sizeAndPosition}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::size\-And\-Position ()\hspace{0.3cm}{\tt  [protected]}}\label{classKCompletionBox_b1}


This properly sizes and positions the listbox. 



Definition at line 268 of file kcompletionbox.cpp.

References QRect::bottom(), calculate\-Geometry(), KGlobal\-Settings::desktop\-Geometry(), QRect::height(), QRect::right(), QRect::size(), QRect::x(), QPoint::x(), QRect::y(), and QPoint::y().

Referenced by popup(), set\-Items(), and show().\index{KCompletionBox@{KCompletion\-Box}!eventFilter@{eventFilter}}
\index{eventFilter@{eventFilter}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KCompletion\-Box::event\-Filter ({\bf QObject} $\ast$, {\bf QEvent} $\ast$)\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKCompletionBox_b2}


Reimplemented from {\bf KList\-Box}{\rm (p.\,\pageref{classKListBox})} to get events from the viewport (to hide this widget on mouse-click, Escape-presses, etc. 



Definition at line 108 of file kcompletionbox.cpp.

References QMouse\-Event::accept(), QKey\-Event::accept(), QList\-Box::current\-Text(), down(), end(), hide(), QList\-Box::highlighted(), home(), QKey\-Event::key(), page\-Down(), page\-Up(), QMouse\-Event::pos(), QList\-Box::selected\-Item(), QKey\-Event::state(), and up().\index{KCompletionBox@{KCompletion\-Box}!slotActivated@{slotActivated}}
\index{slotActivated@{slotActivated}!KCompletionBox@{KCompletion\-Box}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCompletion\-Box::slot\-Activated ({\bf QList\-Box\-Item} $\ast$)\hspace{0.3cm}{\tt  [protected, virtual, slot]}}\label{classKCompletionBox_j0}


Called when an item was activated. 

Emits {\bf activated()}{\rm (p.\,\pageref{classKCompletionBox_l0})} with the item. 

Definition at line 99 of file kcompletionbox.cpp.

References activated(), and hide().

Referenced by KCompletion\-Box().

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