kdeui
kcombobox.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 #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
00144 class KDEUI_EXPORT KComboBox : public QComboBox, public KCompletionBase
00145 {
00146 Q_OBJECT
00147 Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
00148 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
00149 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
00150 Q_PROPERTY( bool trapReturnKey READ trapReturnKey WRITE setTrapReturnKey )
00151
00152 public:
00153
00161 KComboBox( QWidget *parent=0, const char *name=0 );
00162
00172 KComboBox( bool rw, QWidget *parent=0, const char *name=0 );
00173
00177 virtual ~KComboBox();
00178
00184 void setEditURL( const KURL& url );
00185
00191 void insertURL( const KURL& url, int index = -1 );
00192
00199 void insertURL( const QPixmap& pixmap, const KURL& url, int index = -1 );
00200
00206 void changeURL( const KURL& url, int index );
00207
00213 void changeURL( const QPixmap& pixmap, const KURL& url, int index );
00214
00223 int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
00224
00235 virtual void setAutoCompletion( bool autocomplete );
00236
00246 bool autoCompletion() const {
00247 return completionMode() == KGlobalSettings::CompletionAuto;
00248 }
00249
00265 virtual void setContextMenuEnabled( bool showMenu );
00266
00270 bool isContextMenuEnabled() const { return m_bEnableMenu; }
00271
00279 void setURLDropsEnabled( bool enable );
00280
00284 bool isURLDropsEnabled() const;
00285
00295 bool contains( const QString& text ) const;
00296
00310 void setTrapReturnKey( bool trap );
00311
00318 bool trapReturnKey() const;
00319
00323 virtual bool eventFilter( QObject *, QEvent * );
00324
00334 KCompletionBox * completionBox( bool create = true );
00335
00342 virtual void setLineEdit( QLineEdit * );
00343
00344 signals:
00350 void returnPressed();
00351
00361 void returnPressed( const QString& );
00362
00371 void completion( const QString& );
00372
00376 void substringCompletion( const QString& );
00377
00389 void textRotation( KCompletionBase::KeyBindingType );
00390
00395 void completionModeChanged( KGlobalSettings::Completion );
00396
00406 void aboutToShowContextMenu( QPopupMenu * p );
00407
00408 public slots:
00409
00427 void rotateText( KCompletionBase::KeyBindingType type );
00428
00434 virtual void setCompletedText( const QString& );
00435
00440 void setCompletedItems( const QStringList& items );
00441
00447 void setCurrentItem( const QString& item, bool insert = false, int index = -1 );
00448
00453 void setCurrentItem(int index) { QComboBox::setCurrentItem(index); }
00454
00455 protected slots:
00456
00460 virtual void itemSelected( QListBoxItem* ) {}
00461
00473 virtual void makeCompletion( const QString& );
00474
00475 protected:
00476
00477
00478
00479
00480
00481
00482
00483
00484 virtual void setCompletedText( const QString& , bool );
00485
00489 virtual void create( WId = 0, bool initializeWindow = true,
00490 bool destroyOldWindow = true );
00491
00492 virtual void wheelEvent( QWheelEvent *ev );
00493
00494 private slots:
00495 void lineEditDeleted();
00496
00497 private:
00501 void init();
00502 bool m_bEnableMenu;
00503 bool m_trapReturnKey;
00504
00505 protected:
00506 virtual void virtual_hook( int id, void* data );
00507
00508 private:
00509 class KComboBoxPrivate;
00510 KComboBoxPrivate* const d;
00511 };
00512
00513
00514 class KPixmapProvider;
00515
00533 class KDEUI_EXPORT KHistoryCombo : public KComboBox
00534 {
00535 Q_OBJECT
00536 Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
00537
00538 public:
00558 KHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
00559
00560
00567 KHistoryCombo( bool useCompletion,
00568 QWidget *parent = 0L, const char *name = 0L );
00569
00573 ~KHistoryCombo();
00574
00581 inline void setHistoryItems( QStringList items ) {
00582 setHistoryItems(items, false);
00583 }
00584
00626 void setHistoryItems( QStringList items, bool setCompletionList );
00627
00634 QStringList historyItems() const;
00635
00643 bool removeFromHistory( const QString& item );
00644
00657 void setPixmapProvider( KPixmapProvider *prov );
00658
00664 KPixmapProvider * pixmapProvider() const { return myPixProvider; }
00665
00670 void reset() { slotReset(); }
00671
00672 public slots:
00692 void addToHistory( const QString& item );
00693
00697 void clearHistory();
00698
00699 signals:
00703 void cleared();
00704
00705 protected:
00709 virtual void keyPressEvent( QKeyEvent * );
00710
00714 virtual void wheelEvent( QWheelEvent *ev );
00715
00724 void insertItems( const QStringList& items );
00725
00729 bool useCompletion() const { return compObj(); }
00730
00731 private slots:
00735 void slotReset();
00736
00741 void slotClear();
00742
00746 void addContextMenuItems( QPopupMenu* );
00747
00748 private:
00749 void init( bool useCompletion );
00750 void rotateUp();
00751 void rotateDown();
00752
00756 int myIterateIndex;
00757
00761 QString myText;
00762
00767 bool myRotated;
00768 KPixmapProvider *myPixProvider;
00769
00770 protected:
00771 virtual void virtual_hook( int id, void* data );
00772 private:
00773 class KHistoryComboPrivate;
00774 KHistoryComboPrivate* const d;
00775 };
00776
00777
00778 #endif
00779