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
00121 class KComboBox : public QComboBox, public KCompletionBase
00122 {
00123 Q_OBJECT
00124 Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
00125 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
00126 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
00127
00128 public:
00129
00137 KComboBox( QWidget *parent=0, const char *name=0 );
00138
00148 KComboBox( bool rw, QWidget *parent=0, const char *name=0 );
00149
00153 virtual ~KComboBox();
00154
00160 void setEditURL( const KURL& url );
00161
00167 void insertURL( const KURL& url, int index = -1 );
00168
00175 void insertURL( const QPixmap& pixmap, const KURL& url, int index = -1 );
00176
00182 void changeURL( const KURL& url, int index );
00183
00189 void changeURL( const QPixmap& pixmap, const KURL& url, int index );
00190
00199 int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
00200
00211 virtual void setAutoCompletion( bool autocomplete );
00212
00222 bool autoCompletion() const {
00223 return completionMode() == KGlobalSettings::CompletionAuto;
00224 }
00225
00242 virtual void setContextMenuEnabled( bool showMenu );
00243
00247 bool isContextMenuEnabled() const { return m_bEnableMenu; }
00248
00256 void setURLDropsEnabled( bool enable );
00257
00261 bool isURLDropsEnabled() const;
00262
00272 bool contains( const QString& text ) const;
00273
00288 void setTrapReturnKey( bool trap );
00289
00296 bool trapReturnKey() const;
00297
00303 virtual bool eventFilter( QObject *, QEvent * );
00304
00314 KCompletionBox * completionBox( bool create = true );
00315
00316 virtual void setLineEdit( QLineEdit * );
00317
00318 signals:
00325 void returnPressed();
00326
00339 void returnPressed( const QString& );
00340
00352 void completion( const QString& );
00353
00357 void substringCompletion( const QString& );
00358
00371 void textRotation( KCompletionBase::KeyBindingType );
00372
00377 void completionModeChanged( KGlobalSettings::Completion );
00378
00391 void aboutToShowContextMenu( QPopupMenu * );
00392
00393 public slots:
00394
00412 void rotateText( KCompletionBase::KeyBindingType );
00413
00420 virtual void setCompletedText( const QString& );
00421
00426 void setCompletedItems( const QStringList& items );
00427
00433 void setCurrentItem( const QString& item, bool insert = false, int index = -1 );
00434 void setCurrentItem(int index) { QComboBox::setCurrentItem(index); }
00435
00436 protected slots:
00437
00441 virtual void itemSelected( QListBoxItem* ) {};
00442
00454 virtual void makeCompletion( const QString& );
00455
00456 protected:
00457
00458
00459
00460
00461
00462
00463
00464
00465 virtual void setCompletedText( const QString& , bool );
00466
00470 virtual void create( WId = 0, bool initializeWindow = true,
00471 bool destroyOldWindow = true );
00472
00473 virtual void wheelEvent( QWheelEvent *ev );
00474
00475 private slots:
00476 void lineEditDeleted();
00477
00478 private:
00479
00480
00481
00482 enum MenuID {
00483 Default=0,
00484 Cut,
00485 Copy,
00486 Paste,
00487 Clear,
00488 Unselect,
00489 SelectAll,
00490 NoCompletion,
00491 AutoCompletion,
00492 ShellCompletion,
00493 PopupCompletion,
00494 SemiAutoCompletion
00495 };
00496
00500 void init();
00501
00502
00503 bool m_bEnableMenu;
00504
00505
00506 bool m_trapReturnKey;
00507
00508 protected:
00509 virtual void virtual_hook( int id, void* data );
00510
00511 private:
00512 class KComboBoxPrivate;
00513 KComboBoxPrivate *d;
00514 };
00515
00516
00517 class KPixmapProvider;
00518
00535 class KHistoryCombo : public KComboBox
00536 {
00537 Q_OBJECT
00538 Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
00539
00540 public:
00560 KHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
00561
00562
00569 KHistoryCombo( bool useCompletion,
00570 QWidget *parent = 0L, const char *name = 0L );
00571
00575 ~KHistoryCombo();
00576
00583 inline void setHistoryItems( QStringList items ) {
00584 setHistoryItems(items, false);
00585 }
00586
00628 void setHistoryItems( QStringList items, bool setCompletionList );
00629
00636 QStringList historyItems() const;
00637
00645 bool removeFromHistory( const QString& item );
00646
00659 void setPixmapProvider( KPixmapProvider *prov );
00660
00666 KPixmapProvider * pixmapProvider() const { return myPixProvider; }
00667
00672 void reset() { slotReset(); }
00673
00674 public slots:
00694 void addToHistory( const QString& item );
00695
00699 void clearHistory();
00700
00701 signals:
00705 void cleared();
00706
00707 protected:
00711 virtual void keyPressEvent( QKeyEvent * );
00712
00716 virtual void wheelEvent( QWheelEvent *ev );
00717
00726 void insertItems( const QStringList& items );
00727
00731 bool useCompletion() const { return compObj() != 0L; }
00732
00733 private slots:
00737 void slotReset();
00738
00743 void slotClear();
00744
00748 void addContextMenuItems( QPopupMenu* );
00749
00750 private:
00751 void init( bool useCompletion );
00752 void rotateUp();
00753 void rotateDown();
00754
00758 int myIterateIndex;
00759
00763 QString myText;
00764
00769 bool myRotated;
00770 KPixmapProvider *myPixProvider;
00771
00772 protected:
00773 virtual void virtual_hook( int id, void* data );
00774 private:
00775 class KHistoryComboPrivate;
00776 KHistoryComboPrivate *d;
00777 };
00778
00779
00780 #endif
00781
This file is part of the documentation for kdelibs Version 3.1.0.