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

KDEUI

  • 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
37class QAction;
38class QMenu;
39class KCompletionBox;
40class KUrl;
41class KLineEditPrivate;
42
149class 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
165public:
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
374Q_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
458public 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
523protected Q_SLOTS:
524
529 virtual void makeCompletion( const QString& );
530
536 void userCancelled(const QString & cancelText);
537
538protected:
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
635private 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
646private:
647
648
652 void init();
653
654 bool copySqueezedText( bool clipboard ) const;
655
660 void setSqueezedText ();
661
665 void updateClearButton();
666
667private:
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
KComboBox
An enhanced combo box.
Definition: kcombobox.h:149
KCompletionBase
An abstract base class for adding a completion feature into widgets.
Definition: kcompletion.h:646
KCompletionBase::KeyBindingType
KeyBindingType
Constants that represent the items whose short-cut key-binding is programmable.
Definition: kcompletion.h:653
KCompletionBox
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
Definition: kcompletionbox.h:44
KCompletion
A generic class for completing QStrings.
Definition: kcompletion.h:131
KGlobalSettings::Completion
Completion
This enum describes the completion mode used for by the KCompletion class.
Definition: kglobalsettings.h:179
KLineEdit
An enhanced QLineEdit widget for inputting text.
Definition: klineedit.h:150
KLineEdit::userTextChanged
QT_MOC_COMPAT void userTextChanged(const QString &)
Emitted when the text is changed NOT by the suggested autocompletion: either when the user is physica...
KLineEdit::aboutToShowContextMenu
void aboutToShowContextMenu(QMenu *menu)
Emitted before the context menu is displayed.
KLineEdit::returnPressed
void returnPressed(const QString &)
Emitted when the user presses the return key.
KLineEdit::textRotation
void textRotation(KCompletionBase::KeyBindingType)
Emitted when the text rotation key-bindings are pressed.
KLineEdit::completionBoxActivated
void completionBoxActivated(const QString &)
Emitted whenever the completion box is activated.
KLineEdit::completionModeChanged
void completionModeChanged(KGlobalSettings::Completion)
Emitted when the user changed the completion mode by using the popupmenu.
KLineEdit::clearButtonClicked
void clearButtonClicked()
Emitted when the user clicked on the clear button.
KLineEdit::completion
void completion(const QString &)
Emitted when the completion key is pressed.
KLineEdit::substringCompletion
void substringCompletion(const QString &)
Emitted when the shortcut for substring completion is pressed.
KUrl
QAction
QLineEdit
QMenu
QWidget
kcompletion.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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