KDEUI
keditlistbox.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 #ifndef KEDITLISTBOX_H
00021 #define KEDITLISTBOX_H
00022
00023 #include <kdeui_export.h>
00024
00025 #include <QtGui/QGroupBox>
00026 #include <QtGui/QStringListModel>
00027
00028 class KLineEdit;
00029 class KComboBox;
00030 class QListView;
00031 class QPushButton;
00032
00033 class KEditListBoxPrivate;
00045 class KDEUI_EXPORT KEditListBox : public QGroupBox
00046 {
00047 Q_OBJECT
00048
00049 Q_FLAGS( Buttons )
00050 Q_PROPERTY( Buttons buttons READ buttons WRITE setButtons )
00051 Q_PROPERTY( QStringList items READ items WRITE setItems USER true )
00052
00053 public:
00054 class CustomEditorPrivate;
00055
00059 class KDEUI_EXPORT CustomEditor
00060 {
00061 public:
00062 CustomEditor();
00063 CustomEditor( QWidget *repWidget, KLineEdit *edit );
00064 CustomEditor( KComboBox *combo );
00065 virtual ~CustomEditor();
00066
00067 void setRepresentationWidget( QWidget *repWidget );
00068 void setLineEdit( KLineEdit *edit );
00069
00070 virtual QWidget *representationWidget() const;
00071 virtual KLineEdit *lineEdit() const;
00072
00073 private:
00074 friend class CustomEditorPrivate;
00075 CustomEditorPrivate *const d;
00076
00077 Q_DISABLE_COPY(CustomEditor)
00078 };
00079
00080 public:
00081
00086 enum Button {
00087 Add = 0x0001,
00088 Remove = 0x0002,
00089 UpDown = 0x0004,
00090 All = Add | Remove | UpDown
00091 };
00092
00093 Q_DECLARE_FLAGS( Buttons, Button )
00094
00095
00098 explicit KEditListBox(QWidget *parent = 0);
00099
00106 explicit KEditListBox(const QString& title, QWidget *parent = 0);
00107
00108
00109
00124 explicit KDE_DEPRECATED KEditListBox(QWidget *parent, const char *name,
00125 bool checkAtEntering = false, Buttons buttons = All );
00134 explicit KDE_DEPRECATED KEditListBox(const QString& title, QWidget *parent,
00135 const char *name, bool checkAtEntering = false,
00136 Buttons buttons = All );
00137
00149 KEditListBox( const QString& title,
00150 const CustomEditor &customEditor,
00151 QWidget *parent = 0, const char *name = 0,
00152 bool checkAtEntering = false, Buttons buttons = All );
00153
00154 virtual ~KEditListBox();
00155
00159 QListView* listView() const;
00163 KLineEdit* lineEdit() const;
00167 QPushButton* addButton() const;
00171 QPushButton* removeButton() const;
00175 QPushButton* upButton() const;
00179 QPushButton* downButton() const;
00180
00184 int count() const;
00188 void insertStringList(const QStringList& list, int index=-1);
00192 void insertItem(const QString& text, int index=-1);
00196 void clear();
00200 QString text(int index) const;
00204 int currentItem() const;
00208 QString currentText() const;
00209
00213 QStringList items() const;
00214
00218 void setItems(const QStringList& items);
00219
00223 Buttons buttons() const;
00224
00228 void setButtons( Buttons buttons );
00229
00241 void setCheckAtEntering(bool check);
00242
00246 bool checkAtEntering();
00247
00259 void setCustomEditor( const CustomEditor& editor );
00260
00264 bool eventFilter( QObject* o, QEvent* e );
00265
00266 Q_SIGNALS:
00267 void changed();
00268
00273 void added( const QString & text );
00274
00279 void removed( const QString & text );
00280
00281 protected Q_SLOTS:
00282 void moveItemUp();
00283 void moveItemDown();
00284 void addItem();
00285 void removeItem();
00286 void enableMoveButtons(const QModelIndex&, const QModelIndex&);
00287 void typedSomething(const QString& text);
00288
00289 private Q_SLOTS:
00290 void slotSelectionChanged( const QItemSelection& selected, const QItemSelection& deselected );
00291
00292 private:
00293 friend class KEditListBoxPrivate;
00294 KEditListBoxPrivate* const d;
00295
00296 Q_DISABLE_COPY(KEditListBox)
00297 };
00298
00299 Q_DECLARE_OPERATORS_FOR_FLAGS(KEditListBox::Buttons)
00300
00301 #endif