org.kde.koala

Class KHistoryCombo

public class KHistoryCombo extends KComboBox

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. See KHistoryComboSignals for signals emitted by KHistoryCombo

Author: Carsten Pfeiffer

UNKNOWN: A combobox for offering a history and completion.

Constructor Summary
protected KHistoryCombo(Class dummy)
KHistoryCombo(QWidget parent, String name)
Constructs a "read-write" combobox.
KHistoryCombo(QWidget parent)
KHistoryCombo()
KHistoryCombo(boolean useCompletion, QWidget parent, String name)
Same as the previous constructor, but additionally has the option to specify whether you want to let KHistoryCombo handle completion or not.
KHistoryCombo(boolean useCompletion, QWidget parent)
KHistoryCombo(boolean useCompletion)
Method Summary
voidaddToHistory(String item)
Adds an item to the end of the history list and to the completion list.
StringclassName()
voidclearHistory()
Clears the history and the completion list.
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
protected voidfinalize()
Deletes the wrapped C++ instance
ArrayListhistoryItems()
Returns the list of history items.
protected voidinsertItems(String[] items)
Inserts items into the combo, honoring pixmapProvider() Does not update the completionObject.
booleanisDisposed()
Has the wrapped C++ instance been deleted?
protected voidkeyPressEvent(QKeyEvent arg1)
Handling key-events, the shortcuts to rotate the items.
QMetaObjectmetaObject()
KPixmapProviderpixmapProvider()
booleanremoveFromHistory(String item)
Removes all items named item.
voidreset()
Resets the current position of the up/down history.
voidsetHistoryItems(String[] items)
Inserts items into the combobox.
voidsetHistoryItems(String[] items, boolean setCompletionList)
Inserts items into the combobox.
voidsetPixmapProvider(KPixmapProvider prov)
Sets a pixmap provider, so that items in the combobox can have a pixmap.
protected booleanuseCompletion()
protected voidwheelEvent(QWheelEvent ev)
Handling wheel-events, to rotate the items.

Constructor Detail

KHistoryCombo

protected KHistoryCombo(Class dummy)

KHistoryCombo

public KHistoryCombo(QWidget parent, String name)
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( String )"),
		          combo, SLOT("addToHistory( String )"));
		 
Use QComboBox.setMaxCount() to limit the history. parent the parent object of this widget. name the name of this widget.

UNKNOWN: Constructs a "read-write" combobox.

KHistoryCombo

public KHistoryCombo(QWidget parent)

KHistoryCombo

public KHistoryCombo()

KHistoryCombo

public KHistoryCombo(boolean useCompletion, QWidget parent, String name)
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.

UNKNOWN: Same as the previous constructor, but additionally has the option to specify whether you want to let KHistoryCombo handle completion or not.

KHistoryCombo

public KHistoryCombo(boolean useCompletion, QWidget parent)

KHistoryCombo

public KHistoryCombo(boolean useCompletion)

Method Detail

addToHistory

public void addToHistory(String item)
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: KHistoryCombo org.kde.qt.QComboBox#setDuplicatesEnabled

UNKNOWN: Adds an item to the end of the history list and to the completion list.

className

public String className()

clearHistory

public void clearHistory()
Clears the history and the completion list.

UNKNOWN: Clears the history and the completion list.

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()

finalize

protected void finalize()
Deletes the wrapped C++ instance

historyItems

public ArrayList historyItems()
Returns the list of history items. Empty, when this is not a read-write combobox.

See Also: KHistoryCombo

UNKNOWN: Returns the list of history items.

insertItems

protected void insertItems(String[] items)
Inserts items into the combo, honoring pixmapProvider() Does not update the completionObject. Note: duplicatesEnabled() is not honored here. Called from setHistoryItems() and setPixmapProvider()

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

isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?

keyPressEvent

protected void keyPressEvent(QKeyEvent arg1)
Handling key-events, the shortcuts to rotate the items.

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

metaObject

public QMetaObject metaObject()

pixmapProvider

public KPixmapProvider pixmapProvider()

Returns: the current pixmap provider.

See Also: KHistoryCombo KPixmapProvider

UNKNOWN:

removeFromHistory

public boolean removeFromHistory(String item)
Removes all items named item.

Returns: true if at least one item was removed.

See Also: KHistoryCombo

UNKNOWN: Removes all items named item.

reset

public void reset()
Resets the current position of the up/down history. Call this when you manually call setCurrentItem() or clearEdit().

UNKNOWN: Resets the current position of the up/down history.

setHistoryItems

public void setHistoryItems(String[] items)
Inserts items into the combobox. items might get truncated if it is longer than maxCount()

See Also: KHistoryCombo

UNKNOWN: Inserts items into the combobox.

setHistoryItems

public void setHistoryItems(String[] items, boolean 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
		 KConfig config = kapp.config();
		 ArrayList 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 setCompletionList is true, the items are inserted into the KCompletion object with mode KCompletion.Insertion and the mode is set to KCompletion.Weighted afterwards.

See Also: KHistoryCombo KComboBox KCompletion KCompletion

UNKNOWN: Inserts items into the combobox.

setPixmapProvider

public void 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 libkio, which uses KMimeType.pixmapForURL to resolve icons. Set prov to null if you want to disable pixmaps. Default no pixmaps.

See Also: KHistoryCombo

UNKNOWN: Sets a pixmap provider, so that items in the combobox can have a pixmap.

useCompletion

protected boolean useCompletion()

Returns: if we can modify the completion object or not.

UNKNOWN:

wheelEvent

protected void wheelEvent(QWheelEvent ev)
Handling wheel-events, to rotate the items.

UNKNOWN: Handling wheel-events, to rotate the items.