Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OCompletionBase Class Reference

An abstract class for adding text completion support to widgets. More...

#include </home/clem/local/src/opie/libopie2/qt3/opiecore/ocompletionbase.h>

Inheritance diagram for OCompletionBase:

Inheritance graph
[legend]
Collaboration diagram for OCompletionBase:

Collaboration graph
[legend]
List of all members.

Public Types

typedef QMap< KeyBindingType,
OShortcut
KeyBindingMap
enum  KeyBindingType { TextCompletion, PrevCompletionMatch, NextCompletionMatch, SubstringCompletion }

Public Member Functions

 OCompletionBase ()
virtual ~OCompletionBase ()
OCompletioncompletionObject (bool hsig=true)
virtual void setCompletionObject (OCompletion *, bool hsig=true)
virtual void setHandleSignals (bool)
bool isCompletionObjectAutoDeleted () const
void setAutoDeleteCompletionObject (bool autoDelete)
void setEnableSignals (bool enable)
bool handleSignals () const
bool emitSignals () const
virtual void setCompletionMode (OGlobalSettings::Completion mode)
OGlobalSettings::Completion completionMode () const
bool setKeyBinding (KeyBindingType, const OShortcut &cut)
const OShortcutgetKeyBinding (KeyBindingType item) const
void useGlobalKeyBindings ()
virtual void setCompletedText (const QString &text)=0
virtual void setCompletedItems (const QStringList &items)=0
OCompletioncompObj () const

Protected Member Functions

KeyBindingMap getKeyBindings () const
void setDelegate (OCompletionBase *delegate)
OCompletionBasedelegate () const

Private Member Functions

void setup (bool, bool, bool)

Private Attributes

bool m_bAutoDelCompObj
bool m_bHandleSignals
bool m_bEmitSignals
OGlobalSettings::Completion m_iCompletionMode
QGuardedPtr< OCompletionm_pCompObj
KeyBindingMap m_keyMap
OCompletionBasem_delegate
OCompletionBasePrivate * d

Detailed Description

An abstract class for adding text completion support to widgets.

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 OLineEdit or OComboBox to see how easily such support can be added using this as a base class.

Author:
Dawit Alemayehu <adawit@kde.org>

Definition at line 51 of file ocompletionbase.h.


Member Typedef Documentation

typedef QMap<KeyBindingType, OShortcut> OCompletionBase::KeyBindingMap
 

Definition at line 82 of file ocompletionbase.h.


Member Enumeration Documentation

enum OCompletionBase::KeyBindingType
 

Constants that represent the items whose short-cut key-binding is programmable. The default key-bindings for these items are defined in OStdAccel.

Enumeration values:
TextCompletion  Text completion (by default Ctrl-E).
PrevCompletionMatch  Switch to previous completion (by default Ctrl-Up).
NextCompletionMatch  Switch to next completion (by default Ctrl-Down).
SubstringCompletion  Substring completion (by default Ctrl-T).

Definition at line 61 of file ocompletionbase.h.


Constructor & Destructor Documentation

OCompletionBase::OCompletionBase  ) 
 

Default constructor.

Definition at line 36 of file ocompletionbase.cpp.

References m_delegate, m_iCompletionMode, setup(), and useGlobalKeyBindings().

OCompletionBase::~OCompletionBase  )  [virtual]
 

Destructor.

Definition at line 52 of file ocompletionbase.cpp.

References m_bAutoDelCompObj, and m_pCompObj.


Member Function Documentation

OGlobalSettings::Completion OCompletionBase::completionMode  )  const [inline]
 

Returns the current completion mode.

The return values are of type OGlobalSettings::Completion. See setCompletionMode() for details.

Returns:
the completion mode.

Definition at line 255 of file ocompletionbase.h.

References completionMode(), m_delegate, and m_iCompletionMode.

Referenced by OComboBox::autoCompletion(), OLineEdit::completionMenuActivated(), completionMode(), OLineEdit::createPopupMenu(), OLineEdit::keyPressEvent(), OLineEdit::makeCompletion(), OLineEdit::setCompletedText(), and OLineEdit::setCompletionMode().

OCompletion * OCompletionBase::completionObject bool  hsig = true  ) 
 

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 setAutoDeleteCompletionObject and setHandleSignals 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 setHandleSignals or setCompletionObject for such cases depending on your requirement.

Parameters:
hsig if true, handles signals internally.
Returns:
a pointer the completion object.

Definition at line 73 of file ocompletionbase.cpp.

References completionObject(), m_bAutoDelCompObj, m_delegate, m_pCompObj, and setCompletionObject().

Referenced by OHistoryCombo::addToHistory(), OHistoryCombo::clearHistory(), completionObject(), OpieUIDemo::demoOComboBox(), OpieUIDemo::demoOLineEdit(), OHistoryCombo::init(), OHistoryCombo::removeFromHistory(), and OHistoryCombo::setHistoryItems().

OCompletion* OCompletionBase::compObj  )  const [inline]
 

Returns a pointer to the completion object.

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

Returns:
the completion object or NULL if one does not exist.

Definition at line 356 of file ocompletionbase.h.

References compObj(), m_delegate, and m_pCompObj.

Referenced by compObj(), OLineEdit::createPopupMenu(), OLineEdit::makeCompletion(), OLineEdit::rotateText(), OLineEdit::setCompletionObject(), and OHistoryCombo::useCompletion().

OCompletionBase* OCompletionBase::delegate  )  const [inline, protected]
 

Definition at line 370 of file ocompletionbase.h.

References m_delegate.

bool OCompletionBase::emitSignals  )  const [inline]
 

Returns true if the object emits the signals

Returns:
true if signals are emitted

Definition at line 223 of file ocompletionbase.h.

References emitSignals(), m_bEmitSignals, and m_delegate.

Referenced by emitSignals(), and OLineEdit::keyPressEvent().

const OShortcut& OCompletionBase::getKeyBinding KeyBindingType  item  )  const [inline]
 

Returns the key-binding used for the specified item.

This methods returns the key-binding used to activate the feature feature given by item. If the binding contains modifier key(s), the SUM of the modifier key and the actual key code are returned.

Returns:
the key-binding used for the feature given by item.
See also:
setKeyBinding

Definition at line 305 of file ocompletionbase.h.

References getKeyBinding(), m_delegate, and m_keyMap.

Referenced by getKeyBinding().

KeyBindingMap OCompletionBase::getKeyBindings  )  const [inline, protected]
 

Returns a key-binding map

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

Returns:
the key-binding used for the feature given by item.

Definition at line 367 of file ocompletionbase.h.

References getKeyBindings(), m_delegate, and m_keyMap.

Referenced by getKeyBindings(), and OLineEdit::keyPressEvent().

bool OCompletionBase::handleSignals  )  const [inline]
 

Returns true if the object handles the signals

Returns:
true if this signals are handled internally.

Definition at line 216 of file ocompletionbase.h.

References handleSignals(), m_bHandleSignals, and m_delegate.

Referenced by handleSignals(), OLineEdit::keyPressEvent(), OLineEdit::makeCompletionBox(), and OLineEdit::setCompletionObject().

bool OCompletionBase::isCompletionObjectAutoDeleted  )  const [inline]
 

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

See setCompletionObject() and enableCompletion() for details.

Returns:
true if the completion object

Definition at line 164 of file ocompletionbase.h.

References isCompletionObjectAutoDeleted(), m_bAutoDelCompObj, and m_delegate.

Referenced by isCompletionObjectAutoDeleted().

void OCompletionBase::setAutoDeleteCompletionObject bool  autoDelete  )  [inline]
 

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.

Parameters:
autoDelete if true, delete completion object on destruction.

Definition at line 177 of file ocompletionbase.h.

References m_bAutoDelCompObj, m_delegate, and setAutoDeleteCompletionObject().

Referenced by setAutoDeleteCompletionObject().

virtual void OCompletionBase::setCompletedItems const QStringList items  )  [pure virtual]
 

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

Implemented in OComboBox, and OLineEdit.

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

Parameters:
text the completed text to be set in the widget.

Implemented in OComboBox, and OLineEdit.

void OCompletionBase::setCompletionMode OGlobalSettings::Completion  mode  )  [virtual]
 

Sets the type of completion to be used.

The completion modes supported are those defined in OGlobalSettings(). See below.

Parameters:
mode Completion type:
  • CompletionNone: Disables completion feature.
  • CompletionAuto: Attempts to find a match & fills-in the remaining text.
  • CompletionMan: Acts the same as the above except the action has to be manually triggered through pre-defined completion key.
  • CompletionShell: Mimics the completion feature found in typical *nix shell environments.
  • CompletionPopup: Shows all available completions at once, in a listbox popping up.

Reimplemented in OLineEdit.

Definition at line 112 of file ocompletionbase.cpp.

References m_delegate, m_iCompletionMode, m_pCompObj, and setCompletionMode().

Referenced by OpieUIDemo::demoOComboBox(), OComboBox::setAutoCompletion(), OLineEdit::setCompletionMode(), and setCompletionMode().

void OCompletionBase::setCompletionObject OCompletion ,
bool  hsig = true
[virtual]
 

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.

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. Also if you do not want the signals to be handled by an internal implementation, be sure to set the bool argument to false.

This method is also called when a completion-object is created automatically, when completionObject() is called the first time.

Parameters:
compObj a OCompletion() or a derived child object.
hsig if true, handles signals internally.

Reimplemented in OLineEdit.

Definition at line 86 of file ocompletionbase.cpp.

References m_bAutoDelCompObj, m_delegate, m_pCompObj, setCompletionObject(), and setup().

Referenced by completionObject(), OLineEdit::setCompletionObject(), and setCompletionObject().

void OCompletionBase::setDelegate OCompletionBase delegate  )  [protected]
 

Definition at line 60 of file ocompletionbase.cpp.

References m_bAutoDelCompObj, m_bEmitSignals, m_bHandleSignals, m_delegate, m_iCompletionMode, and m_keyMap.

Referenced by OComboBox::setLineEdit().

void OCompletionBase::setEnableSignals bool  enable  )  [inline]
 

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

Invoking this function with enable set to false will cause the completion & rotation signals not to be emitted. However, unlike setting the completion object to NULL using setCompletionObject, disabling the emition 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.

Parameters:
enable if false, disables the emition of completion & rotation signals.

Definition at line 204 of file ocompletionbase.h.

References m_bEmitSignals, m_delegate, and setEnableSignals().

Referenced by setEnableSignals().

void OCompletionBase::setHandleSignals bool   )  [virtual]
 

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.

Parameters:
handle if true, handle completion & rotation internally.

Definition at line 104 of file ocompletionbase.cpp.

References m_bHandleSignals, m_delegate, and setHandleSignals().

Referenced by setHandleSignals().

bool OCompletionBase::setKeyBinding KeyBindingType  ,
const OShortcut cut
 

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 key is negative or the supplied key-binding conflicts with the ones set for one of the other features.

NOTE: To use a modifier key (Shift, Ctrl, Alt) as part of the key-binding simply simply sum 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 "Qt::CtrlButton + Qt::Key_E" as the second argument to this function.

Parameters:
item the 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
Parameters:
key key-binding used to rotate down in a list.
Returns:
true if key-binding can successfully be set.
See also:
getKeyBinding

Definition at line 126 of file ocompletionbase.cpp.

References QMap< Key, T >::begin(), QMap< Key, T >::end(), OShortcut::isNull(), m_delegate, m_keyMap, QMap< Key, T >::replace(), and setKeyBinding().

Referenced by setKeyBinding().

void OCompletionBase::setup bool  ,
bool  ,
bool 
[private]
 

Definition at line 161 of file ocompletionbase.cpp.

References m_bAutoDelCompObj, m_bEmitSignals, m_bHandleSignals, m_delegate, and setup().

Referenced by OCompletionBase(), setCompletionObject(), and setup().

void OCompletionBase::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 OGlobalSettings.

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 141 of file ocompletionbase.cpp.

Referenced by OCompletionBase().


Member Data Documentation

OCompletionBasePrivate* OCompletionBase::d [private]
 

Reimplemented in OComboBox, OHistoryCombo, and OLineEdit.

Definition at line 399 of file ocompletionbase.h.

bool OCompletionBase::m_bAutoDelCompObj [private]
 

Definition at line 380 of file ocompletionbase.h.

Referenced by completionObject(), isCompletionObjectAutoDeleted(), setAutoDeleteCompletionObject(), setCompletionObject(), setDelegate(), setup(), and ~OCompletionBase().

bool OCompletionBase::m_bEmitSignals [private]
 

Definition at line 385 of file ocompletionbase.h.

Referenced by emitSignals(), setDelegate(), setEnableSignals(), and setup().

bool OCompletionBase::m_bHandleSignals [private]
 

Definition at line 383 of file ocompletionbase.h.

Referenced by handleSignals(), setDelegate(), setHandleSignals(), and setup().

OCompletionBase* OCompletionBase::m_delegate [private]
 

Definition at line 393 of file ocompletionbase.h.

Referenced by completionMode(), completionObject(), compObj(), delegate(), emitSignals(), getKeyBinding(), getKeyBindings(), handleSignals(), isCompletionObjectAutoDeleted(), OCompletionBase(), setAutoDeleteCompletionObject(), setCompletionMode(), setCompletionObject(), setDelegate(), setEnableSignals(), setHandleSignals(), setKeyBinding(), and setup().

OGlobalSettings::Completion OCompletionBase::m_iCompletionMode [private]
 

Definition at line 387 of file ocompletionbase.h.

Referenced by completionMode(), OCompletionBase(), setCompletionMode(), and setDelegate().

KeyBindingMap OCompletionBase::m_keyMap [private]
 

Definition at line 391 of file ocompletionbase.h.

Referenced by getKeyBinding(), getKeyBindings(), setDelegate(), and setKeyBinding().

QGuardedPtr<OCompletion> OCompletionBase::m_pCompObj [private]
 

Definition at line 389 of file ocompletionbase.h.

Referenced by completionObject(), compObj(), setCompletionMode(), setCompletionObject(), and ~OCompletionBase().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:41:54 2005 for OPIE by  doxygen 1.4.2