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

OCompletionBox Class Reference

A helper widget for "completion-widgets" (OLineEdit, OComboBox)) Adapted for the Opie project by Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>. More...

#include </home/clem/local/src/opie/libopie2/qt3/opieui/ocompletionbox.h>

Collaboration diagram for OCompletionBox:

Collaboration graph
[legend]
List of all members.

Public Slots

QStringList items () const
void insertItems (const QStringList &items, int index=-1)
void setItems (const QStringList &items)
virtual void popup ()
void setTabHandling (bool enable)
bool isTabHandling () const
void setCancelledText (const QString &)
QString cancelledText () const
void down ()
void up ()
void pageDown ()
void pageUp ()
void home ()
void end ()
virtual void show ()
virtual void hide ()

Signals

void activated (const QString &)
void userCancelled (const QString &)

Public Member Functions

 OCompletionBox (QWidget *parent, const char *name=0)
 ~OCompletionBox ()
virtual QSize sizeHint () const

Protected Slots

virtual void slotActivated (QListBoxItem *)

Protected Member Functions

virtual bool eventFilter (QObject *, QEvent *)

Properties

bool isTabHandling
QString cancelledText

Private Slots

void slotSetCurrentItem (QListBoxItem *i)
void slotCurrentChanged ()
void cancelled ()
void slotItemClicked (QListBoxItem *)

Private Attributes

OCompletionBoxPrivated

Classes

class  OCompletionBoxPrivate

Detailed Description

A helper widget for "completion-widgets" (OLineEdit, OComboBox)) Adapted for the Opie project by Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>.

A little utility class for "completion-widgets", like OLineEdit or OComboBox. OCompletionBox 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 OGlobalSettings::Completion == CompletionPopup or CompletionPopupAuto.

Author:
Carsten Pfeiffer <pfeiffer@kde.org>

Definition at line 57 of file ocompletionbox.h.


Constructor & Destructor Documentation

OCompletionBox::OCompletionBox QWidget *  parent,
const char *  name = 0
 

Constructs a OCompletionBox.

Notice: the parent needs to be always 0L, so you can't specify it in the constructor. Because of that, Qt's auto-deletion does not take place, so you have to explicitly delete this widget when you don't need it anymore.

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

Definition at line 50 of file ocompletionbox.cpp.

References d, OCompletionBox::OCompletionBoxPrivate::down_workaround, OCompletionBox::OCompletionBoxPrivate::m_parent, slotActivated(), slotCurrentChanged(), slotItemClicked(), and OCompletionBox::OCompletionBoxPrivate::tabHandling.

OCompletionBox::~OCompletionBox  ) 
 

Destroys the box

Definition at line 80 of file ocompletionbox.cpp.

References d, and OCompletionBox::OCompletionBoxPrivate::m_parent.


Member Function Documentation

void OCompletionBox::activated const QString  )  [signal]
 

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

Referenced by slotActivated(), and slotItemClicked().

void OCompletionBox::cancelled  )  [private, slot]
 

Definition at line 336 of file ocompletionbox.cpp.

References OCompletionBox::OCompletionBoxPrivate::cancelText, d, hide(), QString::isNull(), and userCancelled().

Referenced by eventFilter().

QString OCompletionBox::cancelledText  )  const [slot]
 

Returns:
the text set via setCancelledText() or QString::null.

void OCompletionBox::down  )  [slot]
 

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

Definition at line 271 of file ocompletionbox.cpp.

References d, OCompletionBox::OCompletionBoxPrivate::down_workaround, and i.

Referenced by eventFilter().

void OCompletionBox::end  )  [slot]
 

Moves the selection down to the last item.

Definition at line 311 of file ocompletionbox.cpp.

bool OCompletionBox::eventFilter QObject *  ,
QEvent * 
[protected, virtual]
 

Reimplemented from OListBox to get events from the viewport (to hide this widget on mouse-click, Escape-presses, etc.

Definition at line 104 of file ocompletionbox.cpp.

References cancelled(), d, down(), hide(), KeyPress, OCompletionBox::OCompletionBoxPrivate::m_parent, pageDown(), pageUp(), sizeHint(), OCompletionBox::OCompletionBoxPrivate::tabHandling, type, and up().

void OCompletionBox::hide  )  [virtual, slot]
 

Re-implemented for internal reasons. API is unaffected.

Definition at line 252 of file ocompletionbox.cpp.

References OCompletionBox::OCompletionBoxPrivate::cancelText, d, OCompletionBox::OCompletionBoxPrivate::m_parent, QString::null, and qApp.

Referenced by cancelled(), OLineEdit::completionMenuActivated(), OLineEdit::eventFilter(), eventFilter(), OLineEdit::keyPressEvent(), OLineEdit::makeCompletion(), popup(), OLineEdit::setCompletedItems(), OLineEdit::setCompletionMode(), slotActivated(), and slotItemClicked().

void OCompletionBox::home  )  [slot]
 

Moves the selection up to the first item.

Definition at line 306 of file ocompletionbox.cpp.

void OCompletionBox::insertItems const QStringList items,
int  index = -1
[slot]
 

Inserts items into the box. Does not clear the items before. index determines at which position items will be inserted. (defaults to appending them at the end)

Definition at line 351 of file ocompletionbox.cpp.

References d, and OCompletionBox::OCompletionBoxPrivate::down_workaround.

bool OCompletionBox::isTabHandling  )  const [slot]
 

Returns:
true if this widget is handling Tab-key events to traverse the items in the dropdown list, otherwise false.
Default is false.

See also:
setTabHandling

QStringList OCompletionBox::items  )  const [slot]
 

Returns a list of all items currently in the box.

Definition at line 86 of file ocompletionbox.cpp.

References QValueList< T >::append(), i, list, and text.

void OCompletionBox::pageDown  )  [slot]
 

Moves the selection one page down.

Definition at line 292 of file ocompletionbox.cpp.

References i.

Referenced by eventFilter().

void OCompletionBox::pageUp  )  [slot]
 

Moves the selection one page up.

Definition at line 299 of file ocompletionbox.cpp.

References i.

Referenced by eventFilter().

void OCompletionBox::popup  )  [virtual, slot]
 

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 hide() the box when appropriate.

Definition at line 205 of file ocompletionbox.cpp.

References height, hide(), show(), size, and sizeHint().

Referenced by OpieUIDemo::demoOCompletionBox(), and OLineEdit::setCompletedItems().

void OCompletionBox::setCancelledText const QString  )  [slot]
 

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

If the cancelled text is not set through this function, the userCancelled signal will not be emitted.

See also:
userCancelled( const QString& )
Parameters:
txt the text to be emitted if the user cancels this box

Definition at line 326 of file ocompletionbox.cpp.

References OCompletionBox::OCompletionBoxPrivate::cancelText, and d.

Referenced by OLineEdit::setCompletedItems().

void OCompletionBox::setItems const QStringList items  )  [slot]
 

Clears the box and inserts items.

Definition at line 360 of file ocompletionbox.cpp.

References QValueList< T >::begin(), d, OCompletionBox::OCompletionBoxPrivate::down_workaround, and QValueList< T >::end().

Referenced by OLineEdit::setCompletedItems().

void OCompletionBox::setTabHandling bool  enable  )  [slot]
 

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.

See also:
isTabHandling

Definition at line 316 of file ocompletionbox.cpp.

References d, and OCompletionBox::OCompletionBoxPrivate::tabHandling.

void OCompletionBox::show  )  [virtual, slot]
 

Re-implemented for internal reasons. API is unaffected.

Definition at line 223 of file ocompletionbox.cpp.

References d, height, OCompletionBox::OCompletionBoxPrivate::m_parent, qApp, sizeHint(), width, Opie::MM::x, and Opie::MM::y.

Referenced by popup().

QSize OCompletionBox::sizeHint  )  const [virtual]
 

Definition at line 260 of file ocompletionbox.cpp.

References d, height, OCompletionBox::OCompletionBoxPrivate::m_parent, and width.

Referenced by eventFilter(), popup(), and show().

void OCompletionBox::slotActivated QListBoxItem *   )  [protected, virtual, slot]
 

Called when an item was activated. Emits activated() with the item.

Definition at line 95 of file ocompletionbox.cpp.

References activated(), and hide().

Referenced by OCompletionBox().

void OCompletionBox::slotCurrentChanged  )  [private, slot]
 

Definition at line 391 of file ocompletionbox.cpp.

References d, and OCompletionBox::OCompletionBoxPrivate::down_workaround.

Referenced by OCompletionBox().

void OCompletionBox::slotItemClicked QListBoxItem *   )  [private, slot]
 

Definition at line 396 of file ocompletionbox.cpp.

References activated(), d, OCompletionBox::OCompletionBoxPrivate::down_workaround, and hide().

Referenced by OCompletionBox().

void OCompletionBox::slotSetCurrentItem QListBoxItem *  i  )  [inline, private, slot]
 

Definition at line 221 of file ocompletionbox.h.

void OCompletionBox::up  )  [slot]
 

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

Definition at line 286 of file ocompletionbox.cpp.

Referenced by eventFilter().

void OCompletionBox::userCancelled const QString  )  [signal]
 

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

Referenced by cancelled().


Member Data Documentation

OCompletionBoxPrivate* OCompletionBox::d [private]
 

Definition at line 227 of file ocompletionbox.h.

Referenced by cancelled(), down(), eventFilter(), hide(), insertItems(), OCompletionBox(), setCancelledText(), setItems(), setTabHandling(), show(), sizeHint(), slotCurrentChanged(), slotItemClicked(), and ~OCompletionBox().


Property Documentation

QString OCompletionBox::cancelledText [read, write]
 

Definition at line 61 of file ocompletionbox.h.

bool OCompletionBox::isTabHandling [read, write]
 

Definition at line 59 of file ocompletionbox.h.


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