kcombobox.h
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
00151 public:
00152
00160 KComboBox( QWidget *parent=0, const char *name=0 );
00161
00171 KComboBox( bool rw, QWidget *parent=0, const char *name=0 );
00172
00176 virtual ~KComboBox();
00177
00183 void setEditURL( const KURL& url );
00184
00190 void insertURL( const KURL& url, int index = -1 );
00191
00198 void insertURL( const QPixmap& pixmap, const KURL& url, int index = -1 );
00199
00205 void changeURL( const KURL& url, int index );
00206
00212 void changeURL( const QPixmap& pixmap, const KURL& url, int index );
00213
00222 int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
00223
00234 virtual void setAutoCompletion( bool autocomplete );
00235
00245 bool autoCompletion() const {
00246 return completionMode() == KGlobalSettings::CompletionAuto;
00247 }
00248
00264 virtual void setContextMenuEnabled( bool showMenu );
00265
00269 bool isContextMenuEnabled() const { return m_bEnableMenu; }
00270
00278 void setURLDropsEnabled( bool enable );
00279
00283 bool isURLDropsEnabled() const;
00284
00294 bool contains( const QString& text ) const;
00295
00309 void setTrapReturnKey( bool trap );
00310
00317 bool trapReturnKey() const;
00318
00322 virtual bool eventFilter( QObject *, QEvent * );
00323
00333 KCompletionBox * completionBox( bool create = true );
00334
00341 virtual void setLineEdit( QLineEdit * );
00342
00343 signals:
00349 void returnPressed();
00350
00360 void returnPressed( const QString& );
00361
00370 void completion( const QString& );
00371
00375 void substringCompletion( const QString& );
00376
00388 void textRotation( KCompletionBase::KeyBindingType );
00389
00394 void completionModeChanged( KGlobalSettings::Completion );
00395
00405 void aboutToShowContextMenu( QPopupMenu * p );
00406
00407 public slots:
00408
00426 void rotateText( KCompletionBase::KeyBindingType type );
00427
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 );
00452 void setCurrentItem(int index) { QComboBox::setCurrentItem(index); }
00453
00454 protected slots:
00455
00459 virtual void itemSelected( QListBoxItem* ) {};
00460
00472 virtual void makeCompletion( const QString& );
00473
00474 protected:
00475
00476
00477
00478
00479
00480
00481
00482
00483 virtual void setCompletedText( const QString& , bool );
00484
00488 virtual void create( WId = 0, bool initializeWindow = true,
00489 bool destroyOldWindow = true );
00490
00491 virtual void wheelEvent( QWheelEvent *ev );
00492
00493 private slots:
00494 void lineEditDeleted();
00495
00496 private:
00500 void init();
00501 bool m_bEnableMenu;
00502 bool m_trapReturnKey;
00503
00504 protected:
00505 virtual void virtual_hook( int id, void* data );
00506
00507 private:
00508 class KComboBoxPrivate;
00509 KComboBoxPrivate* d;
00510 };
00511
00512
00513 class KPixmapProvider;
00514
00532 class KDEUI_EXPORT KHistoryCombo : public KComboBox
00533 {
00534 Q_OBJECT
00535 Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
00536
00537 public:
00557 KHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
00558
00559
00566 KHistoryCombo( bool useCompletion,
00567 QWidget *parent = 0L, const char *name = 0L );
00568
00572 ~KHistoryCombo();
00573
00580 inline void setHistoryItems( QStringList items ) {
00581 setHistoryItems(items, false);
00582 }
00583
00625 void setHistoryItems( QStringList items, bool setCompletionList );
00626
00633 QStringList historyItems() const;
00634
00642 bool removeFromHistory( const QString& item );
00643
00656 void setPixmapProvider( KPixmapProvider *prov );
00657
00663 KPixmapProvider * pixmapProvider() const { return myPixProvider; }
00664
00669 void reset() { slotReset(); }
00670
00671 public slots:
00691 void addToHistory( const QString& item );
00692
00696 void clearHistory();
00697
00698 signals:
00702 void cleared();
00703
00704 protected:
00708 virtual void keyPressEvent( QKeyEvent * );
00709
00713 virtual void wheelEvent( QWheelEvent *ev );
00714
00723 void insertItems( const QStringList& items );
00724
00728 bool useCompletion() const { return compObj(); }
00729
00730 private slots:
00734 void slotReset();
00735
00740 void slotClear();
00741
00745 void addContextMenuItems( QPopupMenu* );
00746
00747 private:
00748 void init( bool useCompletion );
00749 void rotateUp();
00750 void rotateDown();
00751
00755 int myIterateIndex;
00756
00760 QString myText;
00761
00766 bool myRotated;
00767 KPixmapProvider *myPixProvider;
00768
00769 protected:
00770 virtual void virtual_hook( int id, void* data );
00771 private:
00772 class KHistoryComboPrivate;
00773 KHistoryComboPrivate* d;
00774 };
00775
00776
00777 #endif
00778
This file is part of the documentation for kdeui Library Version 3.3.90.