• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • widgets
klineedit.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2 
3  This class was originally inspired by Torben Weis'
4  fileentry.cpp for KFM II.
5 
6  Copyright (C) 1997 Sven Radej <sven.radej@iname.com>
7  Copyright (c) 1999 Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com>
8  Copyright (c) 1999 Preston Brown <pbrown@kde.org>
9 
10  Completely re-designed:
11  Copyright (c) 2000,2001 Dawit Alemayehu <adawit@kde.org>
12 
13  This library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU Lesser General Public
15  License (LGPL) as published by the Free Software Foundation;
16  either version 2 of the License, or (at your option) any later
17  version.
18 
19  This library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  Lesser General Public License for more details.
23 
24  You should have received a copy of the GNU Lesser General Public License
25  along with this library; see the file COPYING.LIB. If not, write to
26  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27  Boston, MA 02110-1301, USA.
28 */
29 
30 #ifndef KLINEEDIT_H
31 #define KLINEEDIT_H
32 
33 #include <QtGui/QLineEdit>
34 
35 #include <kcompletion.h>
36 
37 class QAction;
38 class QMenu;
39 class KCompletionBox;
40 class KUrl;
41 class KLineEditPrivate;
42 
149 class KDEUI_EXPORT KLineEdit : public QLineEdit, public KCompletionBase //krazy:exclude=qclasses
150 {
151  friend class KComboBox;
152  friend class KLineEditStyle;
153 
154  Q_OBJECT
155 #ifndef KDE_NO_DEPRECATED
156  Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
157 #endif
158  Q_PROPERTY( bool urlDropsEnabled READ urlDropsEnabled WRITE setUrlDropsEnabled )
159  Q_PROPERTY( bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey )
160  Q_PROPERTY( bool squeezedTextEnabled READ isSqueezedTextEnabled WRITE setSqueezedTextEnabled )
161  Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
162  Q_PROPERTY( bool showClearButton READ isClearButtonShown WRITE setClearButtonShown )
163  Q_PROPERTY( bool passwordMode READ passwordMode WRITE setPasswordMode )
164 
165 public:
166 
174  explicit KLineEdit( const QString &string, QWidget *parent = 0 );
175 
180  explicit KLineEdit( QWidget *parent = 0 );
181 
185  virtual ~KLineEdit ();
186 
191  void setUrl( const KUrl& url );
192 
201  virtual void setCompletionMode( KGlobalSettings::Completion mode );
202 
209  void setCompletionModeDisabled( KGlobalSettings::Completion mode, bool disable = true );
210 
225 #ifndef KDE_NO_DEPRECATED
226  virtual KDE_DEPRECATED void setContextMenuEnabled( bool showMenu );
227 #endif
228 
233 #ifndef KDE_NO_DEPRECATED
234  KDE_DEPRECATED bool isContextMenuEnabled() const;
235 #endif
236 
244  void setUrlDropsEnabled( bool enable );
245 
249  bool urlDropsEnabled() const;
250 
261  void setTrapReturnKey( bool trap );
262 
269  bool trapReturnKey() const;
270 
279  KCompletionBox * completionBox( bool create = true ); // KDE5 TODO: make virtual, so konq can reimplement i
280 
284  virtual void setCompletionObject( KCompletion *, bool hsig = true );
285 
289  virtual void copy() const;
290 
301  void setSqueezedTextEnabled( bool enable );
302 
307  bool isSqueezedTextEnabled() const;
308 
316  QString originalText() const;
317 
324  QString userText() const;
325 
333  void setCompletionBox( KCompletionBox *box );
334 
340  void setClickMessage( const QString &msg );
341 
345  QString clickMessage() const;
346 
352  void setClearButtonShown(bool show);
353 
357  bool isClearButtonShown() const;
358 
363  QSize clearButtonUsedSize() const;
364 
372  void doCompletion(const QString& txt);
373 
374 Q_SIGNALS:
375 
379  void completionBoxActivated (const QString &);
380 
388  void returnPressed( const QString& );
389 
397  void completion( const QString& );
398 
402  void substringCompletion( const QString& );
403 
416 #ifndef KDE_NO_DEPRECATED
417  QT_MOC_COMPAT void userTextChanged( const QString & );
418 #endif
419 
431  void textRotation( KCompletionBase::KeyBindingType );
432 
437  void completionModeChanged( KGlobalSettings::Completion );
438 
451  void aboutToShowContextMenu(QMenu* menu);
452 
456  void clearButtonClicked();
457 
458 public Q_SLOTS:
459 
464  virtual void setReadOnly(bool);
465 
476  void rotateText( KCompletionBase::KeyBindingType type );
477 
481  virtual void setCompletedText( const QString& );
482 
491  void setCompletedItems( const QStringList& items, bool autoSuggest = true );
492 
497  virtual void clear(); // ### KDE 5: check if still required
498 
503  void setSqueezedText( const QString &text);
504 
508  virtual void setText ( const QString& );
509 
515  void setPasswordMode( bool b = true );
516 
520  bool passwordMode( ) const;
521 
522 
523 protected Q_SLOTS:
524 
529  virtual void makeCompletion( const QString& );
530 
536  void userCancelled(const QString & cancelText);
537 
538 protected:
539 
543  virtual bool event( QEvent * );
544 
550  virtual void resizeEvent( QResizeEvent * );
551 
557  virtual void keyPressEvent( QKeyEvent * );
558 
564  virtual void mousePressEvent( QMouseEvent * );
565 
571  virtual void mouseReleaseEvent( QMouseEvent * );
572 
578  virtual void mouseDoubleClickEvent( QMouseEvent * );
579 
585  virtual void contextMenuEvent( QContextMenuEvent * );
586 
592  QMenu* createStandardContextMenu();
593 
599  virtual void dropEvent( QDropEvent * );
600 
609  virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ );
610 
611 
616  void setUserSelection( bool userSelection );
617 
621  virtual void create( WId = 0, bool initializeWindow = true,
622  bool destroyOldWindow = true );
623 
627  bool autoSuggest() const;
628 
629  virtual void paintEvent( QPaintEvent *ev );
630 
631  virtual void focusInEvent( QFocusEvent *ev );
632 
633  virtual void focusOutEvent( QFocusEvent *ev );
634 
635 private Q_SLOTS:
636  void completionMenuActivated( QAction *act );
637  void tripleClickTimeout(); // resets possibleTripleClick
638  void slotRestoreSelectionColors();
639  void _k_slotCompletionBoxTextChanged( const QString& text );
640 
644  void updateClearButtonIcon(const QString&);
645 
646 private:
647 
648 
652  void init();
653 
654  bool copySqueezedText( bool clipboard ) const;
655 
660  void setSqueezedText ();
661 
665  void updateClearButton();
666 
667 private:
668  friend class KLineEditPrivate;
669  KLineEditPrivate *const d;
670 
671  Q_PRIVATE_SLOT( d, void _k_slotSettingsChanged( int category ) )
672  Q_PRIVATE_SLOT( d, void _k_textChanged(const QString&) )
673 };
674 
675 #endif
QLineEdit::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *event)
QEvent
QResizeEvent
QWidget
QLineEdit::setText
void setText(const QString &)
KCompletionBox
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
Definition: kcompletionbox.h:43
KStandardAction::copy
KAction * copy(const QObject *recvr, const char *slot, QObject *parent)
Copy the selected area into the clipboard.
Definition: kstandardaction.cpp:299
QLineEdit::event
virtual bool event(QEvent *e)
KStandardShortcut::substringCompletion
const KShortcut & substringCompletion()
Find a string within another string or list of strings.
Definition: kstandardshortcut.cpp:368
QLineEdit::createStandardContextMenu
QMenu * createStandardContextMenu()
QMouseEvent
KCompletionBase::setCompletedText
virtual void setCompletedText(const QString &text)=0
A pure virtual function that must be implemented by all inheriting classes.
QLineEdit::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event)
KUrl
QLineEdit::setReadOnly
void setReadOnly(bool)
QContextMenuEvent
QDropEvent
KCompletion
A generic class for completing QStrings.
Definition: kcompletion.h:130
KStandardAction::clear
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
Clear the content of the focus widget.
Definition: kstandardaction.cpp:314
QLineEdit::focusOutEvent
virtual void focusOutEvent(QFocusEvent *e)
QString
QLineEdit::paintEvent
virtual void paintEvent(QPaintEvent *)
QStringList
QLineEdit::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *e)
kcompletion.h
QMenu
KGlobalSettings
Access the KDE global configuration.
Definition: kglobalsettings.h:58
QSize
KCompletionBase
An abstract base class for adding a completion feature into widgets.
Definition: kcompletion.h:645
QLineEdit::returnPressed
void returnPressed()
QKeyEvent
QLineEdit::focusInEvent
virtual void focusInEvent(QFocusEvent *e)
KLineEdit
An enhanced QLineEdit widget for inputting text.
Definition: klineedit.h:149
QAction
KStandardAction::create
KAction * create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
Creates an action corresponding to one of the KStandardAction::StandardAction actions, which is connected to the given object and slot, and is owned by parent.
Definition: kstandardaction.cpp:82
KComboBox
An enhanced combo box.
Definition: kcombobox.h:148
KGlobalSettings::Completion
Completion
This enum describes the completion mode used for by the KCompletion class.
Definition: kglobalsettings.h:179
KCompletionBase::setCompletionObject
virtual void setCompletionObject(KCompletion *compObj, bool hsig=true)
Sets up the completion object to be used.
Definition: kcompletionbase.cpp:109
KCompletionBase::KeyBindingType
KeyBindingType
Constants that represent the items whose short-cut key-binding is programmable.
Definition: kcompletion.h:653
QLineEdit
QPaintEvent
QWidget::resizeEvent
virtual void resizeEvent(QResizeEvent *event)
KCompletionBase::setCompletedItems
virtual void setCompletedItems(const QStringList &items, bool autoSuggest=true)=0
A pure virtual function that must be implemented by all inheriting classes.
QLineEdit::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QMouseEvent *e)
QFocusEvent
KStandardShortcut::completion
const KShortcut & completion()
Complete text in input widgets.
Definition: kstandardshortcut.cpp:363
QLineEdit::mousePressEvent
virtual void mousePressEvent(QMouseEvent *e)
QLineEdit::dropEvent
virtual void dropEvent(QDropEvent *e)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal