File indexing completed on 2024-05-12 11:47:11
0001 /* 0002 This file is part of the KDE libraries 0003 0004 This class was originally inspired by Torben Weis' 0005 fileentry.cpp for KFM II. 0006 0007 SPDX-FileCopyrightText: 1997 Sven Radej <sven.radej@iname.com> 0008 SPDX-FileCopyrightText: 1999 Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com> 0009 SPDX-FileCopyrightText: 1999 Preston Brown <pbrown@kde.org> 0010 0011 Completely re-designed: 0012 SPDX-FileCopyrightText: 2000, 2001 Dawit Alemayehu <adawit@kde.org> 0013 0014 SPDX-License-Identifier: LGPL-2.0-or-later 0015 */ 0016 0017 #ifndef KLINEEDIT_H 0018 #define KLINEEDIT_H 0019 0020 #include <kcompletion.h> 0021 #include <kcompletion_export.h> 0022 #include <kcompletionbase.h> 0023 0024 #include <QLineEdit> 0025 #include <memory> 0026 0027 class QAction; 0028 class QMenu; 0029 class KCompletionBox; 0030 class QUrl; 0031 class KLineEditPrivate; 0032 0033 /** 0034 * @class KLineEdit klineedit.h KLineEdit 0035 * 0036 * An enhanced QLineEdit widget for inputting text. 0037 * 0038 * \b Detail \n 0039 * 0040 * This widget inherits from QLineEdit and implements the following 0041 * additional functionalities: 0042 * @li a completion object that provides both automatic and manual text 0043 * completion as well as multiple match iteration features 0044 * @li configurable key-bindings to activate these features 0045 * @li a popup-menu item that can be used to allow the user to set text 0046 * completion modes on the fly based on their preference 0047 * 0048 * To support these features KLineEdit also emits a few more additional 0049 * signals: 0050 * @li @c completion(const QString &): this signal can be connected to 0051 * a slot that will assist the user in filling out the remaining text 0052 * @li @c textRotation(KeyBindingType): this signal is intended to be 0053 * used to iterate through the list of all possible matches whenever 0054 * there is more than one match for the entered text 0055 * @li @c returnKeyPressed(const QString &): this signal provides the 0056 * current text in the widget as its argument whenever appropriate (this 0057 * is in addition to the @c QLineEdit::returnPressed() signal which KLineEdit 0058 * inherits from QLineEdit). 0059 * 0060 * This widget by default creates a completion object when you invoke 0061 * the @c completionObject(bool) member function for the first time or 0062 * use @c setCompletionObject(KCompletion *, bool) to assign your own 0063 * completion object. Additionally, to make this widget more functional, 0064 * KLineEdit will by default handle the text rotation and completion 0065 * events internally when a completion object is created through either one 0066 * of the methods mentioned above. If you do not need this functionality, 0067 * simply use @c KCompletionBase::setHandleSignals(bool) or set the boolean 0068 * parameter in the above functions to false. 0069 * 0070 * The default key-bindings for completion and rotation is determined 0071 * from the global settings in KStandardShortcut. These values, however, 0072 * can be overridden locally by invoking @c KCompletionBase::setKeyBinding(). 0073 * The values can easily be reverted back to the default setting, by simply 0074 * calling @c useGlobalSettings(). An alternate method would be to default 0075 * individual key-bindings by using setKeyBinding() with the default 0076 * second argument. 0077 * 0078 * If @c EchoMode for this widget is set to something other than @c QLineEdit::Normal, 0079 * the completion mode will always be defaulted to CompletionNone. 0080 * This is done purposefully to guard against protected entries, such as 0081 * passwords, being cached in KCompletion's list. Hence, if the @c EchoMode 0082 * is not @c QLineEdit::Normal, the completion mode is automatically disabled. 0083 * 0084 * A read-only KLineEdit will have the same background color as a disabled 0085 * KLineEdit, but its foreground color will be the one used for the read-write 0086 * mode. This differs from QLineEdit's implementation and is done to give visual 0087 * distinction between the three different modes: disabled, read-only, and read-write. 0088 * 0089 * @b Usage 0090 * 0091 * To enable the basic completion feature: 0092 * 0093 * @code 0094 * KLineEdit *edit = new KLineEdit(this); 0095 * KCompletion *comp = edit->completionObject(); 0096 * // Connect to the Return pressed signal - optional 0097 * connect(edit, &KLineEdit::returnKeyPressed, comp, [this](const QString &text) { addItem(text); }); 0098 * @endcode 0099 * 0100 * To use a customized completion object or your own completion object: 0101 * 0102 * @code 0103 * KLineEdit *edit = new KLineEdit(this); 0104 * KUrlCompletion *comp = new KUrlCompletion(); 0105 * edit->setCompletionObject(comp); 0106 * // Connect to the return pressed signal - optional 0107 * connect(edit, &KLineEdit::returnKeyPressed, comp, [this](const QString &text) { addItem(text); }); 0108 * @endcode 0109 * 0110 * Note if you specify your own completion object you have to either delete 0111 * it when you don't need it anymore, or you can tell KLineEdit to delete it 0112 * for you: 0113 * @code 0114 * edit->setAutoDeleteCompletionObject(true); 0115 * @endcode 0116 * 0117 * <b>Miscellaneous function calls :</b>\n 0118 * 0119 * @code 0120 * // Tell the widget to not handle completion and iteration automatically 0121 * edit->setHandleSignals(false); 0122 * 0123 * // Set your own key-bindings for a text completion mode 0124 * edit->setKeyBinding(KCompletionBase::TextCompletion, Qt::End); 0125 * 0126 * // Hide the context (popup) menu 0127 * edit->setContextMenuPolicy(Qt::NoContextMenu); 0128 * 0129 * // Default the key-bindings back to the default system settings 0130 * edit->useGlobalKeyBindings(); 0131 * @endcode 0132 * 0133 * @image html klineedit.png "KLineEdit widgets with clear-button" 0134 * 0135 * @author Dawit Alemayehu <adawit@kde.org> 0136 */ 0137 0138 class KCOMPLETION_EXPORT KLineEdit : public QLineEdit, public KCompletionBase // krazy:exclude=qclasses 0139 { 0140 friend class KComboBox; 0141 friend class KLineEditStyle; 0142 0143 Q_OBJECT 0144 Q_DECLARE_PRIVATE(KLineEdit) 0145 #if KCOMPLETION_BUILD_DEPRECATED_SINCE(4, 5) 0146 Q_PROPERTY(bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled) 0147 #endif 0148 #if KCOMPLETION_BUILD_DEPRECATED_SINCE(5, 0) 0149 Q_PROPERTY(bool urlDropsEnabled READ urlDropsEnabled WRITE setUrlDropsEnabled) 0150 #endif 0151 Q_PROPERTY(bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey) 0152 Q_PROPERTY(bool squeezedTextEnabled READ isSqueezedTextEnabled WRITE setSqueezedTextEnabled) 0153 #if KCOMPLETION_BUILD_DEPRECATED_SINCE(5, 0) 0154 Q_PROPERTY(QString clickMessage READ clickMessage WRITE setClickMessage) 0155 #endif 0156 #if KCOMPLETION_BUILD_DEPRECATED_SINCE(5, 46) 0157 Q_PROPERTY(bool showClearButton READ isClearButtonShown WRITE setClearButtonShown) 0158 #endif 0159 #if KCOMPLETION_BUILD_DEPRECATED_SINCE(5, 83) 0160 Q_PROPERTY(bool passwordMode READ passwordMode WRITE setPasswordMode) 0161 #endif 0162 0163 public: 0164 /** 0165 * Constructs a KLineEdit object with a default text, a parent, 0166 * and a name. 0167 * 0168 * @param string Text to be shown in the edit widget. 0169 * @param parent The parent widget of the line edit. 0170 */ 0171 explicit KLineEdit(const QString &string, QWidget *parent = nullptr); 0172 0173 /** 0174 * Constructs a line edit 0175 * @param parent The parent widget of the line edit. 0176 */ 0177 explicit KLineEdit(QWidget *parent = nullptr); 0178 0179 /** 0180 * Destructor. 0181 */ 0182 ~KLineEdit() override; 0183 0184 /** 0185 * Sets @p url into the lineedit. It uses QUrl::toDisplayString() so 0186 * that the url is properly decoded for displaying. 0187 */ 0188 void setUrl(const QUrl &url); 0189 0190 /** 0191 * Reimplemented from KCompletionBase for internal reasons. 0192 * 0193 * This function is re-implemented in order to make sure that 0194 * the EchoMode is acceptable before we set the completion mode. 0195 * 0196 * See KCompletionBase::setCompletionMode 0197 */ 0198 void setCompletionMode(KCompletion::CompletionMode mode) override; 0199 0200 /** 0201 * Disables completion modes by making them non-checkable. 0202 * 0203 * The context menu allows to change the completion mode. 0204 * This method allows to disable some modes. 0205 */ 0206 void setCompletionModeDisabled(KCompletion::CompletionMode mode, bool disable = true); 0207 0208 #if KCOMPLETION_BUILD_DEPRECATED_SINCE(4, 5) 0209 /** 0210 * Enables/disables the popup (context) menu. 0211 * 0212 * This method only works if this widget is editable, i.e. read-write and 0213 * allows you to enable/disable the context menu. It does nothing if invoked 0214 * for a none-editable combo-box. 0215 * 0216 * By default, the context menu is created if this widget is editable. 0217 * Call this function with the argument set to false to disable the popup 0218 * menu. 0219 * 0220 * @param showMenu If @c true, show the context menu. 0221 * @deprecated since 4.5, use setContextMenuPolicy instead 0222 */ 0223 KCOMPLETION_DEPRECATED_VERSION(4, 5, "Use QWidget::setContextMenuPolicy(Qt::ContextMenuPolicy)") 0224 virtual void setContextMenuEnabled(bool showMenu); 0225 #endif 0226 0227 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(4, 5) 0228 /** 0229 * Returns @c true when the context menu is enabled. 0230 * @deprecated since 4.5, use contextMenuPolicy instead 0231 */ 0232 KCOMPLETION_DEPRECATED_VERSION(4, 5, "Use QWidget::contextMenuPolicy()") 0233 bool isContextMenuEnabled() const; 0234 #endif 0235 0236 /** 0237 * Enables/Disables handling of URL drops. If enabled and the user 0238 * drops an URL, the decoded URL will be inserted. Otherwise the default 0239 * behavior of QLineEdit is used, which inserts the encoded URL. 0240 * Call setUrlDropsEnabled(false) if you need dropEvent to be called in a KLineEdit subclass. 0241 * 0242 * @param enable If @c true, insert decoded URLs 0243 */ 0244 void setUrlDropsEnabled(bool enable); // KF6: remove it and don't create LineEditUrlDropEventFilter by default. 0245 0246 /** 0247 * Returns @c true when decoded URL drops are enabled 0248 */ 0249 bool urlDropsEnabled() const; 0250 0251 /** 0252 * By default, KLineEdit recognizes @c Key_Return and @c Key_Enter and emits 0253 * the returnPressed() signals, but it also lets the event pass, 0254 * for example causing a dialog's default-button to be called. 0255 * 0256 * Call this method with @p trap = @c true to make @c KLineEdit stop these 0257 * events. The signals will still be emitted of course. 0258 * 0259 * @see trapReturnKey() 0260 */ 0261 void setTrapReturnKey(bool trap); 0262 0263 /** 0264 * @returns @c true if keyevents of @c Key_Return or 0265 * @c Key_Enter will be stopped or if they will be propagated. 0266 * 0267 * @see setTrapReturnKey () 0268 */ 0269 bool trapReturnKey() const; 0270 0271 /** 0272 * This method will create a completion-box if none is there, yet. 0273 * 0274 * @param create Set this to false if you don't want the box to be created 0275 * i.e. to test if it is available. 0276 * @returns the completion-box, that is used in completion mode 0277 * CompletionPopup. 0278 */ 0279 virtual KCompletionBox *completionBox(bool create = true); 0280 0281 /** 0282 * Reimplemented for internal reasons, the API is not affected. 0283 */ 0284 void setCompletionObject(KCompletion *, bool handle = true) override; 0285 0286 /** 0287 * Reimplemented for internal reasons, the API is not affected. 0288 */ 0289 virtual void copy() const; 0290 0291 /** 0292 * Enable text squeezing whenever the supplied text is too long. 0293 * Only works for "read-only" mode. 0294 * 0295 * Note that once text squeezing is enabled, QLineEdit::text() 0296 * and QLineEdit::displayText() return the squeezed text. If 0297 * you want the original text, use @ref originalText. 0298 * 0299 * @see QLineEdit 0300 */ 0301 void setSqueezedTextEnabled(bool enable); 0302 0303 /** 0304 * Returns true if text squeezing is enabled. 0305 * This is only valid when the widget is in read-only mode. 0306 */ 0307 bool isSqueezedTextEnabled() const; 0308 0309 /** 0310 * Returns the original text if text squeezing is enabled. 0311 * If the widget is not in "read-only" mode, this function 0312 * returns the same thing as QLineEdit::text(). 0313 * 0314 * @see QLineEdit 0315 */ 0316 QString originalText() const; 0317 0318 /** 0319 * Returns the text as given by the user (i.e. not autocompleted) 0320 * if the widget has autocompletion disabled, this function 0321 * returns the same as QLineEdit::text(). 0322 * @since 4.2.2 0323 */ 0324 QString userText() const; 0325 0326 /** 0327 * Set the completion-box to be used in completion mode 0328 * CompletionPopup. 0329 * This will do nothing if a completion-box already exists. 0330 * 0331 * @param box The KCompletionBox to set 0332 */ 0333 void setCompletionBox(KCompletionBox *box); 0334 0335 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 0) 0336 /** 0337 * This makes the line edit display a grayed-out hinting text as long as 0338 * the user didn't enter any text. It is often used as indication about 0339 * the purpose of the line edit. 0340 * @deprecated since 5.0, use QLineEdit::setPlaceholderText instead. 0341 */ 0342 KCOMPLETION_DEPRECATED_VERSION(5, 0, "Use QLineEdit::setPlaceholderText(const QString&)") 0343 void setClickMessage(const QString &msg); 0344 #endif 0345 0346 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 0) 0347 /** 0348 * @return the message set with setClickMessage 0349 * @deprecated since 5.0, use QLineEdit::placeholderText instead. 0350 */ 0351 KCOMPLETION_DEPRECATED_VERSION(5, 0, "Use QLineEdit::placeholderText()") 0352 QString clickMessage() const; 0353 #endif 0354 0355 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 46) 0356 /** 0357 * This makes the line edit display an icon on one side of the line edit 0358 * which, when clicked, clears the contents of the line edit. 0359 * This is useful for such things as location or search bars. 0360 * 0361 * @deprecated since 5.46 Use QLineEdit::setClearButtonEnabled 0362 */ 0363 KCOMPLETION_DEPRECATED_VERSION(5, 46, "Use QLineEdit::setClearButtonEnabled(bool)") 0364 void setClearButtonShown(bool show); 0365 #endif 0366 0367 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 46) 0368 /** 0369 * @return whether or not the clear button is shown 0370 * 0371 * @deprecated since 5.46 Use QLineEdit::isClearButtonEnabled 0372 */ 0373 KCOMPLETION_DEPRECATED_VERSION(5, 46, "Use QLineEdit::isClearButtonEnabled()") 0374 bool isClearButtonShown() const; 0375 #endif 0376 0377 /** 0378 * @return the size used by the clear button 0379 * @since 4.1 0380 */ 0381 QSize clearButtonUsedSize() const; 0382 0383 /** 0384 * Do completion now. This is called automatically when typing a key for instance. 0385 * Emits completion() and/or calls makeCompletion(), depending on 0386 * emitSignals and handleSignals. 0387 * 0388 * @since 4.2.1 0389 */ 0390 void doCompletion(const QString &text); 0391 0392 Q_SIGNALS: 0393 /** 0394 * Emitted whenever the completion box is activated. 0395 */ 0396 void completionBoxActivated(const QString &); 0397 0398 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 81) 0399 /** 0400 * Emitted when the user presses the Return or Enter key. 0401 * 0402 * The argument is the current text. Note that this 0403 * signal is @em not emitted if the widget's @c EchoMode is set to 0404 * QLineEdit::EchoMode. 0405 * 0406 * @deprecated since 5.81, use the KLineEdit::returnKeyPressed(const QString &) signal instead 0407 */ 0408 KCOMPLETION_DEPRECATED_VERSION(5, 81, "Use the KLineEdit::returnKeyPressed(const QString &) signal instead") 0409 void returnPressed(const QString &text); // clazy:exclude=overloaded-signal 0410 #endif 0411 0412 /** 0413 * Emitted when the user presses the Return or Enter key. 0414 * 0415 * The argument is the current text. Note that this signal is @em not emitted 0416 * if the widget's @c EchoMode is set to QLineEdit::EchoMode. 0417 * 0418 * @since 5.81 0419 */ 0420 void returnKeyPressed(const QString &text); 0421 0422 /** 0423 * Emitted when the completion key is pressed. 0424 * 0425 * Please note that this signal is @em not emitted if the 0426 * completion mode is set to @c CompletionNone or @c EchoMode is 0427 * @em normal. 0428 */ 0429 void completion(const QString &); 0430 0431 /** 0432 * Emitted when the shortcut for substring completion is pressed. 0433 */ 0434 void substringCompletion(const QString &); 0435 0436 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(4, 5) 0437 /** 0438 * Emitted when the text is changed NOT by the suggested autocompletion: 0439 * either when the user is physically typing keys, or when the text is changed programmatically, 0440 * for example, by calling setText(). 0441 * But not when automatic completion changes the text temporarily. 0442 * 0443 * @since 4.2.2 0444 * @deprecated since 4.5. You probably want to connect to textEdited() instead, 0445 * which is emitted whenever the text is actually changed by the user 0446 * (by typing or accepting autocompletion), without side effects from 0447 * suggested autocompletion either. userTextChanged isn't needed anymore. 0448 */ 0449 KCOMPLETION_DEPRECATED_VERSION(4, 5, "Use QLineEdit::textEdited(const QString&)") 0450 QT_MOC_COMPAT void userTextChanged(const QString &); 0451 #endif 0452 0453 /** 0454 * Emitted when the text rotation key-bindings are pressed. 0455 * 0456 * The argument indicates which key-binding was pressed. 0457 * In KLineEdit's case this can be either one of two values: 0458 * PrevCompletionMatch or NextCompletionMatch. See 0459 * KCompletionBase::setKeyBinding for details. 0460 * 0461 * Note that this signal is @em not emitted if the completion 0462 * mode is set to @c CompletionNone or @c echoMode() is @em not normal. 0463 */ 0464 void textRotation(KCompletionBase::KeyBindingType); 0465 0466 /** 0467 * Emitted when the user changed the completion mode by using the 0468 * popupmenu. 0469 */ 0470 void completionModeChanged(KCompletion::CompletionMode); 0471 0472 /** 0473 * Emitted before the context menu is displayed. 0474 * 0475 * The signal allows you to add your own entries into the 0476 * the context menu that is created on demand. 0477 * 0478 * NOTE: Do not store the pointer to the QMenu 0479 * provided through since it is created and deleted 0480 * on demand. 0481 * 0482 * @param contextMenu the context menu about to be displayed 0483 */ 0484 void aboutToShowContextMenu(QMenu *contextMenu); 0485 0486 /** 0487 * Emitted when the user clicked on the clear button 0488 */ 0489 void clearButtonClicked(); 0490 0491 public Q_SLOTS: 0492 0493 /** 0494 * Sets the lineedit to read-only. Similar to QLineEdit::setReadOnly 0495 * but also takes care of the background color, and the clear button. 0496 */ 0497 virtual void setReadOnly(bool); 0498 0499 /** 0500 * Iterates through all possible matches of the completed text or 0501 * the history list. 0502 * 0503 * This function simply iterates over all possible matches in case 0504 * multiple matches are found as a result of a text completion request. 0505 * It will have no effect if only a single match is found. 0506 * 0507 * @param type The key-binding invoked. 0508 */ 0509 void rotateText(KCompletionBase::KeyBindingType type); 0510 0511 /** 0512 * See KCompletionBase::setCompletedText. 0513 */ 0514 void setCompletedText(const QString &) override; 0515 0516 /** 0517 * Same as the above function except it allows you to temporarily 0518 * turn off text completion in CompletionPopupAuto mode. 0519 * 0520 * 0521 * @param items list of completion matches to be shown in the completion box. 0522 * @param autoSuggest true if you want automatic text completion (suggestion) enabled. 0523 */ 0524 void setCompletedItems(const QStringList &items, bool autoSuggest = true) override; 0525 0526 /** 0527 * Squeezes @p text into the line edit. 0528 * This can only be used with read-only line-edits. 0529 */ 0530 void setSqueezedText(const QString &text); 0531 0532 /** 0533 * Reimplemented to enable text squeezing. API is not affected. 0534 */ 0535 virtual void setText(const QString &); 0536 0537 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 83) 0538 /** 0539 * @brief set the line edit in password mode. 0540 * this change the EchoMode according to KDE preferences. 0541 * @param passwordMode true to set in password mode 0542 * 0543 * @deprecated Since 5.83, use KPasswordLineEdit or QLineEdit::setEchoMode(QLineEdit::EchoMode). 0544 */ 0545 KCOMPLETION_DEPRECATED_VERSION(5, 83, "Use KPasswordLineEdit or QLineEdit::setEchoMode(QLineEdit::EchoMode)") 0546 void setPasswordMode(bool passwordMode = true); 0547 #endif 0548 0549 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 83) 0550 /** 0551 * @return returns true if the lineedit is set to password mode echoing 0552 * 0553 * @deprecated Since 5.83, see setPasswordMode(bool) 0554 */ 0555 KCOMPLETION_DEPRECATED_VERSION(5, 83, "See API docs") 0556 bool passwordMode() const; 0557 #endif 0558 0559 protected Q_SLOTS: 0560 0561 /** 0562 * Completes the remaining text with a matching one from 0563 * a given list. 0564 */ 0565 virtual void makeCompletion(const QString &); 0566 0567 /** 0568 * Resets the current displayed text. 0569 * Call this function to revert a text completion if the user 0570 * cancels the request. Mostly applies to popup completions. 0571 */ 0572 void userCancelled(const QString &cancelText); 0573 0574 protected: 0575 /** 0576 * Reimplemented for internal reasons. API not affected. 0577 */ 0578 bool event(QEvent *) override; 0579 0580 /** 0581 * Reimplemented for internal reasons. API not affected. 0582 * 0583 * See QLineEdit::resizeEvent(). 0584 */ 0585 void resizeEvent(QResizeEvent *) override; 0586 0587 /** 0588 * Reimplemented for internal reasons. API not affected. 0589 * 0590 * See QLineEdit::keyPressEvent(). 0591 */ 0592 void keyPressEvent(QKeyEvent *) override; 0593 0594 /** 0595 * Reimplemented for internal reasons. API not affected. 0596 * 0597 * See QLineEdit::mousePressEvent(). 0598 */ 0599 void mousePressEvent(QMouseEvent *) override; 0600 0601 /** 0602 * Reimplemented for internal reasons. API not affected. 0603 * 0604 * See QLineEdit::mouseReleaseEvent(). 0605 */ 0606 void mouseReleaseEvent(QMouseEvent *) override; 0607 0608 /** 0609 * Reimplemented for internal reasons. API not affected. 0610 * 0611 * See QWidget::mouseDoubleClickEvent(). 0612 */ 0613 void mouseDoubleClickEvent(QMouseEvent *) override; 0614 0615 /** 0616 * Reimplemented for internal reasons. API not affected. 0617 * 0618 * See QLineEdit::contextMenuEvent(). 0619 */ 0620 void contextMenuEvent(QContextMenuEvent *) override; 0621 0622 /** 0623 * Reimplemented for internal reasons. API not affected. 0624 * 0625 * See QLineEdit::createStandardContextMenu(). 0626 */ 0627 QMenu *createStandardContextMenu(); 0628 0629 /** 0630 * This function simply sets the lineedit text and 0631 * highlights the text appropriately if the boolean 0632 * value is set to true. 0633 * 0634 * @param text 0635 * @param marked 0636 */ 0637 virtual void setCompletedText(const QString & /*text*/, bool /*marked*/); 0638 0639 /** 0640 * Sets the widget in userSelection mode or in automatic completion 0641 * selection mode. This changes the colors of selections. 0642 */ 0643 void setUserSelection(bool userSelection); 0644 0645 /** 0646 * Whether in current state text should be auto-suggested 0647 */ 0648 bool autoSuggest() const; 0649 0650 void paintEvent(QPaintEvent *ev) override; 0651 0652 private: 0653 std::unique_ptr<KLineEditPrivate> const d_ptr; 0654 }; 0655 0656 #endif