KDEUI
klineedit.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef KLINEEDIT_H
00031 #define KLINEEDIT_H
00032
00033 #include <QtGui/QLineEdit>
00034
00035 #include <kcompletion.h>
00036
00037 class QAction;
00038 class QMenu;
00039 class KCompletionBox;
00040 class KUrl;
00041 class KLineEditPrivate;
00042
00147 class KDEUI_EXPORT KLineEdit : public QLineEdit, public KCompletionBase
00148 {
00149 friend class KComboBox;
00150 friend class KLineEditStyle;
00151
00152 Q_OBJECT
00153 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
00154 Q_PROPERTY( bool urlDropsEnabled READ urlDropsEnabled WRITE setUrlDropsEnabled )
00155 Q_PROPERTY( bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey )
00156 Q_PROPERTY( bool squeezedTextEnabled READ isSqueezedTextEnabled WRITE setSqueezedTextEnabled )
00157 Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
00158 Q_PROPERTY( bool showClearButton READ isClearButtonShown WRITE setClearButtonShown )
00159 Q_PROPERTY( bool passwordMode READ passwordMode WRITE setPasswordMode )
00160
00161 public:
00162
00170 explicit KLineEdit( const QString &string, QWidget *parent = 0 );
00171
00176 explicit KLineEdit( QWidget *parent = 0 );
00177
00181 virtual ~KLineEdit ();
00182
00187 void setUrl( const KUrl& url );
00188
00197 virtual void setCompletionMode( KGlobalSettings::Completion mode );
00198
00205 void setCompletionModeDisabled( KGlobalSettings::Completion mode, bool disable = true );
00206
00222 virtual KDE_DEPRECATED void setContextMenuEnabled( bool showMenu );
00223
00228 KDE_DEPRECATED bool isContextMenuEnabled() const;
00229
00237 void setUrlDropsEnabled( bool enable );
00238
00242 bool urlDropsEnabled() const;
00243
00254 void setTrapReturnKey( bool trap );
00255
00262 bool trapReturnKey() const;
00263
00272 KCompletionBox * completionBox( bool create = true );
00273
00277 virtual void setCompletionObject( KCompletion *, bool hsig = true );
00278
00282 virtual void copy() const;
00283
00294 void setSqueezedTextEnabled( bool enable );
00295
00300 bool isSqueezedTextEnabled() const;
00301
00309 QString originalText() const;
00310
00318 void setCompletionBox( KCompletionBox *box );
00319
00325 void setClickMessage( const QString &msg );
00326
00330 QString clickMessage() const;
00331
00337 void setClearButtonShown(bool show);
00338
00342 bool isClearButtonShown() const;
00343
00348 QSize clearButtonUsedSize() const;
00349
00350 Q_SIGNALS:
00351
00355 void completionBoxActivated (const QString &);
00356
00364 void returnPressed( const QString& );
00365
00373 void completion( const QString& );
00374
00378 void substringCompletion( const QString& );
00379
00391 void textRotation( KCompletionBase::KeyBindingType );
00392
00397 void completionModeChanged( KGlobalSettings::Completion );
00398
00411 void aboutToShowContextMenu( QMenu * p );
00412
00416 void clearButtonClicked();
00417
00418 public Q_SLOTS:
00419
00423 virtual void setReadOnly(bool);
00424
00435 void rotateText( KCompletionBase::KeyBindingType type );
00436
00440 virtual void setCompletedText( const QString& );
00441
00450 void setCompletedItems( const QStringList& items, bool autoSuggest = true );
00451
00456 virtual void clear();
00457
00462 void setSqueezedText( const QString &text);
00463
00467 virtual void setText ( const QString& );
00468
00474 void setPasswordMode( bool b = true );
00475
00479 bool passwordMode( ) const;
00480
00481
00482 protected Q_SLOTS:
00483
00488 virtual void makeCompletion( const QString& );
00489
00495 void userCancelled(const QString & cancelText);
00496
00497 protected:
00498
00502 virtual bool event( QEvent * );
00503
00509 virtual void resizeEvent( QResizeEvent * );
00510
00516 virtual void keyPressEvent( QKeyEvent * );
00517
00523 virtual void mousePressEvent( QMouseEvent * );
00524
00530 virtual void mouseReleaseEvent( QMouseEvent * );
00531
00537 virtual void mouseDoubleClickEvent( QMouseEvent * );
00538
00544 virtual void contextMenuEvent( QContextMenuEvent * );
00545
00551 QMenu* createStandardContextMenu();
00552
00558 virtual void dropEvent( QDropEvent * );
00559
00568 virtual void setCompletedText( const QString& , bool );
00569
00570
00575 void setUserSelection( bool userSelection );
00576
00580 virtual void create( WId = 0, bool initializeWindow = true,
00581 bool destroyOldWindow = true );
00582
00586 bool autoSuggest() const;
00587
00588 virtual void paintEvent( QPaintEvent *ev );
00589
00590 virtual void focusInEvent( QFocusEvent *ev );
00591
00592 virtual void focusOutEvent( QFocusEvent *ev );
00593
00594 private Q_SLOTS:
00595 void completionMenuActivated( QAction *act );
00596 void tripleClickTimeout();
00597 void slotRestoreSelectionColors();
00598 void setTextWorkaround( const QString& text );
00599
00603 void updateClearButtonIcon(const QString&);
00604
00605 private:
00606
00607
00611 void init();
00612
00613 bool copySqueezedText( bool clipboard ) const;
00614
00619 void setSqueezedText ();
00620
00624 void updateClearButton();
00625
00626 private:
00627 friend class KLineEditPrivate;
00628 KLineEditPrivate *const d;
00629
00630 Q_PRIVATE_SLOT( d, void _k_slotSettingsChanged( int category ) )
00631 };
00632
00633 #endif