.TH "KCompletionBase" 3 "28 Jan 2004" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KCompletionBase \- An abstract base class for adding a completion feature into widgets. An abstract class for adding text completion support to widgets.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kcompletion.h>\fP
.PP
Inherited by \fBKComboBox\fP, and \fBKLineEdit\fP.
.PP
.SS "Public Types"

.in +1c
.ti -1c
.RI "typedef \fBQMap\fP< \fBKeyBindingType\fP, KShortcut > \fBKeyBindingMap\fP"
.br
.ti -1c
.RI "enum \fBKeyBindingType\fP { \fBTextCompletion\fP, \fBPrevCompletionMatch\fP, \fBNextCompletionMatch\fP, \fBSubstringCompletion\fP }"
.br
.RI "\fIConstants that represent the items whose short-cut key-binding is programmable. \fP"
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKCompletionBase\fP ()"
.br
.RI "\fIDefault constructor. \fP"
.ti -1c
.RI "virtual \fB~KCompletionBase\fP ()"
.br
.RI "\fIDestructor. \fP"
.ti -1c
.RI "\fBKCompletion\fP * \fBcompletionObject\fP (bool hsig=true)"
.br
.RI "\fIReturns a pointer to the current completion object. \fP"
.ti -1c
.RI "virtual void \fBsetCompletionObject\fP (\fBKCompletion\fP *, bool hsig=true)"
.br
.RI "\fISets up the completion object to be used. \fP"
.ti -1c
.RI "virtual void \fBsetHandleSignals\fP (bool)"
.br
.RI "\fIEnables this object to handle completion and rotation events internally. \fP"
.ti -1c
.RI "bool \fBisCompletionObjectAutoDeleted\fP () const "
.br
.RI "\fIReturns true if the completion object is deleted upon this widget's destruction. \fP"
.ti -1c
.RI "void \fBsetAutoDeleteCompletionObject\fP (bool autoDelete)"
.br
.RI "\fISets the completion object when this widget's destructor is called. \fP"
.ti -1c
.RI "void \fBsetEnableSignals\fP (bool enable)"
.br
.RI "\fISets the widget's ability to emit text completion and rotation signals. \fP"
.ti -1c
.RI "bool \fBhandleSignals\fP () const "
.br
.RI "\fIReturns true if the object handles the signals. \fP"
.ti -1c
.RI "bool \fBemitSignals\fP () const "
.br
.RI "\fIReturns true if the object emits the signals. \fP"
.ti -1c
.RI "virtual void \fBsetCompletionMode\fP (\fBKGlobalSettings::Completion\fP mode)"
.br
.RI "\fISets the type of completion to be used. \fP"
.ti -1c
.RI "\fBKGlobalSettings::Completion\fP \fBcompletionMode\fP () const "
.br
.RI "\fIReturns the current completion mode. \fP"
.ti -1c
.RI "bool \fBsetKeyBinding\fP (\fBKeyBindingType\fP, const  KShortcut &cut)"
.br
.RI "\fISets the key-binding to be used for manual text completion, text rotation in a history list as well as a completion list. \fP"
.ti -1c
.RI "const  KShortcut & \fBgetKeyBinding\fP (\fBKeyBindingType\fP item) const "
.br
.RI "\fIReturns the key-binding used for the specified item. \fP"
.ti -1c
.RI "void \fBuseGlobalKeyBindings\fP ()"
.br
.RI "\fISets this object to use global values for key-bindings. \fP"
.ti -1c
.RI "virtual void \fBsetCompletedText\fP (const  \fBQString\fP &text)=0"
.br
.RI "\fIA pure virtual function that must be implemented by all inheriting classes. \fP"
.ti -1c
.RI "virtual void \fBsetCompletedItems\fP (const  \fBQStringList\fP &items)=0"
.br
.RI "\fIA pure virtual function that must be implemented by all inheriting classes. \fP"
.ti -1c
.RI "\fBKCompletion\fP * \fBcompObj\fP () const "
.br
.RI "\fIReturns a pointer to the completion object. \fP"
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "\fBKeyBindingMap\fP \fBgetKeyBindings\fP () const "
.br
.RI "\fIReturns a key-binding map. \fP"
.ti -1c
.RI "void \fBsetDelegate\fP (\fBKCompletionBase\fP *delegate)"
.br
.RI "\fISets or removes the delegation object. \fP"
.ti -1c
.RI "\fBKCompletionBase\fP * \fBdelegate\fP () const "
.br
.RI "\fIReturns the delegation object. \fP"
.ti -1c
.RI "virtual void \fBvirtual_hook\fP (int id, void *data)"
.br
.in -1c
.SH "Detailed Description"
.PP 
An abstract base class for adding a completion feature into widgets. An abstract class for adding text completion support to widgets. 

This is a convenience class that provides the basic functions needed to add text completion support into widgets. All that is required is an implementation for the pure virtual function \fBsetCompletedText\fP. Refer to \fBKLineEdit\fP or \fBKComboBox\fP to see how easily such support can be added using this as a base class.
.PP
\fBAuthor:\fP
.RS 4
Dawit Alemayehu <adawit@kde.org> 
.RE
.PP

.PP
Definition at line 655 of file kcompletion.h.
.SH "Member Enumeration Documentation"
.PP 
.SS "enum \fBKCompletionBase::KeyBindingType\fP"
.PP
Constants that represent the items whose short-cut key-binding is programmable. The default key-bindings for these items are defined in \fBKStdAccel\fP. 
.PP
\fBEnumeration values: \fP
.in +1c
.TP
\fB\fITextCompletion \fP\fP
Text completion (by default Ctrl-E). 
.TP
\fB\fIPrevCompletionMatch \fP\fP
Switch to previous completion (by default Ctrl-Up). 
.TP
\fB\fINextCompletionMatch \fP\fP
Switch to next completion (by default Ctrl-Down). 
.TP
\fB\fISubstringCompletion \fP\fP
Substring completion (by default Ctrl-T). 
.PP
Definition at line 665 of file kcompletion.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KCompletionBase::KCompletionBase ()"
.PP
Default constructor. Definition at line 25 of file kcompletionbase.cpp.
.PP
References KGlobalSettings::completionMode(), and useGlobalKeyBindings().
.SS "KCompletionBase::~\fBKCompletionBase\fP ()\fC [virtual]\fP"
.PP
Destructor. Definition at line 41 of file kcompletionbase.cpp.
.SH "Member Function Documentation"
.PP 
.SS "\fBKCompletion\fP * KCompletionBase::completionObject (bool hsig = true)"
.PP
Returns a pointer to the current completion object. If the object does not exist, it is automatically created. Note that the completion object created here is used by default to handle the signals internally. It is also deleted when this object's destructor is invoked. If you do not want these default settings, use \fBsetAutoDeleteCompletionObject\fP and \fBsetHandleSignals\fP to change the behavior. Alternatively, you can set the boolean parameter to false to disable the automatic handling of the signals by this object. Note that the boolean argument will be ignored if there already exists a completion object since no new object needs to be created. You need to use either \fBsetHandleSignals\fP or \fBsetCompletionObject\fP for such cases depending on your requirement.
.PP
\fBParameters:\fP
.RS 4
\fIhsig\fP if true, handles signals internally. 
.RE
.PP
\fBReturns:\fP
.RS 4
a pointer the completion object. 
.RE
.PP
Definition at line 62 of file kcompletionbase.cpp.
.PP
References setCompletionObject().
.SS "void KCompletionBase::setCompletionObject (\fBKCompletion\fP *, bool hsig = true)\fC [virtual]\fP"
.PP
Sets up the completion object to be used. This method assigns the completion object and sets it up to automatically handle the completion and rotation signals internally. You should use this function if you want to share one completion object among you widgets or need to use a customized completion object.
.PP
The object assigned through this method is not deleted when this object's destructor is invoked unless you explicitly call \fBsetAutoDeleteCompletionObject\fP after calling this method. Also if you do not want the signals to be handled by an internal implementation, be sure to set the bool argument to false.
.PP
This method is also called when a completion-object is created automatically, when \fBcompletionObject()\fP is called the first time.
.PP
\fBParameters:\fP
.RS 4
\fIcompObj\fP a \fBKCompletion\fP() or a derived child object. 
.br
\fIhsig\fP if true, handles signals internally. 
.RE
.PP
Reimplemented in \fBKLineEdit\fP.
.PP
Definition at line 75 of file kcompletionbase.cpp.
.PP
References QGuardedPtr< KCompletion >::isNull().
.PP
Referenced by completionObject().
.SS "void KCompletionBase::setHandleSignals (bool)\fC [virtual]\fP"
.PP
Enables this object to handle completion and rotation events internally. This function simply assigns a boolean value that indicates whether it should handle rotation and completion events or not. Note that this does not stop the object from emitting signals when these events occur.
.PP
\fBParameters:\fP
.RS 4
\fIhandle\fP if true, handle completion & rotation internally. 
.RE
.PP
Definition at line 93 of file kcompletionbase.cpp.
.SS "bool KCompletionBase::isCompletionObjectAutoDeleted () const\fC [inline]\fP"
.PP
Returns true if the completion object is deleted upon this widget's destruction. See \fBsetCompletionObject\fP() and \fBenableCompletion\fP() for details.
.PP
\fBReturns:\fP
.RS 4
true if the completion object will be deleted automatically 
.RE
.PP
Definition at line 769 of file kcompletion.h.
.SS "void KCompletionBase::setAutoDeleteCompletionObject (bool autoDelete)\fC [inline]\fP"
.PP
Sets the completion object when this widget's destructor is called. If the argument is set to true, the completion object is deleted when this widget's destructor is called.
.PP
\fBParameters:\fP
.RS 4
\fIautoDelete\fP if true, delete completion object on destruction. 
.RE
.PP
Definition at line 782 of file kcompletion.h.
.SS "void KCompletionBase::setEnableSignals (bool enable)\fC [inline]\fP"
.PP
Sets the widget's ability to emit text completion and rotation signals. Invoking this function with \fCenable\fP set to \fCfalse\fP will cause the completion & rotation signals not to be emitted. However, unlike setting the completion object to \fCNULL\fP using \fBsetCompletionObject\fP, disabling the emition of the signals through this method does not affect the current completion object.
.PP
There is no need to invoke this function by default. When a completion object is created through \fBcompletionObject\fP or \fBsetCompletionObject\fP, these signals are set to emit automatically. Also note that disabling this signals will not necessarily interfere with the objects ability to handle these events internally. See \fBsetHandleSignals\fP.
.PP
\fBParameters:\fP
.RS 4
\fIenable\fP if false, disables the emition of completion & rotation signals. 
.RE
.PP
Definition at line 809 of file kcompletion.h.
.SS "bool KCompletionBase::handleSignals () const\fC [inline]\fP"
.PP
Returns true if the object handles the signals. \fBReturns:\fP
.RS 4
true if this signals are handled internally. 
.RE
.PP
Definition at line 821 of file kcompletion.h.
.SS "bool KCompletionBase::emitSignals () const\fC [inline]\fP"
.PP
Returns true if the object emits the signals. \fBReturns:\fP
.RS 4
true if signals are emitted 
.RE
.PP
Definition at line 828 of file kcompletion.h.
.SS "void KCompletionBase::setCompletionMode (\fBKGlobalSettings::Completion\fP mode)\fC [virtual]\fP"
.PP
Sets the type of completion to be used. The completion modes supported are those defined in \fBKGlobalSettings\fP(). See below.
.PP
\fBParameters:\fP
.RS 4
\fImode\fP Completion type: 
.IP "\(bu" 2
CompletionNone: Disables completion feature. 
.IP "\(bu" 2
CompletionAuto: Attempts to find a match & fills-in the remaining text. 
.IP "\(bu" 2
CompletionMan: Acts the same as the above except the action has to be manually triggered through pre-defined completion key. 
.IP "\(bu" 2
CompletionShell: Mimics the completion feature found in typical *nix shell environments. 
.IP "\(bu" 2
CompletionPopup: Shows all available completions at once, in a listbox popping up. 
.PP
.RE
.PP
Reimplemented in \fBKLineEdit\fP.
.PP
Definition at line 101 of file kcompletionbase.cpp.
.PP
References KGlobalSettings::CompletionNone.
.SS "\fBKGlobalSettings::Completion\fP KCompletionBase::completionMode () const\fC [inline]\fP"
.PP
Returns the current completion mode. The return values are of type \fBKGlobalSettings::Completion\fP. See \fBsetCompletionMode\fP() for details.
.PP
\fBReturns:\fP
.RS 4
the completion mode. 
.RE
.PP
Definition at line 860 of file kcompletion.h.
.PP
References KGlobalSettings::Completion.
.SS "bool KCompletionBase::setKeyBinding (\fBKeyBindingType\fP, const KShortcut & cut)"
.PP
Sets the key-binding to be used for manual text completion, text rotation in a history list as well as a completion list. When the keys set by this function are pressed, a signal defined by the inheriting widget will be activated. If the default value or 0 is specified by the second parameter, then the key-binding as defined in the global setting should be used. This method returns false value for \fCkey\fP is negative or the supplied key-binding conflicts with the ones set for one of the other features.
.PP
NOTE: To use a modifier key (Shift, Ctrl, Alt) as part of the key-binding simply simply \fCsum\fP up the values of the modifier and the actual key. For example, to use CTRL+E as a key binding for one of the items, you would simply supply \fC'Qt::CtrlButton + Qt::Key_E'\fP as the second argument to this function.
.PP
\fBParameters:\fP
.RS 4
\fIitem\fP the feature whose key-binding needs to be set: 
.IP "\(bu" 2
TextCompletion the manual completion key-binding. 
.IP "\(bu" 2
PrevCompletionMatch the previous match key for multiple completion. 
.IP "\(bu" 2
NextCompletionMatch the next match key for for multiple completion. 
.IP "\(bu" 2
SubstringCompletion the key for substring completion 
.PP
.br
\fIkey\fP key-binding used to rotate down in a list. 
.RE
.PP
\fBReturns:\fP
.RS 4
true if key-binding can successfully be set. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBgetKeyBinding\fP 
.RE
.PP
Definition at line 115 of file kcompletionbase.cpp.
.PP
References QMap::begin(), KStdAction::cut(), QMap::end(), and QMap::replace().
.SS "const KShortcut& KCompletionBase::getKeyBinding (\fBKeyBindingType\fP item) const\fC [inline]\fP"
.PP
Returns the key-binding used for the specified item. This methods returns the key-binding used to activate the feature feature given by \fCitem\fP. If the binding contains modifier key(s), the SUM of the modifier key and the actual key code are returned.
.PP
\fBParameters:\fP
.RS 4
\fIitem\fP the item to check 
.RE
.PP
\fBReturns:\fP
.RS 4
the key-binding used for the feature given by \fCitem\fP. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBsetKeyBinding\fP 
.RE
.PP
Definition at line 908 of file kcompletion.h.
.SS "void KCompletionBase::useGlobalKeyBindings ()"
.PP
Sets this object to use global values for key-bindings. This method changes the values of the key bindings for rotation and completion features to the default values provided in \fBKGlobalSettings\fP.
.PP
NOTE: By default inheriting widgets should uses the global key-bindings so that there will be no need to call this method. Definition at line 130 of file kcompletionbase.cpp.
.PP
References QMap::clear(), QMap::insert(), NextCompletionMatch, PrevCompletionMatch, SubstringCompletion, and TextCompletion.
.PP
Referenced by KCompletionBase().
.SS "virtual void KCompletionBase::setCompletedText (const \fBQString\fP & text)\fC [pure virtual]\fP"
.PP
A pure virtual function that must be implemented by all inheriting classes. This function is intended to allow external completion implementations to set completed text appropriately. It is mostly relevant when the completion mode is set to CompletionAuto and CompletionManual modes. See \fBKCompletionBase::setCompletedText\fP. Does nothing in CompletionPopup mode, as all available matches will be shown in the popup.
.PP
\fBParameters:\fP
.RS 4
\fItext\fP the completed text to be set in the widget. 
.RE
.PP
Implemented in \fBKComboBox\fP, and \fBKLineEdit\fP.
.SS "virtual void KCompletionBase::setCompletedItems (const \fBQStringList\fP & items)\fC [pure virtual]\fP"
.PP
A pure virtual function that must be implemented by all inheriting classes. \fBParameters:\fP
.RS 4
\fIitems\fP the list of completed items 
.RE
.PP
Implemented in \fBKComboBox\fP, and \fBKLineEdit\fP.
.SS "\fBKCompletion\fP* KCompletionBase::compObj () const\fC [inline]\fP"
.PP
Returns a pointer to the completion object. This method is only different from \fBcompletionObject\fP() in that it does not create a new \fBKCompletion\fP object even if the internal pointer is \fCNULL\fP. Use this method to get the pointer to a completion object when inheriting so that you won't inadvertently create it!!
.PP
\fBReturns:\fP
.RS 4
the completion object or NULL if one does not exist. 
.RE
.PP
Definition at line 959 of file kcompletion.h.
.SS "\fBKeyBindingMap\fP KCompletionBase::getKeyBindings () const\fC [inline, protected]\fP"
.PP
Returns a key-binding map. This method is the same as \fBgetKeyBinding\fP() except it returns the whole keymap containing the key-bindings.
.PP
\fBReturns:\fP
.RS 4
the key-binding used for the feature given by \fCitem\fP. 
.RE
.PP
Definition at line 970 of file kcompletion.h.
.SS "void KCompletionBase::setDelegate (\fBKCompletionBase\fP * delegate)\fC [protected]\fP"
.PP
Sets or removes the delegation object. If a delegation object is set, all function calls will be forwarded to the delegation object. 
.PP
\fBParameters:\fP
.RS 4
\fIdelegate\fP the delegation object, or 0 to remove it 
.RE
.PP
Definition at line 49 of file kcompletionbase.cpp.
.PP
References m_bAutoDelCompObj, m_bEmitSignals, m_bHandleSignals, m_iCompletionMode, and m_keyMap.
.SS "\fBKCompletionBase\fP* KCompletionBase::delegate () const\fC [inline, protected]\fP"
.PP
Returns the delegation object. \fBReturns:\fP
.RS 4
the delegation object, or 0 if there is none 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBsetDelegate()\fP 
.RE
.PP
Definition at line 984 of file kcompletion.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
