#include <klineedit.h>
Public Slots | |
virtual void | setReadOnly (bool) |
void | rotateText (TDECompletionBase::KeyBindingType type) |
virtual void | setCompletedText (const TQString &) |
void | setCompletedItems (const TQStringList &items) |
void | setCompletedItems (const TQStringList &items, bool autoSuggest) |
virtual void | clear () |
void | setSqueezedText (const TQString &text) |
virtual void | setText (const TQString &) |
Signals | |
void | completionBoxActivated (const TQString &) |
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 | |
KLineEdit (const TQString &string, TQWidget *parent, const char *name=0) | |
KLineEdit (TQWidget *parent=0, const char *name=0) | |
virtual | ~KLineEdit () |
void | setURL (const KURL &url) |
void | cursorAtEnd () |
virtual void | setCompletionMode (TDEGlobalSettings::Completion mode) |
virtual void | setContextMenuEnabled (bool showMenu) |
bool | isContextMenuEnabled () const |
void | setURLDropsEnabled (bool enable) |
bool | isURLDropsEnabled () const |
void | setTrapReturnKey (bool trap) |
bool | trapReturnKey () const |
virtual bool | eventFilter (TQObject *, TQEvent *) |
TDECompletionBox * | completionBox (bool create=true) |
virtual void | setCompletionObject (TDECompletion *, bool hsig=true) |
virtual void | copy () const |
void | setEnableSqueezedText (bool enable) |
bool | isSqueezedTextEnabled () const |
TQString | originalText () const |
void | setCompletionBox (TDECompletionBox *box) |
void | setClickMessage (const TQString &msg) |
TQString | clickMessage () const |
Public Member Functions inherited from TDECompletionBase | |
TDECompletion * | completionObject (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 |
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 Slots | |
virtual void | makeCompletion (const TQString &) |
void | slotAboutToShow () |
void | slotCancelled () |
void | userCancelled (const TQString &cancelText) |
Protected Member Functions | |
virtual void | resizeEvent (TQResizeEvent *) |
virtual void | keyPressEvent (TQKeyEvent *) |
virtual void | mousePressEvent (TQMouseEvent *) |
virtual void | mouseDoubleClickEvent (TQMouseEvent *) |
virtual void | mouseReleaseEvent (TQMouseEvent *) |
virtual void | contextMenuEvent (TQContextMenuEvent *) |
virtual TQPopupMenu * | createPopupMenu () |
virtual void | drawContents (TQPainter *p) |
virtual void | dropEvent (TQDropEvent *) |
virtual void | setCompletedText (const TQString &, bool) |
void | setUserSelection (bool userSelection) |
virtual void | create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true) |
virtual void | focusInEvent (TQFocusEvent *) |
virtual void | focusOutEvent (TQFocusEvent *) |
bool | autoSuggest () const |
virtual void | virtual_hook (int id, void *data) |
Protected Member Functions inherited from TDECompletionBase | |
KeyBindingMap | getKeyBindings () const |
void | setDelegate (TDECompletionBase *delegate) |
TDECompletionBase * | delegate () const |
Friends | |
class | KComboBox |
Additional Inherited Members | |
Public Types inherited from TDECompletionBase | |
enum | KeyBindingType |
Public Attributes inherited from TDECompletionBase | |
TextCompletion | |
PrevCompletionMatch | |
NextCompletionMatch | |
SubstringCompletion | |
Detailed Description
An enhanced TQLineEdit widget for inputting text.
Detail
This widget inherits from TQLineEdit and implements the following additional functionalities: a completion object that provides both automatic and manual text completion as well as multiple match iteration features, configurable key-bindings to activate these features and a popup-menu item that can be used to allow the user to set text completion modes on the fly based on their preference.
To support these new features KLineEdit also emits a few more additional signals. These are: completion( const TQString& ), textRotation( KeyBindingType ), and returnPressed( const TQString& ). The completion signal can be connected to a slot that will assist the user in filling out the remaining text. The text rotation signal is intended to be used to iterate through the list of all possible matches whenever there is more than one match for the entered text. The returnPressed( const TQString& )
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( bool ) member function for the first time or use setCompletionObject( TDECompletion*, bool ) 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 setHandleSignals( bool )
or set the boolean parameter in the above functions to false.
The default key-bindings for completion and rotation is determined from the global settings in TDEStdAccel. These values, however, can be overridden locally by invoking setKeyBinding()
. You can easily revert these settings back to the default 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 TQLineEdit::Normal
, the completion mode will always be defaulted to TDEGlobalSettings::CompletionNone. This is done purposefully to guard against protected entries such as passwords being cached in TDECompletion's list. Hence, if the EchoMode
is not TQLineEdit::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.
Usage
To enable the basic completion feature :
To use a customized completion objects or your own completion object :
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:
Miscellaneous function calls :
Definition at line 145 of file klineedit.h.
Constructor & Destructor Documentation
◆ KLineEdit() [1/2]
KLineEdit::KLineEdit | ( | const TQString & | string, |
TQWidget * | parent, | ||
const char * | name = 0 |
||
) |
Constructs a KLineEdit object with a default text, a parent, and a name.
- Parameters
-
string Text to be shown in the edit widget. parent The parent object of this widget. name the name of this widget
Definition at line 106 of file klineedit.cpp.
◆ KLineEdit() [2/2]
KLineEdit::KLineEdit | ( | TQWidget * | parent = 0 , |
const char * | name = 0 |
||
) |
Constructs a KLineEdit object with a parent and a name.
- Parameters
-
parent The parent object of this widget. name The name of this widget.
Definition at line 112 of file klineedit.cpp.
◆ ~KLineEdit()
|
virtual |
Destructor.
Definition at line 118 of file klineedit.cpp.
Member Function Documentation
◆ aboutToShowContextMenu
|
signal |
Emitted before the context menu is displayed.
The signal allows you to add your own entries into the the context menu that is created on demand.
NOTE: Do not store the pointer to the QPopupMenu provided through since it is created and deleted on demand.
- Parameters
-
p the context menu about to be displayed
◆ autoSuggest()
|
protected |
Whether in current state text should be auto-suggested.
- Since
- 3.4
Definition at line 1362 of file klineedit.cpp.
◆ clear
|
virtualslot |
Reimplemented to workaround a buggy TQLineEdit::clear() (changing the clipboard to the text we just had in the lineedit)
Definition at line 1320 of file klineedit.cpp.
◆ clickMessage()
TQString KLineEdit::clickMessage | ( | ) | const |
- Returns
- the message set with setClickMessage
- Since
- 3.5.4
Definition at line 1373 of file klineedit.cpp.
◆ completion
|
signal |
Emitted when the completion key is pressed.
Please note that this signal is not emitted if the completion mode is set to CompletionNone
or EchoMode
is normal.
◆ completionBox()
TDECompletionBox * KLineEdit::completionBox | ( | bool | create = true | ) |
- Returns
- the completion-box, that is used in completion mode TDEGlobalSettings::CompletionPopup. This method will create a completion-box if none is there, yet.
- Parameters
-
create Set this to false if you don't want the box to be created i.e. to test if it is available.
Definition at line 1260 of file klineedit.cpp.
◆ completionBoxActivated
|
signal |
Emitted whenever the completion box is activated.
- Since
- 3.1
◆ completionModeChanged
|
signal |
Emitted when the user changed the completion mode by using the popupmenu.
◆ contextMenuEvent()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQLineEdit::contextMenuEvent().
Definition at line 856 of file klineedit.cpp.
◆ copy()
|
virtual |
Reimplemented for internal reasons, the API is not affected.
Definition at line 397 of file klineedit.cpp.
◆ create()
|
protectedvirtual |
Reimplemented for internal reasons, the API is not affected.
Definition at line 1285 of file klineedit.cpp.
◆ createPopupMenu()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQLineEdit::createPopupMenu().
Reimplemented in TDEListViewSearchLine.
Definition at line 862 of file klineedit.cpp.
◆ cursorAtEnd()
|
inline |
Puts the text cursor at the end of the string.
This method is deprecated. Use TQLineEdit::end() instead.
- Deprecated:
- TQLineEdit::end()
Definition at line 197 of file klineedit.h.
◆ drawContents()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQFrame::drawContents().
Definition at line 967 of file klineedit.cpp.
◆ dropEvent()
|
protectedvirtual |
Re-implemented to handle URI drops.
See TQLineEdit::dropEvent().
Definition at line 983 of file klineedit.cpp.
◆ eventFilter()
|
virtual |
Re-implemented for internal reasons.
API not affected.
Definition at line 1007 of file klineedit.cpp.
◆ focusInEvent()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQLineEdit::focusInEvent().
Definition at line 1339 of file klineedit.cpp.
◆ focusOutEvent()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQLineEdit::focusOutEvent().
Reimplemented in TDEListViewLineEdit.
Definition at line 1353 of file klineedit.cpp.
◆ isContextMenuEnabled()
|
inline |
Returns true
when the context menu is enabled.
Definition at line 228 of file klineedit.h.
◆ isSqueezedTextEnabled()
bool KLineEdit::isSqueezedTextEnabled | ( | ) | const |
Returns true if text squeezing is enabled.
This is only valid when the widget is in read-only mode.
- Since
- 3.2
Definition at line 305 of file klineedit.cpp.
◆ isURLDropsEnabled()
bool KLineEdit::isURLDropsEnabled | ( | ) | const |
Returns true
when decoded URL drops are enabled.
Definition at line 1063 of file klineedit.cpp.
◆ keyPressEvent()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQLineEdit::keyPressEvent().
Reimplemented in TDEListViewLineEdit, and KRestrictedLine.
Definition at line 440 of file klineedit.cpp.
◆ makeCompletion
|
protectedvirtualslot |
Completes the remaining text with a matching one from a given list.
Definition at line 226 of file klineedit.cpp.
◆ mouseDoubleClickEvent()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQWidget::mouseDoubleClickEvent().
Definition at line 818 of file klineedit.cpp.
◆ mousePressEvent()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQLineEdit::mousePressEvent().
Definition at line 829 of file klineedit.cpp.
◆ mouseReleaseEvent()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQLineEdit::mouseReleaseEvent().
Definition at line 840 of file klineedit.cpp.
◆ originalText()
TQString KLineEdit::originalText | ( | ) | const |
Returns the original text if text squeezing is enabled.
If the widget is not in "read-only" mode, this function returns the same thing as TQLineEdit::text().
- See also
- QLineEdit
- Since
- 3.2
Definition at line 1331 of file klineedit.cpp.
◆ resizeEvent()
|
protectedvirtual |
Re-implemented for internal reasons.
API not affected.
See TQLineEdit::resizeEvent().
Definition at line 432 of file klineedit.cpp.
◆ returnPressed
|
signal |
Emitted when the user presses the return key.
The argument is the current text. Note that this signal is not emitted if the widget's EchoMode
is set to TQLineEdit::EchoMode.
◆ rotateText
|
slot |
Iterates through all possible matches of the completed text or the history list.
This function simply iterates over all possible matches in case multimple matches are found as a result of a text completion request. It will have no effect if only a single match is found.
- Parameters
-
type The key-binding invoked.
Definition at line 205 of file klineedit.cpp.
◆ setClickMessage()
void KLineEdit::setClickMessage | ( | const TQString & | msg | ) |
This makes the line edit display a grayed-out hinting text as long as the user didn't enter any text.
It is often used as indication about the purpose of the line edit.
- Since
- 3.5.4
Definition at line 1367 of file klineedit.cpp.
◆ setCompletedItems [1/2]
|
slot |
Sets 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.
Definition at line 1193 of file klineedit.cpp.
◆ setCompletedItems [2/2]
|
slot |
Same as the above function except it allows you to temporarily turn off text completion in CompletionPopupAuto mode.
TODO: Merge with above function in KDE 4. TODO: Does that make this or the above
- Parameters
-
items list of completion matches to be shown in the completion box. autoSuggest true if you want automatic text completion (suggestion) enabled.
Definition at line 1198 of file klineedit.cpp.
◆ setCompletedText
|
virtualslot |
See TDECompletionBase::setCompletedText.
Definition at line 195 of file klineedit.cpp.
◆ setCompletionBox()
void KLineEdit::setCompletionBox | ( | TDECompletionBox * | box | ) |
Set the completion-box to be used in completion mode TDEGlobalSettings::CompletionPopup.
This will do nothing if a completion-box already exists.
- Parameters
-
box The TDECompletionBox to set
- Since
- 3.4
Definition at line 1083 of file klineedit.cpp.
◆ setCompletionMode()
|
virtual |
Re-implemented from TDECompletionBase for internal reasons.
This function is re-implemented in order to make sure that the EchoMode is acceptable before we set the completion mode.
See TDECompletionBase::setCompletionMode
Reimplemented from TDECompletionBase.
Definition at line 150 of file klineedit.cpp.
◆ setCompletionObject()
|
virtual |
Reimplemented for internal reasons, the API is not affected.
Reimplemented from TDECompletionBase.
Definition at line 1270 of file klineedit.cpp.
◆ setContextMenuEnabled()
|
inlinevirtual |
Enables/disables the popup (context) menu.
Note that when this function is invoked with its argument set to 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.
Definition at line 223 of file klineedit.h.
◆ setEnableSqueezedText()
void KLineEdit::setEnableSqueezedText | ( | bool | enable | ) |
Enable text squeezing whenever the supplied text is too long.
Only works for "read-only" mode.
Note that once text squeezing is enabled, TQLineEdit::text() and TQLineEdit::displayText() return the squeezed text. If you want the original text, use originalText.
- See also
- QLineEdit
- Since
- 3.2
Definition at line 300 of file klineedit.cpp.
◆ setReadOnly
|
virtualslot |
◆ setSqueezedText
|
slot |
Squeezes text
into the line edit.
This can only be used with read-only line-edits.
- Since
- 3.1
Definition at line 294 of file klineedit.cpp.
◆ setText
|
virtualslot |
Re-implemented to enable text squeezing.
API is not affected.
Definition at line 310 of file klineedit.cpp.
◆ setTrapReturnKey()
void KLineEdit::setTrapReturnKey | ( | bool | 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.
Call this method with trap
= true
to make KLineEdit
stop these events. The signals will still be emitted of course.
- See also
- trapReturnKey()
Definition at line 1068 of file klineedit.cpp.
◆ setURL()
void KLineEdit::setURL | ( | const KURL & | url | ) |
Sets url
into the lineedit.
It uses KURL::prettyURL() so that the url is properly decoded for displaying.
Definition at line 1078 of file klineedit.cpp.
◆ setURLDropsEnabled()
void KLineEdit::setURLDropsEnabled | ( | bool | enable | ) |
Enables/Disables handling of URL drops.
If enabled and the user drops an URL, the decoded URL will be inserted. Otherwise the default behavior of TQLineEdit is used, which inserts the encoded URL.
- Parameters
-
enable If true
, insert decoded URLs
Definition at line 1058 of file klineedit.cpp.
◆ setUserSelection()
|
protected |
Sets the widget in userSelection mode or in automatic completion selection mode.
This changes the colors of selections.
Definition at line 1291 of file klineedit.cpp.
◆ slotAboutToShow
|
inlineprotectedslot |
◆ slotCancelled
|
inlineprotectedslot |
◆ substringCompletion
|
signal |
Emitted when the shortcut for substring completion is pressed.
◆ textRotation
|
signal |
Emitted when the text rotation key-bindings are pressed.
The argument indicates which key-binding was pressed. In KLineEdit's case this can be either one of two values: PrevCompletionMatch or NextCompletionMatch. See setKeyBinding
for details.
Note that this signal is not emitted if the completion mode is set to TDEGlobalSettings::CompletionNone
or echoMode()
is not normal.
◆ trapReturnKey()
bool KLineEdit::trapReturnKey | ( | ) | const |
- Returns
true
if keyevents ofKey_Return
orKey_Enter
will be stopped or if they will be propagated.
- See also
- setTrapReturnKey ()
Definition at line 1073 of file klineedit.cpp.
◆ userCancelled
|
protectedslot |
Resets the current displayed text.
Call this function to revert a text completion if the user cancels the request. Mostly applies to popup completions.
Definition at line 1100 of file klineedit.cpp.
The documentation for this class was generated from the following files: