Search for usage in LXR

#include <KCompletionBase>

Inheritance diagram for KCompletionBase:

Public Types

typedef QMap< KeyBindingType, QList< QKeySequence > > KeyBindingMap
enum  KeyBindingType { TextCompletion , PrevCompletionMatch , NextCompletionMatch , SubstringCompletion }

Public Member Functions

 KCompletionBase ()
virtual ~KCompletionBase ()
KCompletion::CompletionMode completionMode () const
KCompletioncompletionObject (bool handleSignals=true)
KCompletioncompObj () const
bool emitSignals () const
bool handleSignals () const
bool isCompletionObjectAutoDeleted () const
QList< QKeySequencekeyBinding (KeyBindingType item) const
void setAutoDeleteCompletionObject (bool autoDelete)
virtual void setCompletedItems (const QStringList &items, bool autoSuggest=true)=0
virtual void setCompletedText (const QString &text)=0
virtual void setCompletionMode (KCompletion::CompletionMode mode)
virtual void setCompletionObject (KCompletion *completionObject, bool handleSignals=true)
void setEmitSignals (bool emitRotationSignals)
void setEnableSignals (bool enable)
virtual void setHandleSignals (bool handle)
bool setKeyBinding (KeyBindingType item, const QList< QKeySequence > &key)
void useGlobalKeyBindings ()

Protected Member Functions

KCompletionBasedelegate () const
KeyBindingMap keyBindingMap () const
void setDelegate (KCompletionBase *delegate)
void setKeyBindingMap (KeyBindingMap keyBindingMap)
virtual void virtual_hook (int id, void *data)

Detailed Description

An abstract base class for adding a completion feature into 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 setCompletedText(). Refer to KLineEdit or KComboBox to see how easily such support can be added using this as a base class.

An abstract class for adding text completion support to widgets.

Dawit Alemayehu adawi.nosp@m.t@kd.nosp@m.e.org

Definition at line 36 of file kcompletionbase.h.

Member Typedef Documentation

◆ KeyBindingMap

Member Enumeration Documentation

◆ KeyBindingType

Constants that represent the items whose shortcut key binding is programmable.

The default key bindings for these items are defined in KStandardShortcut.


Text completion (by default Ctrl-E).


Switch to previous completion (by default Ctrl-Up).


Switch to next completion (by default Ctrl-Down).


Substring completion (by default Ctrl-T).

Definition at line 45 of file kcompletionbase.h.

Constructor & Destructor Documentation

◆ KCompletionBase()

KCompletionBase::KCompletionBase ( )

Default constructor.

Definition at line 59 of file kcompletionbase.cpp.

◆ ~KCompletionBase()

KCompletionBase::~KCompletionBase ( )


Definition at line 66 of file kcompletionbase.cpp.

Member Function Documentation

◆ completionMode()

KCompletion::CompletionMode KCompletionBase::completionMode ( ) const

Returns the current completion mode.

the completion mode.

Definition at line 201 of file kcompletionbase.cpp.

◆ completionObject()

KCompletion * KCompletionBase::completionObject ( bool handleSignals = true)

Returns a pointer to the current completion object.

If the completion object does not exist, it is automatically created and by default handles all the completion signals internally unless handleSignals is set to false. It is also automatically destroyed when the destructor is called. You can change this default behavior using the setAutoDeleteCompletionObject and setHandleSignals member functions.

See also compObj.

handleSignalsif true, handles completion signals internally.
a pointer to the completion object.

Definition at line 90 of file kcompletionbase.cpp.

◆ compObj()

KCompletion * KCompletionBase::compObj ( ) const

Returns a pointer to the completion object.

This method is only different from completionObject() in that it does not create a new KCompletion object even if the internal pointer is NULL. Use this method to get the pointer to a completion object when inheriting so that you will not inadvertently create it.

the completion object or NULL if one does not exist.

Definition at line 246 of file kcompletionbase.cpp.

◆ delegate()

KCompletionBase * KCompletionBase::delegate ( ) const

Returns the delegation object.

the delegation object, or nullptr if there is none
See also

Definition at line 84 of file kcompletionbase.cpp.

◆ emitSignals()

bool KCompletionBase::emitSignals ( ) const

Returns true if the object emits the signals.

true if signals are emitted

Definition at line 169 of file kcompletionbase.cpp.

◆ handleSignals()

bool KCompletionBase::handleSignals ( ) const

Returns true if the object handles the signals.

true if this signals are handled internally.

Definition at line 163 of file kcompletionbase.cpp.

◆ isCompletionObjectAutoDeleted()

bool KCompletionBase::isCompletionObjectAutoDeleted ( ) const

Returns true if the completion object is deleted upon this widget's destruction.

See setCompletionObject() and enableCompletion() for details.

true if the completion object will be deleted automatically

Definition at line 137 of file kcompletionbase.cpp.

◆ keyBinding()

QList< QKeySequence > KCompletionBase::keyBinding ( KeyBindingType item) const

Returns the key binding used for the specified item.

This method returns the key binding used to activate the feature given by item. If the binding contains modifier key(s), the sum of the modifier key and the actual key code is returned.

itemthe item to check
the key binding used for the feature given by item.
See also

Definition at line 225 of file kcompletionbase.cpp.

◆ keyBindingMap()

KCompletionBase::KeyBindingMap KCompletionBase::keyBindingMap ( ) const

Returns a key binding map.

This method is the same as getKeyBinding(), except that it returns the whole keymap containing the key bindings.

the key binding used for the feature given by item.

Definition at line 252 of file kcompletionbase.cpp.

◆ setAutoDeleteCompletionObject()

void KCompletionBase::setAutoDeleteCompletionObject ( bool autoDelete)

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.

autoDeleteif true, delete completion object on destruction.

Definition at line 143 of file kcompletionbase.cpp.

◆ setCompletedItems()

virtual void KCompletionBase::setCompletedItems ( const QStringList & items,
bool autoSuggest = true )
pure virtual

A pure virtual function that must be implemented by all inheriting classes.

itemsthe list of completed items
autoSuggestif true, the first element of items is automatically completed (i.e. preselected).

◆ setCompletedText()

virtual void KCompletionBase::setCompletedText ( const QString & text)
pure virtual

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 KCompletionBase::setCompletedText. Does nothing in CompletionPopup mode, as all available matches will be shown in the popup.

textthe completed text to be set in the widget.

◆ setCompletionMode()

void KCompletionBase::setCompletionMode ( KCompletion::CompletionMode mode)

Sets the type of completion to be used.

modeCompletion type
See also

Reimplemented in KLineEdit.

Definition at line 185 of file kcompletionbase.cpp.

◆ setCompletionObject()

void KCompletionBase::setCompletionObject ( KCompletion * completionObject,
bool handleSignals = true )

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 your widgets or need to use a customized completion object.

The object assigned through this method is not deleted when this object's destructor is invoked unless you explicitly call setAutoDeleteCompletionObject after calling this method. Be sure to set the bool argument to false, if you want to handle the completion signals yourself.

completionObjecta KCompletion or a derived child object.
handleCompletionSignalsif true, handles completion signals internally.

Reimplemented in KLineEdit, and KUrlComboBox.

Definition at line 104 of file kcompletionbase.cpp.

◆ setDelegate()

void KCompletionBase::setDelegate ( KCompletionBase * delegate)

Sets or removes the delegation object.

If a delegation object is set, all function calls will be forwarded to the delegation object.

delegatethe delegation object, or nullptr to remove it

Definition at line 70 of file kcompletionbase.cpp.

◆ setEmitSignals()

void KCompletionBase::setEmitSignals ( bool emitRotationSignals)

Sets whether the object emits rotation signals.

emitRotationSignalsif false, disables the emission of rotation signals.

Definition at line 175 of file kcompletionbase.cpp.

◆ setEnableSignals()

void KCompletionBase::setEnableSignals ( bool enable)

Sets the widget's ability to emit text completion and rotation signals.

Invoking this function with enable set to false will cause the completion and rotation signals not to be emitted. However, unlike setting the completion object to nullptr using setCompletionObject, disabling the emission of the signals through this method does not affect the current completion object.

There is no need to invoke this function by default. When a completion object is created through completionObject or setCompletionObject, 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 setHandleSignals.

enableif false, disables the emission of completion and rotation signals.

Definition at line 153 of file kcompletionbase.cpp.

◆ setHandleSignals()

void KCompletionBase::setHandleSignals ( bool handle)

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.

handleif true, it handles completion and rotation internally.

Definition at line 127 of file kcompletionbase.cpp.

◆ setKeyBinding()

bool KCompletionBase::setKeyBinding ( KeyBindingType item,
const QList< QKeySequence > & key )

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 when key is negative or the supplied key binding conflicts with another one set for another feature.

NOTE: To use a modifier key (Shift, Ctrl, Alt) as part of the key binding simply sum up the values of the modifier and the actual key. For example, to use CTRL+E, supply "Qt::CtrlButton | Qt::Key_E" as the second argument to this function.

itemthe feature whose key binding needs to be set:
  • TextCompletion the manual completion key binding.
  • PrevCompletionMatch the previous match key for multiple completion.
  • NextCompletionMatch the next match key for for multiple completion.
  • SubstringCompletion the key for substring completion
keykey binding used to rotate down in a list.
true if key binding is successfully set.
See also

Definition at line 207 of file kcompletionbase.cpp.

◆ setKeyBindingMap()

void KCompletionBase::setKeyBindingMap ( KCompletionBase::KeyBindingMap keyBindingMap)

Sets the keymap.


Definition at line 258 of file kcompletionbase.cpp.

◆ useGlobalKeyBindings()

void KCompletionBase::useGlobalKeyBindings ( )

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 KGlobalSettings.

NOTE: By default, inheriting widgets should use the global key bindings so that there is no need to call this method.

Definition at line 231 of file kcompletionbase.cpp.

◆ virtual_hook()

void KCompletionBase::virtual_hook ( int id,
void * data )

Virtual hook, used to add new "virtual" functions while maintaining binary compatibility.

Unused in this class.

Definition at line 269 of file kcompletionbase.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:42:46 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.