KHistoryCombo Class Reference
#include <kcombobox.h>
Inheritance diagram for KHistoryCombo:

Detailed Description
A combobox for offering a history and completion.A combobox which implements a history like a unix shell. You can navigate through all the items by using the Up or Down arrows (configurable of course). Additionally, weighted completion is available. So you should load and save the completion list to preserve the weighting between sessions.
KHistoryCombo obeys the HISTCONTROL environment variable to determine whether duplicates in the history should be tolerated in addToHistory() or not. During construction of KHistoryCombo, duplicates will be disabled when HISTCONTROL is set to "ignoredups" or "ignoreboth". Otherwise, duplicates are enabled by default.
- Author:
- Carsten Pfeiffer <pfeiffer@kde.org>
Definition at line 533 of file kcombobox.h.
Public Slots | |
void | addToHistory (const QString &item) |
void | clearHistory () |
Signals | |
void | cleared () |
Public Member Functions | |
KHistoryCombo (QWidget *parent=0L, const char *name=0L) | |
KHistoryCombo (bool useCompletion, QWidget *parent=0L, const char *name=0L) | |
~KHistoryCombo () | |
void | setHistoryItems (QStringList items) |
void | setHistoryItems (QStringList items, bool setCompletionList) |
QStringList | historyItems () const |
bool | removeFromHistory (const QString &item) |
void | setPixmapProvider (KPixmapProvider *prov) |
KPixmapProvider * | pixmapProvider () const |
void | reset () |
Protected Member Functions | |
virtual void | keyPressEvent (QKeyEvent *) |
virtual void | wheelEvent (QWheelEvent *ev) |
void | insertItems (const QStringList &items) |
bool | useCompletion () const |
virtual void | virtual_hook (int id, void *data) |
Properties | |
QStringList | historyItems |
Constructor & Destructor Documentation
|
Constructs a "read-write" combobox. A read-only history combobox doesn't make much sense, so it is only available as read-write. Completion will be used automatically for the items in the combo. The insertion-policy is set to NoInsertion, you have to add the items yourself via the slot addToHistory. If you want every item added, use
connect( combo, SIGNAL( activated( const QString& )), combo, SLOT( addToHistory( const QString& ))); Use QComboBox::setMaxCount() to limit the history.
Definition at line 348 of file kcombobox.cpp. |
|
Same as the previous constructor, but additionally has the option to specify whether you want to let KHistoryCombo handle completion or not.
If set to Definition at line 355 of file kcombobox.cpp. |
|
Destructs the combo, the completion-object and the pixmap-provider.
Definition at line 386 of file kcombobox.cpp. |
Member Function Documentation
|
Adds an item to the end of the history list and to the completion list. If maxCount() is reached, the first item of the list will be removed.
If the last inserted item is the same as
If duplicatesEnabled() is false, any equal existing item will be removed before Note: By using this method and not the Q and KComboBox insertItem() methods, you make sure that the combobox stays in sync with the completion. It would be annoying if completion would give an item not in the combobox, and vice versa.
Definition at line 450 of file kcombobox.cpp. |
|
Emitted when the history was cleared by the entry in the popup menu.
|
|
Clears the history and the completion list.
Definition at line 430 of file kcombobox.cpp. |
|
Returns the list of history items. Empty, when this is not a read-write combobox.
|
|
Inserts Note: duplicatesEnabled() is not honored here. Called from setHistoryItems() and setPixmapProvider() Definition at line 656 of file kcombobox.cpp. |
|
Handling key-events, the shortcuts to rotate the items.
Definition at line 597 of file kcombobox.cpp. |
|
Definition at line 664 of file kcombobox.h. |
|
Removes all items named
Definition at line 502 of file kcombobox.cpp. |
|
Resets the current position of the up/down history. Call this when you manually call setCurrentItem() or clearEdit(). Definition at line 670 of file kcombobox.h. |
|
Inserts
Set KConfig *config = kapp->config(); QStringList list; // load the history and completion list after creating the history combo list = config->readListEntry( "Completion list" ); combo->completionObject()->setItems( list ); list = config->readListEntry( "History list" ); combo->setHistoryItems( list ); [...] // save the history and completion list when the history combo is // destroyed list = combo->completionObject()->items() config->writeEntry( "Completion list", list ); list = combo->historyItems(); config->writeEntry( "History list", list ); Be sure to use different names for saving with KConfig if you have more than one KHistoryCombo.
Note: When
Definition at line 391 of file kcombobox.cpp. |
|
Inserts
Definition at line 581 of file kcombobox.h. |
|
Sets a pixmap provider, so that items in the combobox can have a pixmap. KPixmapProvider is just an abstract class with the one pure virtual method KPixmapProvider::pixmapFor(). This method is called whenever an item is added to the KHistoryComboBox. Implement it to return your own custom pixmaps, or use the KURLPixmapProvider from libkio, which uses KMimeType::pixmapForURL to resolve icons.
Set
Definition at line 638 of file kcombobox.cpp. |
|
Definition at line 729 of file kcombobox.h. |
|
Handling wheel-events, to rotate the items.
Reimplemented from KComboBox. Definition at line 613 of file kcombobox.cpp. |
The documentation for this class was generated from the following files: