org.kde.koala
public class KLineEdit extends QLineEdit implements KCompletionBaseInterface
returnPressed
( String ) signals are the same as QLineEdit's
except it provides the current text in the widget as its argument whenever
appropriate.
This widget by default creates a completion object when you invoke
the completionObject( boolean ) member function for the first time or
use setCompletionObject( KCompletion, boolean ) to assign your own
completion object. Additionally, to make this widget more functional,
KLineEdit will by default handle the text rotation and completion
events internally when a completion object is created through either one
of the methods mentioned above. If you do not need this functionality,
simply use KCompletionBase.setHandleSignals( boolean ) or set the
booleanean parameter in the above functions to false.
The default key-bindings for completion and rotation is determined
from the global settings in KStdAccel. These values, however,
can be overridden locally by invoking KCompletionBase.setKeyBinding().
The values can easily be reverted back to the default setting, by simply
calling useGlobalSettings(). An alternate method would be to default
individual key-bindings by using setKeyBinding() with the default
second argument.
If EchoMode
for this widget is set to something other than QLineEdit
.Normal,
the completion mode will always be defaulted to KGlobalSettings.CompletionNone.
This is done purposefully to guard against protected entries such as passwords being
cached in KCompletion's list. Hence, if the EchoMode
is not QLineEdit.Normal, the
completion mode is automatically disabled.
A read-only KLineEdit will have the same background color as a
disabled KLineEdit, but its foreground color will be the one used
for the read-write mode. This differs from QLineEdit's implementation
and is done to give visual distinction between the three different modes:
disabled, read-only, and read-write.
KLineEdit edit = new KLineEdit( this, "mywidget" ); KCompletion comp = edit.completionObject(); // Connect to the return pressed signal - optional connect(edit,SIGNAL("returnPressed(String)"),comp,SLOT("addItem(String)"));To use a customized completion objects or your own completion object :
KLineEdit edit = new KLineEdit( this,"mywidget" ); KURLCompletion comp = new KURLCompletion(); edit.setCompletionObject( comp ); // Connect to the return pressed signal - optional connect(edit,SIGNAL("returnPressed(String)"),comp,SLOT("addItem(String)"));Note if you specify your own completion object you have to either delete it when you don't need it anymore, or you can tell KLineEdit to delete it for you:
edit.setAutoDeleteCompletionObject( true );
// Tell the widget to not handle completion and iteration automatically. edit.setHandleSignals( false ); // Set your own key-bindings for a text completion mode. edit.setKeyBinding( KCompletionBase.TextCompletion, Qt.End ); // Hide the context (popup) menu edit.setContextMenuEnabled( false ); // Temporarily disable signal (both completion & iteration) emitions edit.disableSignals(); // Default the key-bindings back to the default system settings. edit.useGlobalKeyBindings();See KLineEditSignals for signals emitted by KLineEdit
UNKNOWN: An enhanced QLineEdit widget for inputting text.
Constructor Summary | |
---|---|
protected | KLineEdit(Class dummy) |
KLineEdit(String string, QWidget parent, String name)
Constructs a KLineEdit object with a default text, a parent,
and a name. | |
KLineEdit(String string, QWidget parent) | |
KLineEdit(QWidget parent, String name)
Constructs a KLineEdit object with a parent and a name. | |
KLineEdit(QWidget parent) | |
KLineEdit() |
Method Summary | |
---|---|
protected boolean | autoSuggest()
Whether in current state text should be auto-suggested |
String | className() |
void | clear()
Reimplemented to workaround a buggy QLineEdit.clear()
(changing the clipboard to the text we just had in the lineedit) |
KCompletionBox | completionBox(boolean create) |
KCompletionBox | completionBox() |
int | completionMode()
Returns the current completion mode.
|
KCompletion | completionObject(boolean hsig)
Returns a pointer to the current completion object.
|
KCompletion | completionObject() |
KCompletion | compObj()
Returns a pointer to the completion object.
|
protected void | contextMenuEvent(QContextMenuEvent arg1)
Re-implemented for internal reasons. |
void | copy()
Reimplemented for internal reasons, the API is not affected. |
protected void | create(long arg1, boolean initializeWindow, boolean destroyOldWindow)
Reimplemented for internal reasons, the API is not affected. |
protected void | create(long arg1, boolean initializeWindow) |
protected void | create(long arg1) |
protected void | create() |
protected QPopupMenu | createPopupMenu()
Re-implemented for internal reasons. |
protected KCompletionBaseInterface | delegate()
Returns the delegation object. |
void | dispose() Delete the wrapped C++ instance ahead of finalize() |
protected void | dropEvent(QDropEvent arg1)
Re-implemented to handle URI drops.
|
boolean | emitSignals()
Returns true if the object emits the signals. |
boolean | eventFilter(QObject arg1, QEvent arg2)
Re-implemented for internal reasons. |
protected void | finalize() Deletes the wrapped C++ instance |
protected void | focusInEvent(QFocusEvent arg1)
Re-implemented for internal reasons. |
KShortcut | getKeyBinding(int item)
Returns the key-binding used for the specified item.
|
boolean | handleSignals()
Returns true if the object handles the signals. |
boolean | isCompletionObjectAutoDeleted()
Returns true if the completion object is deleted
upon this widget's destruction.
|
boolean | isContextMenuEnabled()
Returns true when the context menu is enabled. |
boolean | isDisposed() Has the wrapped C++ instance been deleted? |
boolean | isSqueezedTextEnabled()
Returns true if text squeezing is enabled.
|
boolean | isURLDropsEnabled()
Returns true when decoded URL drops are enabled |
protected void | keyPressEvent(QKeyEvent arg1)
Re-implemented for internal reasons. |
protected void | makeCompletion(String arg1)
Completes the remaining text with a matching one from
a given list. |
QMetaObject | metaObject() |
protected void | mouseDoubleClickEvent(QMouseEvent arg1)
Re-implemented for internal reasons. |
protected void | mousePressEvent(QMouseEvent arg1)
Re-implemented for internal reasons. |
String | originalText()
Returns the original text if text squeezing is enabled.
|
protected void | resizeEvent(QResizeEvent arg1)
Re-implemented for internal reasons. |
void | rotateText(int type)
Iterates through all possible matches of the completed text or
the history list.
|
void | setAutoDeleteCompletionObject(boolean autoDelete)
Sets the completion object when this widget's destructor
is called.
|
void | setCompletedItems(String[] items)
Sets items into the completion-box if completionMode() is
CompletionPopup. |
void | setCompletedItems(String[] items, boolean autoSuggest)
Same as the above function except it allows you to temporarily
turn off text completion in CompletionPopupAuto mode.
|
void | setCompletedText(String arg1)
See KCompletionBase.setCompletedText. |
protected void | setCompletedText(String arg1, boolean arg2) |
void | setCompletionBox(KCompletionBox box)
Set the completion-box to be used in completion mode
KGlobalSettings.CompletionPopup.
|
void | setCompletionMode(int mode)
Re-implemented from KCompletionBase for internal reasons.
|
void | setCompletionObject(KCompletion arg1, boolean hsig)
Reimplemented for internal reasons, the API is not affected. |
void | setCompletionObject(KCompletion arg1) |
void | setContextMenuEnabled(boolean showMenu)
Enables/disables the popup (context) menu.
|
protected void | setDelegate(KCompletionBaseInterface delegate)
Sets or removes the delegation object. |
void | setEnableSignals(boolean enable)
Sets the widget's ability to emit text completion and
rotation signals.
|
void | setEnableSqueezedText(boolean enable)
Enable text squeezing whenever the supplied text is too long.
|
void | setHandleSignals(boolean handle)
Enables this object to handle completion and rotation
events internally.
|
boolean | setKeyBinding(int item, KShortcut key)
Sets the key-binding to be used for manual text
completion, text rotation in a history list as
well as a completion list.
|
void | setReadOnly(boolean arg1)
Re-implemented for internal reasons. |
void | setSqueezedText(String text)
Squeezes text into the line edit.
|
void | setText(String arg1)
Re-implemented to enable text squeezing. |
void | setTrapReturnKey(boolean trap)
By default, KLineEdit recognizes Key_Return and Key_Enter and emits
the returnPressed() signals, but it also lets the event pass,
for example causing a dialog's default-button to be called.
|
void | setURL(KURL url)
Sets url into the lineedit. |
void | setURLDropsEnabled(boolean enable)
Enables/Disables handling of URL drops. |
protected void | setUserSelection(boolean userSelection)
Sets the widget in userSelection mode or in automatic completion
selection mode. |
boolean | trapReturnKey() |
void | useGlobalKeyBindings()
Sets this object to use global values for key-bindings.
|
protected void | userCancelled(String cancelText)
Resets the current displayed text.
|
Parameters: string Text to be shown in the edit widget. parent The parent object of this widget. name the name of this widget
UNKNOWN: Constructs a KLineEdit object with a default text, a parent, and a name.
Parameters: parent The parent object of this widget. name The name of this widget.
UNKNOWN: Constructs a KLineEdit object with a parent and a name.
UNKNOWN: Whether in current state text should be auto-suggested
UNKNOWN: Reimplemented to workaround a buggy QLineEdit.clear() (changing the clipboard to the text we just had in the lineedit)
Parameters: create Set this to false if you don't want the box to be created i.e. to test if it is available.
Returns: the completion-box, that is used in completion mode KGlobalSettings.CompletionPopup. This method will create a completion-box if none is there, yet.
UNKNOWN:
Returns: the completion mode.
UNKNOWN: Returns the current completion mode.
hsig
is set to false. It is also automatically destroyed when the destructor
is called. You can change this default behavior using the
KLineEdit and KLineEdit member
functions.
See also KLineEdit.Parameters: hsig if true, handles completion signals internally.
Returns: a pointer the completion object.
UNKNOWN: Returns a pointer to the current completion object.
NULL.
Use this method to get the
pointer to a completion object when inheriting so that you
won't inadvertently create it!!Returns: the completion object or NULL if one does not exist.
UNKNOWN: Returns a pointer to the completion object.
UNKNOWN: Re-implemented for internal reasons.
UNKNOWN: Reimplemented for internal reasons, the API is not affected.
UNKNOWN: Reimplemented for internal reasons, the API is not affected.
UNKNOWN: Re-implemented for internal reasons.
Returns: the delegation object, or 0 if there is none
See Also: KLineEdit
UNKNOWN: Returns the delegation object.
UNKNOWN: Re-implemented to handle URI drops.
Returns: true if signals are emitted
UNKNOWN: Returns true if the object emits the signals.
UNKNOWN: Re-implemented for internal reasons.
UNKNOWN: Re-implemented for internal reasons.
item.
If the binding
contains modifier key(s), the SUM of the modifier key
and the actual key code are returned.Parameters: item the item to check
Returns: the key-binding used for the feature given by item.
See Also: KLineEdit
UNKNOWN: Returns the key-binding used for the specified item.
Returns: true if this signals are handled internally.
UNKNOWN: Returns true if the object handles the signals.
Returns: true if the completion object will be deleted automatically
UNKNOWN: Returns true if the completion object is deleted upon this widget's destruction.
true
when the context menu is enabled.UNKNOWN: Returns true
when the context menu is enabled.
UNKNOWN: Returns true if text squeezing is enabled.
true
when decoded URL drops are enabledUNKNOWN: Returns true
when decoded URL drops are enabled
UNKNOWN: Re-implemented for internal reasons.
UNKNOWN: Completes the remaining text with a matching one from a given list.
UNKNOWN: Re-implemented for internal reasons.
UNKNOWN: Re-implemented for internal reasons.
See Also: org.kde.qt.QLineEdit
UNKNOWN: Returns the original text if text squeezing is enabled.
UNKNOWN: Re-implemented for internal reasons.
Parameters: type The key-binding invoked.
UNKNOWN: Iterates through all possible matches of the completed text or the history list.
Parameters: autoDelete if true, delete completion object on destruction.
UNKNOWN: Sets the completion object when this widget's destructor is called.
items
into the completion-box if completionMode() is
CompletionPopup. The popup will be shown immediately.Parameters: items list of completion matches to be shown in the completion box.
UNKNOWN: Sets items
into the completion-box if completionMode() is CompletionPopup.
Parameters: items list of completion matches to be shown in the completion box. autoSuggest true if you want automatic text completion (suggestion) enabled.
UNKNOWN: Same as the above function except it allows you to temporarily turn off text completion in CompletionPopupAuto mode.
UNKNOWN: See KCompletionBase.setCompletedText.
Parameters: box The KCompletionBox to set
UNKNOWN: Set the completion-box to be used in completion mode KGlobalSettings.CompletionPopup.
UNKNOWN: Re-implemented from KCompletionBase for internal reasons.
UNKNOWN: Reimplemented for internal reasons, the API is not affected.
true
, then both the context menu and the completion
menu item are enabled. If you do not want to the completion
item to be visible simply invoke hideModechanger() right
after calling this method. Also by default, the context
menu is automatically created if this widget is editable. Thus
you need to call this function with the argument set to false
if you do not want this behavior.Parameters: showMenu If true
, show the context menu.
UNKNOWN: Enables/disables the popup (context) menu.
Parameters: delegate the delegation object, or 0 to remove it
UNKNOWN: Sets or removes the delegation object.
enable
set to false
will
cause the completion & rotation signals not to be emitted.
However, unlike setting the completion object to NULL
using setCompletionObject, disabling the emition of
the signals through this method does not affect the current
completion object.
There is no need to invoke this function by default. When a
completion object is created through completionObject or
setCompletionObject, these signals are set to emit
automatically. Also note that disabling this signals will not
necessarily interfere with the objects ability to handle these
events internally. See setHandleSignals.Parameters: enable if false, disables the emition of completion & rotation signals.
UNKNOWN: Sets the widget's ability to emit text completion and rotation signals.
See Also: org.kde.qt.QLineEdit
UNKNOWN: Enable text squeezing whenever the supplied text is too long.
Parameters: handle if true, handle completion & rotation internally.
UNKNOWN: Enables this object to handle completion and rotation events internally.
key
is negative or the supplied key-binding conflicts
with the ones set for one of the other features.
NOTE: To use a modifier key (Shift, Ctrl, Alt) as part of
the key-binding simply simply sum
up the values of the
modifier and the actual key. For example, to use CTRL+E as
a key binding for one of the items, you would simply supply
"Qt.CtrlButton + Qt.Key_E" as the second argument to this
function.Parameters: item the feature whose key-binding needs to be set:
Returns: true if key-binding can successfully be set.
See Also: KLineEdit
UNKNOWN: Sets the key-binding to be used for manual text completion, text rotation in a history list as well as a completion list.
UNKNOWN: Re-implemented for internal reasons.
text
into the line edit.
This can only be used with read-only line-edits.UNKNOWN: Squeezes text
into the line edit.
UNKNOWN: Re-implemented to enable text squeezing.
Key_Return
and Key_Enter
and emits
the returnPressed() signals, but it also lets the event pass,
for example causing a dialog's default-button to be called.
Call this method with trap
= true
to make KLineEdit
stop these
events. The signals will still be emitted of course.See Also: KLineEdit
UNKNOWN: By default, KLineEdit recognizes Key_Return
and Key_Enter
and emits the returnPressed() signals, but it also lets the event pass, for example causing a dialog's default-button to be called.
url
into the lineedit. It uses KURL.prettyURL() so
that the url is properly decoded for displaying.UNKNOWN: Sets url
into the lineedit.
Parameters: enable If true
, insert decoded URLs
UNKNOWN: Enables/Disables handling of URL drops.
UNKNOWN: Sets the widget in userSelection mode or in automatic completion selection mode.
Returns: true
if keyevents of Key_Return
or
Key_Enter
will be stopped or if they will be propagated.
See Also: KLineEdit
UNKNOWN:
UNKNOWN: Sets this object to use global values for key-bindings.
UNKNOWN: Resets the current displayed text.