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 <tqlineedit.h>
00034 #include <kcompletion.h>
00035
00036 class TQPopupMenu;
00037
00038 class TDECompletionBox;
00039 class KURL;
00040
00145 class TDEUI_EXPORT KLineEdit : public TQLineEdit, public TDECompletionBase
00146 {
00147 friend class KComboBox;
00148
00149 Q_OBJECT
00150 TQ_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
00151 TQ_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
00152 TQ_PROPERTY( bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey )
00153 TQ_PROPERTY( bool enableSqueezedText READ isSqueezedTextEnabled WRITE setEnableSqueezedText )
00154
00155 TQ_PROPERTY( TQString clickMessage READ clickMessage WRITE setClickMessage )
00156
00157 public:
00158
00167 KLineEdit( const TQString &string, TQWidget *parent, const char *name = 0 );
00168
00175 KLineEdit ( TQWidget *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( TDEGlobalSettings::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( TQObject *, TQEvent * );
00269
00278 TDECompletionBox * completionBox( bool create = true );
00279
00283 virtual void setCompletionObject( TDECompletion *, bool hsig = true );
00284
00288 virtual void copy() const;
00289
00301 void setEnableSqueezedText( bool enable );
00302
00309 bool isSqueezedTextEnabled() const;
00310
00319 TQString originalText() const;
00320
00329 void setCompletionBox( TDECompletionBox *box );
00330
00337 void setClickMessage( const TQString &msg );
00338
00343 TQString clickMessage() const;
00344
00345 signals:
00346
00351 void completionBoxActivated (const TQString &);
00352
00360 void returnPressed( const TQString& );
00361
00369 void completion( const TQString& );
00370
00374 void substringCompletion( const TQString& );
00375
00388 void textRotation( TDECompletionBase::KeyBindingType );
00389
00394 void completionModeChanged( TDEGlobalSettings::Completion );
00395
00408 void aboutToShowContextMenu( TQPopupMenu * p );
00409
00410 public slots:
00411
00415 virtual void setReadOnly(bool);
00416
00427 void rotateText( TDECompletionBase::KeyBindingType type );
00428
00432 virtual void setCompletedText( const TQString& );
00433
00440 void setCompletedItems( const TQStringList& items );
00441
00452 void setCompletedItems( const TQStringList& items, bool autoSuggest );
00453
00458 virtual void clear();
00459
00465 void setSqueezedText( const TQString &text);
00466
00470 virtual void setText ( const TQString& );
00471
00472
00473 protected slots:
00474
00479 virtual void makeCompletion( const TQString& );
00480
00484 void slotAboutToShow() {}
00485
00489 void slotCancelled() {}
00490
00496 void userCancelled(const TQString & cancelText);
00497
00498 protected:
00499
00505 virtual void resizeEvent( TQResizeEvent * );
00506
00512 virtual void keyPressEvent( TQKeyEvent * );
00513
00519 virtual void mousePressEvent( TQMouseEvent * );
00520
00526 virtual void mouseDoubleClickEvent( TQMouseEvent * );
00527
00533 virtual void mouseReleaseEvent( TQMouseEvent * );
00534
00540 virtual void contextMenuEvent( TQContextMenuEvent * );
00541
00547 virtual TQPopupMenu *createPopupMenu();
00548
00554 virtual void drawContents( TQPainter *p );
00555
00561 virtual void dropEvent( TQDropEvent * );
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571 virtual void setCompletedText( const TQString& , 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( TQFocusEvent* );
00592
00598 virtual void focusOutEvent( TQFocusEvent* );
00599
00604 bool autoSuggest() const;
00605
00606 private slots:
00607 void completionMenuActivated( int id );
00608 void tripleClickTimeout();
00609 void slotRestoreSelectionColors();
00610 void setTextWorkaround( const TQString& 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 TQKeyEvent* 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