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
00317 QString userText() const;
00318
00326 void setCompletionBox( KCompletionBox *box );
00327
00333 void setClickMessage( const QString &msg );
00334
00338 QString clickMessage() const;
00339
00345 void setClearButtonShown(bool show);
00346
00350 bool isClearButtonShown() const;
00351
00356 QSize clearButtonUsedSize() const;
00357
00365 void doCompletion(const QString& txt);
00366
00367 Q_SIGNALS:
00368
00372 void completionBoxActivated (const QString &);
00373
00381 void returnPressed( const QString& );
00382
00390 void completion( const QString& );
00391
00395 void substringCompletion( const QString& );
00396
00401 void userTextChanged( const QString & );
00402
00414 void textRotation( KCompletionBase::KeyBindingType );
00415
00420 void completionModeChanged( KGlobalSettings::Completion );
00421
00434 void aboutToShowContextMenu( QMenu * p );
00435
00439 void clearButtonClicked();
00440
00441 public Q_SLOTS:
00442
00446 virtual void setReadOnly(bool);
00447
00458 void rotateText( KCompletionBase::KeyBindingType type );
00459
00463 virtual void setCompletedText( const QString& );
00464
00473 void setCompletedItems( const QStringList& items, bool autoSuggest = true );
00474
00479 virtual void clear();
00480
00485 void setSqueezedText( const QString &text);
00486
00490 virtual void setText ( const QString& );
00491
00497 void setPasswordMode( bool b = true );
00498
00502 bool passwordMode( ) const;
00503
00504
00505 protected Q_SLOTS:
00506
00511 virtual void makeCompletion( const QString& );
00512
00518 void userCancelled(const QString & cancelText);
00519
00520 protected:
00521
00525 virtual bool event( QEvent * );
00526
00532 virtual void resizeEvent( QResizeEvent * );
00533
00539 virtual void keyPressEvent( QKeyEvent * );
00540
00546 virtual void mousePressEvent( QMouseEvent * );
00547
00553 virtual void mouseReleaseEvent( QMouseEvent * );
00554
00560 virtual void mouseDoubleClickEvent( QMouseEvent * );
00561
00567 virtual void contextMenuEvent( QContextMenuEvent * );
00568
00574 QMenu* createStandardContextMenu();
00575
00581 virtual void dropEvent( QDropEvent * );
00582
00591 virtual void setCompletedText( const QString& , bool );
00592
00593
00598 void setUserSelection( bool userSelection );
00599
00603 virtual void create( WId = 0, bool initializeWindow = true,
00604 bool destroyOldWindow = true );
00605
00609 bool autoSuggest() const;
00610
00611 virtual void paintEvent( QPaintEvent *ev );
00612
00613 virtual void focusInEvent( QFocusEvent *ev );
00614
00615 virtual void focusOutEvent( QFocusEvent *ev );
00616
00617 private Q_SLOTS:
00618 void completionMenuActivated( QAction *act );
00619 void tripleClickTimeout();
00620 void slotRestoreSelectionColors();
00621 void setTextWorkaround( const QString& text );
00622
00626 void updateClearButtonIcon(const QString&);
00627
00628 private:
00629
00630
00634 void init();
00635
00636 bool copySqueezedText( bool clipboard ) const;
00637
00642 void setSqueezedText ();
00643
00647 void updateClearButton();
00648
00649 private:
00650 friend class KLineEditPrivate;
00651 KLineEditPrivate *const d;
00652
00653 Q_PRIVATE_SLOT( d, void _k_slotSettingsChanged( int category ) )
00654 Q_PRIVATE_SLOT( d, void _k_updateUserText(const QString&) )
00655 };
00656
00657 #endif