00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _KCOMBOBOX_H
00023 #define _KCOMBOBOX_H
00024
00025 #include <qlineedit.h>
00026 #include <qcombobox.h>
00027
00028 #include <kcompletion.h>
00029
00030 class QListBoxItem;
00031 class QPopupMenu;
00032 class QLineEdit;
00033
00034 class KCompletionBox;
00035 class KURL;
00036
00127 class KComboBox : public QComboBox, public KCompletionBase
00128 {
00129 Q_OBJECT
00130 Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
00131 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
00132 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
00133
00134 public:
00135
00143 KComboBox( QWidget *parent=0, const char *name=0 );
00144
00154 KComboBox( bool rw, QWidget *parent=0, const char *name=0 );
00155
00159 virtual ~KComboBox();
00160
00166 void setEditURL( const KURL& url );
00167
00173 void insertURL( const KURL& url, int index = -1 );
00174
00181 void insertURL( const QPixmap& pixmap, const KURL& url, int index = -1 );
00182
00188 void changeURL( const KURL& url, int index );
00189
00195 void changeURL( const QPixmap& pixmap, const KURL& url, int index );
00196
00205 int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
00206
00217 virtual void setAutoCompletion( bool autocomplete );
00218
00228 bool autoCompletion() const {
00229 return completionMode() == KGlobalSettings::CompletionAuto;
00230 }
00231
00248 virtual void setContextMenuEnabled( bool showMenu );
00249
00253 bool isContextMenuEnabled() const { return m_bEnableMenu; }
00254
00262 void setURLDropsEnabled( bool enable );
00263
00267 bool isURLDropsEnabled() const;
00268
00278 bool contains( const QString& text ) const;
00279
00294 void setTrapReturnKey( bool trap );
00295
00302 bool trapReturnKey() const;
00303
00309 virtual bool eventFilter( QObject *, QEvent * );
00310
00320 KCompletionBox * completionBox( bool create = true );
00321
00322 virtual void setLineEdit( QLineEdit * );
00323
00324 signals:
00331 void returnPressed();
00332
00345 void returnPressed( const QString& );
00346
00358 void completion( const QString& );
00359
00363 void substringCompletion( const QString& );
00364
00377 void textRotation( KCompletionBase::KeyBindingType );
00378
00383 void completionModeChanged( KGlobalSettings::Completion );
00384
00397 void aboutToShowContextMenu( QPopupMenu * );
00398
00399 public slots:
00400
00418 void rotateText( KCompletionBase::KeyBindingType );
00419
00426 virtual void setCompletedText( const QString& );
00427
00432 void setCompletedItems( const QStringList& items );
00433
00439 void setCurrentItem( const QString& item, bool insert = false, int index = -1 );
00440 void setCurrentItem(int index) { QComboBox::setCurrentItem(index); }
00441
00442 protected slots:
00443
00447 virtual void itemSelected( QListBoxItem* ) {};
00448
00460 virtual void makeCompletion( const QString& );
00461
00462 protected:
00463
00464
00465
00466
00467
00468
00469
00470
00471 virtual void setCompletedText( const QString& , bool );
00472
00476 virtual void create( WId = 0, bool initializeWindow = true,
00477 bool destroyOldWindow = true );
00478
00479 private:
00480
00481
00482
00483 enum MenuID {
00484 Default=0,
00485 Cut,
00486 Copy,
00487 Paste,
00488 Clear,
00489 Unselect,
00490 SelectAll,
00491 NoCompletion,
00492 AutoCompletion,
00493 ShellCompletion,
00494 PopupCompletion,
00495 SemiAutoCompletion
00496 };
00497
00501 void init();
00506 void deleteWordBack();
00507 void deleteWordForward();
00508
00509 bool m_bEnableMenu;
00510
00511
00512 bool m_trapReturnKey;
00513
00514 protected:
00515 virtual void virtual_hook( int id, void* data );
00516 private:
00517 class KComboBoxPrivate;
00518 KComboBoxPrivate *d;
00519 };
00520
00521
00522 class KPixmapProvider;
00523
00534 class KHistoryCombo : public KComboBox
00535 {
00536 Q_OBJECT
00537 Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
00538
00539 public:
00559 KHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
00560
00561
00568 KHistoryCombo( bool useCompletion,
00569 QWidget *parent = 0L, const char *name = 0L );
00570
00574 ~KHistoryCombo();
00575
00582 inline void setHistoryItems( QStringList items ) {
00583 setHistoryItems(items, false);
00584 }
00585
00627 void setHistoryItems( QStringList items, bool setCompletionList );
00628
00635 QStringList historyItems() const;
00636
00644 bool removeFromHistory( const QString& item );
00645
00658 void setPixmapProvider( KPixmapProvider *prov );
00659
00665 KPixmapProvider * pixmapProvider() const { return myPixProvider; }
00666
00671 void reset() { slotReset(); }
00672
00673 public slots:
00693 void addToHistory( const QString& item );
00694
00698 void clearHistory();
00699
00700 signals:
00704 void cleared();
00705
00706 protected:
00710 virtual void keyPressEvent( QKeyEvent * );
00711
00712
00721 void insertItems( const QStringList& items );
00722
00726 bool useCompletion() const { return compObj() != 0L; }
00727
00728 private slots:
00732 void slotReset();
00733
00738 void slotClear();
00739
00743 void addContextMenuItems( QPopupMenu* );
00744
00745 private:
00746 void init( bool useCompletion );
00747
00751 int myIterateIndex;
00752
00756 QString myText;
00757
00762 bool myRotated;
00763 KPixmapProvider *myPixProvider;
00764
00765 protected:
00766 virtual void virtual_hook( int id, void* data );
00767 private:
00768 class KHistoryComboPrivate;
00769 KHistoryComboPrivate *d;
00770 };
00771
00772
00773 #endif
00774