• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Properties | List of all members
KCompletionBox Class Reference

#include <kcompletionbox.h>

Inheritance diagram for KCompletionBox:
Inheritance graph
[legend]

Public Slots

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

Signals

void activated (const QString &)
 
void userCancelled (const QString &)
 
- Signals inherited from KListWidget
void doubleClicked (QListWidgetItem *item, const QPoint &pos)
 
void executed (QListWidgetItem *item)
 
void executed (QListWidgetItem *item, const QPoint &pos)
 

Public Member Functions

 KCompletionBox (QWidget *parent=0)
 
 ~KCompletionBox ()
 
bool activateOnSelect () const
 
virtual QSize sizeHint () const
 
- Public Member Functions inherited from KListWidget
 KListWidget (QWidget *parent=0)
 
 ~KListWidget ()
 

Protected Slots

virtual void slotActivated (QListWidgetItem *)
 

Protected Member Functions

QRect calculateGeometry () const
 
virtual bool eventFilter (QObject *, QEvent *)
 
virtual QPoint globalPositionHint () const
 
void sizeAndPosition ()
 
- Protected Member Functions inherited from KListWidget
virtual void focusOutEvent (QFocusEvent *e)
 
virtual void keyPressEvent (QKeyEvent *e)
 
virtual void leaveEvent (QEvent *e)
 
virtual void mouseDoubleClickEvent (QMouseEvent *e)
 
virtual void mousePressEvent (QMouseEvent *e)
 
virtual void mouseReleaseEvent (QMouseEvent *e)
 

Properties

bool activateOnSelect
 
QString cancelledText
 
bool isTabHandling
 

Detailed Description

A helper widget for "completion-widgets" (KLineEdit, KComboBox))

A little utility class for "completion-widgets", like KLineEdit or KComboBox. KCompletionBox 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 KGlobalSettings::Completion == CompletionPopup or CompletionPopupAuto.

Author
Carsten Pfeiffer pfeif.nosp@m.fer@.nosp@m.kde.o.nosp@m.rg

Definition at line 43 of file kcompletionbox.h.

Constructor & Destructor Documentation

KCompletionBox::KCompletionBox ( QWidget *  parent = 0)
explicit

Constructs a KCompletionBox.

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

Definition at line 48 of file kcompletionbox.cpp.

KCompletionBox::~KCompletionBox ( )

Destroys the box.

Definition at line 71 of file kcompletionbox.cpp.

Member Function Documentation

void KCompletionBox::activated ( const QString &  )
signal

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

bool KCompletionBox::activateOnSelect ( ) const
Returns
true if selecting an item results in the emition of the selected() signal.
QRect KCompletionBox::calculateGeometry ( ) const
protected

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/QComboBox when used with one.

Definition at line 348 of file kcompletionbox.cpp.

QString KCompletionBox::cancelledText ( ) const
slot
Returns
the text set via setCancelledText() or QString().
void KCompletionBox::down ( )
slot

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

Definition at line 404 of file kcompletionbox.cpp.

void KCompletionBox::end ( )
slot

Moves the selection down to the last item.

Definition at line 454 of file kcompletionbox.cpp.

bool KCompletionBox::eventFilter ( QObject *  o,
QEvent *  e 
)
protectedvirtual

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

Definition at line 100 of file kcompletionbox.cpp.

QPoint KCompletionBox::globalPositionHint ( ) const
protectedvirtual

The preferred global coordinate at which the completion box's top left corner should be positioned.

Definition at line 310 of file kcompletionbox.cpp.

void KCompletionBox::home ( )
slot

Moves the selection up to the first item.

Definition at line 449 of file kcompletionbox.cpp.

void KCompletionBox::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 501 of file kcompletionbox.cpp.

bool KCompletionBox::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 true.

See also
setTabHandling
QStringList KCompletionBox::items ( ) const
slot

Returns a list of all items currently in the box.

Definition at line 77 of file kcompletionbox.cpp.

void KCompletionBox::pageDown ( )
slot

Moves the selection one page down.

Definition at line 432 of file kcompletionbox.cpp.

void KCompletionBox::pageUp ( )
slot

Moves the selection one page up.

Definition at line 440 of file kcompletionbox.cpp.

void KCompletionBox::popup ( )
virtualslot

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 261 of file kcompletionbox.cpp.

void KCompletionBox::setActivateOnSelect ( bool  state)
slot

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

By default the selected() signal is emitted.

Parameters
statefalse if the signal should not be emitted.

Definition at line 573 of file kcompletionbox.cpp.

void KCompletionBox::setCancelledText ( const QString &  txt)
slot

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 userCancelled signal will not be emitted.

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

Definition at line 469 of file kcompletionbox.cpp.

void KCompletionBox::setItems ( const QStringList &  items)
slot

Clears the box and inserts items.

Definition at line 510 of file kcompletionbox.cpp.

void KCompletionBox::setTabHandling ( bool  enable)
slot

Makes this widget (when visible) capture Tab-key events to traverse the items in the dropdown list (Tab goes down, Shift+Tab goes up).

On by default, but should be turned off when used in combination with KUrlCompletion. When off, KLineEdit handles Tab itself, making it select the current item from the completion box, which is particularly useful when using KUrlCompletion.

See also
isTabHandling

Definition at line 459 of file kcompletionbox.cpp.

void KCompletionBox::setVisible ( bool  visible)
virtualslot

Re-implemented for internal reasons.

API is unaffected. Call it only if you really need it (i.e. the widget was hidden before) to have better performance.

Definition at line 317 of file kcompletionbox.cpp.

void KCompletionBox::sizeAndPosition ( )
protected

This properly sizes and positions the listbox.

Definition at line 278 of file kcompletionbox.cpp.

QSize KCompletionBox::sizeHint ( void  ) const
virtual

Definition at line 399 of file kcompletionbox.cpp.

void KCompletionBox::slotActivated ( QListWidgetItem *  item)
protectedvirtualslot

Called when an item was activated.

Emits activated() with the item.

Definition at line 91 of file kcompletionbox.cpp.

void KCompletionBox::up ( )
slot

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

Definition at line 418 of file kcompletionbox.cpp.

void KCompletionBox::userCancelled ( const QString &  )
signal

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

Property Documentation

bool KCompletionBox::activateOnSelect
readwrite

Definition at line 48 of file kcompletionbox.h.

QString KCompletionBox::cancelledText
readwrite

Definition at line 47 of file kcompletionbox.h.

bool KCompletionBox::isTabHandling
readwrite

Definition at line 46 of file kcompletionbox.h.


The documentation for this class was generated from the following files:
  • kcompletionbox.h
  • kcompletionbox.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal