• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

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

#include <kcombobox.h>

Inheritance diagram for KHistoryCombo:
KComboBox TDECompletionBase

Public Slots

void addToHistory (const TQString &item)
 
void clearHistory ()
 
- Public Slots inherited from KComboBox
void rotateText (TDECompletionBase::KeyBindingType type)
 
virtual void setCompletedText (const TQString &)
 
void setCompletedItems (const TQStringList &items)
 
void setCurrentItem (const TQString &item, bool insert=false, int index=-1)
 
void setCurrentItem (int index)
 

Signals

void cleared ()
 
void removed (const TQString &item)
 
- Signals inherited from KComboBox
void returnPressed ()
 
void returnPressed (const TQString &)
 
void completion (const TQString &)
 
void substringCompletion (const TQString &)
 
void textRotation (TDECompletionBase::KeyBindingType)
 
void completionModeChanged (TDEGlobalSettings::Completion)
 
void aboutToShowContextMenu (TQPopupMenu *p)
 

Public Member Functions

 KHistoryCombo (TQWidget *parent=0L, const char *name=0L)
 
 KHistoryCombo (bool useCompletion, TQWidget *parent=0L, const char *name=0L)
 
 ~KHistoryCombo ()
 
void setHistoryItems (TQStringList items)
 
void setHistoryItems (TQStringList items, bool setCompletionList)
 
TQStringList historyItems () const
 
bool removeFromHistory (const TQString &item)
 
void setPixmapProvider (KPixmapProvider *prov)
 
KPixmapProvider * pixmapProvider () const
 
void reset ()
 
void setHistoryEditorEnabled (bool enable)
 
bool isHistoryEditorEnabled () const
 
- Public Member Functions inherited from KComboBox
 KComboBox (TQWidget *parent=0, const char *name=0)
 
 KComboBox (bool rw, TQWidget *parent=0, const char *name=0)
 
virtual ~KComboBox ()
 
void setEditURL (const KURL &url)
 
void insertURL (const KURL &url, int index=-1)
 
void insertURL (const TQPixmap &pixmap, const KURL &url, int index=-1)
 
void changeURL (const KURL &url, int index)
 
void changeURL (const TQPixmap &pixmap, const KURL &url, int index)
 
int cursorPosition () const
 
virtual void setAutoCompletion (bool autocomplete)
 
bool autoCompletion () const
 
virtual void setContextMenuEnabled (bool showMenu)
 
bool isContextMenuEnabled () const
 
void setURLDropsEnabled (bool enable)
 
bool isURLDropsEnabled () const
 
bool contains (const TQString &text) const
 
void setTrapReturnKey (bool trap)
 
bool trapReturnKey () const
 
virtual bool eventFilter (TQObject *, TQEvent *)
 
TDECompletionBox * completionBox (bool create=true)
 
virtual void setLineEdit (TQLineEdit *)
 
- Public Member Functions inherited from TDECompletionBase
TDECompletion * completionObject (bool hsig=true)
 
virtual void setCompletionObject (TDECompletion *compObj, bool hsig=true)
 
virtual void setHandleSignals (bool handle)
 
bool isCompletionObjectAutoDeleted () const
 
void setAutoDeleteCompletionObject (bool autoDelete)
 
void setEnableSignals (bool enable)
 
bool handleSignals () const
 
bool emitSignals () const
 
virtual void setCompletionMode (TDEGlobalSettings::Completion mode)
 
TDEGlobalSettings::Completion completionMode () const
 
bool setKeyBinding (KeyBindingType item, const TDEShortcut &key)
 
const TDEShortcut & getKeyBinding (KeyBindingType item) const
 
void useGlobalKeyBindings ()
 
virtual void setCompletedText (const TQString &text)=0
 
virtual void setCompletedItems (const TQStringList &items)=0
 
TDECompletion * compObj () const
 

Protected Member Functions

virtual void keyPressEvent (TQKeyEvent *)
 
virtual void wheelEvent (TQWheelEvent *ev)
 
void insertItems (const TQStringList &items)
 
bool useCompletion () const
 
virtual void virtual_hook (int id, void *data)
 
- Protected Member Functions inherited from KComboBox
virtual void setCompletedText (const TQString &, bool)
 
virtual void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
virtual void wheelEvent (TQWheelEvent *ev)
 
virtual void virtual_hook (int id, void *data)
 
- Protected Member Functions inherited from TDECompletionBase
KeyBindingMap getKeyBindings () const
 
void setDelegate (TDECompletionBase *delegate)
 
TDECompletionBase * delegate () const
 

Additional Inherited Members

- Public Types inherited from TDECompletionBase
enum  KeyBindingType
 
- Public Attributes inherited from TDECompletionBase
 TextCompletion
 
 PrevCompletionMatch
 
 NextCompletionMatch
 
 SubstringCompletion
 
- Protected Slots inherited from KComboBox
virtual void itemSelected (TQListBoxItem *)
 
virtual void makeCompletion (const TQString &)
 

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 pfeif.nosp@m.fer@.nosp@m.kde.o.nosp@m.rg

Definition at line 540 of file kcombobox.h.

Constructor & Destructor Documentation

◆ KHistoryCombo() [1/2]

KHistoryCombo::KHistoryCombo ( TQWidget *  parent = 0L,
const char *  name = 0L 
)

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, TQ_SIGNAL( activated( const TQString& )),
combo, TQ_SLOT( addToHistory( const TQString& )));
KHistoryCombo::addToHistory
void addToHistory(const TQString &item)
Adds an item to the end of the history list and to the completion list.
Definition: kcombobox.cpp:467

Use TQComboBox::setMaxCount() to limit the history.

parent the parent object of this widget. name the name of this widget.

Definition at line 361 of file kcombobox.cpp.

◆ KHistoryCombo() [2/2]

KHistoryCombo::KHistoryCombo ( bool  useCompletion,
TQWidget *  parent = 0L,
const char *  name = 0L 
)

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 true, KHistoryCombo will sync the completion to the contents of the combobox.

Definition at line 368 of file kcombobox.cpp.

◆ ~KHistoryCombo()

KHistoryCombo::~KHistoryCombo ( )

Destructs the combo, the completion-object and the pixmap-provider.

Definition at line 399 of file kcombobox.cpp.

Member Function Documentation

◆ addToHistory

void KHistoryCombo::addToHistory ( const TQString &  item)
slot

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 item, it will not be inserted again.

If duplicatesEnabled() is false, any equal existing item will be removed before item is added.

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.

See also
removeFromHistory
TQComboBox::setDuplicatesEnabled

Definition at line 467 of file kcombobox.cpp.

◆ cleared

void KHistoryCombo::cleared ( )
signal

Emitted when the history was cleared by the entry in the popup menu.

◆ clearHistory

void KHistoryCombo::clearHistory ( )
slot

Clears the history and the completion list.

Definition at line 443 of file kcombobox.cpp.

◆ historyItems()

TQStringList KHistoryCombo::historyItems ( ) const

Returns the list of history items.

Empty, when this is not a read-write combobox.

See also
setHistoryItems

Definition at line 433 of file kcombobox.cpp.

◆ insertItems()

void KHistoryCombo::insertItems ( const TQStringList &  items)
protected

Inserts items into the combo, honoring pixmapProvider() Does not update the completionObject.

Note: duplicatesEnabled() is not honored here.

Called from setHistoryItems() and setPixmapProvider()

Definition at line 673 of file kcombobox.cpp.

◆ isHistoryEditorEnabled()

bool KHistoryCombo::isHistoryEditorEnabled ( ) const

Definition at line 715 of file kcombobox.cpp.

◆ keyPressEvent()

void KHistoryCombo::keyPressEvent ( TQKeyEvent *  e)
protectedvirtual

Handling key-events, the shortcuts to rotate the items.

Definition at line 614 of file kcombobox.cpp.

◆ pixmapProvider()

KPixmapProvider * KHistoryCombo::pixmapProvider ( ) const
inline
Returns
the current pixmap provider.
See also
setPixmapProvider
KPixmapProvider

Definition at line 671 of file kcombobox.h.

◆ removeFromHistory()

bool KHistoryCombo::removeFromHistory ( const TQString &  item)

Removes all items named item.

Returns
true if at least one item was removed.
See also
addToHistory

Definition at line 519 of file kcombobox.cpp.

◆ reset()

void KHistoryCombo::reset ( )
inline

Resets the current position of the up/down history.

Call this when you manually call setCurrentItem() or clearEdit().

Definition at line 677 of file kcombobox.h.

◆ setHistoryEditorEnabled()

void KHistoryCombo::setHistoryEditorEnabled ( bool  enable)

When enabling it you have to connect to "removed" signal and save changes.

Definition at line 710 of file kcombobox.cpp.

◆ setHistoryItems() [1/2]

void KHistoryCombo::setHistoryItems ( TQStringList  items)
inline

Inserts items into the combobox.

items might get truncated if it is longer than maxCount()

See also
historyItems

Definition at line 588 of file kcombobox.h.

◆ setHistoryItems() [2/2]

void KHistoryCombo::setHistoryItems ( TQStringList  items,
bool  setCompletionList 
)

Inserts items into the combobox.

items might get truncated if it is longer than maxCount()

Set setCompletionList to true, if you don't have a list of completions. This tells KHistoryCombo to use all the items for the completion object as well. You won't have the benefit of weighted completion though, so normally you should do something like

TDEConfig *config = tdeApp->config();
TQStringList 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 );
TDEConfigBase::readListEntry
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
TDEConfigBase::writeEntry
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
TDEConfig

Be sure to use different names for saving with TDEConfig if you have more than one KHistoryCombo.

Note: When setCompletionList is true, the items are inserted into the TDECompletion object with mode TDECompletion::Insertion and the mode is set to TDECompletion::Weighted afterwards.

See also
historyItems
KComboBox::completionObject
TDECompletion::setItems
TDECompletion::items

Definition at line 404 of file kcombobox.cpp.

◆ setPixmapProvider()

void KHistoryCombo::setPixmapProvider ( KPixmapProvider *  prov)

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 libtdeio, which uses KMimeType::pixmapForURL to resolve icons.

Set prov to 0L if you want to disable pixmaps. Default no pixmaps.

See also
pixmapProvider

Definition at line 655 of file kcombobox.cpp.

◆ useCompletion()

bool KHistoryCombo::useCompletion ( ) const
inlineprotected
Returns
if we can modify the completion object or not.

Definition at line 744 of file kcombobox.h.

◆ virtual_hook()

void KHistoryCombo::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

Reimplemented from KComboBox.

Definition at line 723 of file kcombobox.cpp.

◆ wheelEvent()

void KHistoryCombo::wheelEvent ( TQWheelEvent *  ev)
protectedvirtual

Handling wheel-events, to rotate the items.

Reimplemented from KComboBox.

Definition at line 630 of file kcombobox.cpp.


The documentation for this class was generated from the following files:
  • kcombobox.h
  • kcombobox.cpp

tdeui

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

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.