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 <qlineedit.h>
00034 #include <kcompletion.h>
00035
00036 class QPopupMenu;
00037
00038 class KCompletionBox;
00039 class KURL;
00040
00145 class KDEUI_EXPORT KLineEdit : public QLineEdit, public KCompletionBase
00146 {
00147 friend class KComboBox;
00148
00149 Q_OBJECT
00150 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
00151 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
00152 Q_PROPERTY( bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey )
00153 Q_PROPERTY( bool enableSqueezedText READ isSqueezedTextEnabled WRITE setEnableSqueezedText )
00154
00155 Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
00156
00157 public:
00158
00167 KLineEdit( const QString &string, QWidget *parent, const char *name = 0 );
00168
00175 KLineEdit ( QWidget *parent=0, const char *name=0 );
00176
00180 virtual ~KLineEdit ();
00181
00186 void setURL( const KURL& url );
00187
00197 void cursorAtEnd() { end( false ); }
00198
00207 virtual void setCompletionMode( KGlobalSettings::Completion mode );
00208
00223 virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; }
00224
00228 bool isContextMenuEnabled() const { return m_bEnableMenu; }
00229
00237 void setURLDropsEnabled( bool enable );
00238
00242 bool isURLDropsEnabled() const;
00243
00254 void setTrapReturnKey( bool trap );
00255
00262 bool trapReturnKey() const;
00263
00268 virtual bool eventFilter( QObject *, QEvent * );
00269
00278 KCompletionBox * completionBox( bool create = true );
00279
00283 virtual void setCompletionObject( KCompletion *, bool hsig = true );
00284
00288 virtual void copy() const;
00289
00301 void setEnableSqueezedText( bool enable );
00302
00309 bool isSqueezedTextEnabled() const;
00310
00319 QString originalText() const;
00320
00329 void setCompletionBox( KCompletionBox *box );
00330
00337 void setClickMessage( const QString &msg );
00338
00343 QString clickMessage() const;
00344
00345 signals:
00346
00351 void completionBoxActivated (const QString &);
00352
00360 void returnPressed( const QString& );
00361
00369 void completion( const QString& );
00370
00374 void substringCompletion( const QString& );
00375
00388 void textRotation( KCompletionBase::KeyBindingType );
00389
00394 void completionModeChanged( KGlobalSettings::Completion );
00395
00408 void aboutToShowContextMenu( QPopupMenu * p );
00409
00410 public slots:
00411
00415 virtual void setReadOnly(bool);
00416
00427 void rotateText( KCompletionBase::KeyBindingType type );
00428
00432 virtual void setCompletedText( const QString& );
00433
00440 void setCompletedItems( const QStringList& items );
00441
00452 void setCompletedItems( const QStringList& items, bool autoSuggest );
00453
00458 virtual void clear();
00459
00465 void setSqueezedText( const QString &text);
00466
00470 virtual void setText ( const QString& );
00471
00472
00473 protected slots:
00474
00479 virtual void makeCompletion( const QString& );
00480
00484 void slotAboutToShow() {}
00485
00489 void slotCancelled() {}
00490
00496 void userCancelled(const QString & cancelText);
00497
00498 protected:
00499
00505 virtual void resizeEvent( QResizeEvent * );
00506
00512 virtual void keyPressEvent( QKeyEvent * );
00513
00519 virtual void mousePressEvent( QMouseEvent * );
00520
00526 virtual void mouseDoubleClickEvent( QMouseEvent * );
00527
00533 virtual void mouseReleaseEvent( QMouseEvent * );
00534
00540 virtual void contextMenuEvent( QContextMenuEvent * );
00541
00547 virtual QPopupMenu *createPopupMenu();
00548
00554 virtual void drawContents( QPainter *p );
00555
00561 virtual void dropEvent( QDropEvent * );
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571 virtual void setCompletedText( const QString& , bool );
00572
00573
00578 void setUserSelection( bool userSelection );
00579
00583 virtual void create( WId = 0, bool initializeWindow = true,
00584 bool destroyOldWindow = true );
00585
00591 virtual void focusInEvent( QFocusEvent* );
00592
00598 virtual void focusOutEvent( QFocusEvent* );
00599
00604 bool autoSuggest() const;
00605
00606 private slots:
00607 void completionMenuActivated( int id );
00608 void tripleClickTimeout();
00609 void slotRestoreSelectionColors();
00610 void setTextWorkaround( const QString& text );
00611
00612 private:
00613
00614
00615 enum MenuID
00616 {
00617 Default = 42,
00618 NoCompletion,
00619 AutoCompletion,
00620 ShellCompletion,
00621 PopupCompletion,
00622 ShortAutoCompletion,
00623 PopupAutoCompletion
00624 };
00625
00629 void init();
00630
00631 bool copySqueezedText( bool clipboard ) const;
00632
00637 bool overrideAccel (const QKeyEvent* e);
00638
00643 void setSqueezedText ();
00644
00645 bool m_bEnableMenu;
00646
00647 bool possibleTripleClick;
00648
00649 protected:
00650 virtual void virtual_hook( int id, void* data );
00651 private:
00652 class KLineEditPrivate;
00653 KLineEditPrivate *d;
00654 };
00655
00656 #endif