keditlistbox.h
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 <qgroupbox.h>
00024 #include <qlistbox.h>
00025
00026 #include <kdelibs_export.h>
00027
00028 class KLineEdit;
00029 class KComboBox;
00030 class QPushButton;
00031
00032 class KEditListBoxPrivate;
00044 class KDEUI_EXPORT KEditListBox : public QGroupBox
00045 {
00046 Q_OBJECT
00047
00048 Q_PROPERTY( QStringList items READ items WRITE setItems )
00049
00050 public:
00056 class CustomEditor
00057 {
00058 public:
00059 CustomEditor()
00060 : m_representationWidget( 0L ),
00061 m_lineEdit( 0L ) {}
00062 CustomEditor( QWidget *repWidget, KLineEdit *edit )
00063 : m_representationWidget( repWidget ),
00064 m_lineEdit( edit ) {}
00065 CustomEditor( KComboBox *combo );
00066
00067 void setRepresentationWidget( QWidget *repWidget ) {
00068 m_representationWidget = repWidget;
00069 }
00070 void setLineEdit( KLineEdit *edit ) {
00071 m_lineEdit = edit;
00072 }
00073
00074 virtual QWidget *representationWidget() const {
00075 return m_representationWidget;
00076 }
00077 virtual KLineEdit *lineEdit() const {
00078 return m_lineEdit;
00079 }
00080
00081 protected:
00082 QWidget *m_representationWidget;
00083 KLineEdit *m_lineEdit;
00084 };
00085
00086 public:
00087
00092 enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown };
00093
00106 KEditListBox(QWidget *parent = 0, const char *name = 0,
00107 bool checkAtEntering=false, int buttons = All );
00114 KEditListBox(const QString& title, QWidget *parent = 0,
00115 const char *name = 0, bool checkAtEntering=false,
00116 int buttons = All );
00117
00130 KEditListBox( const QString& title,
00131 const CustomEditor &customEditor,
00132 QWidget *parent = 0, const char *name = 0,
00133 bool checkAtEntering = false, int buttons = All );
00134
00135 virtual ~KEditListBox();
00136
00140 QListBox* listBox() const { return m_listBox; }
00144 KLineEdit* lineEdit() const { return m_lineEdit; }
00148 QPushButton* addButton() const { return servNewButton; }
00152 QPushButton* removeButton() const { return servRemoveButton; }
00156 QPushButton* upButton() const { return servUpButton; }
00160 QPushButton* downButton() const { return servDownButton; }
00161
00165 int count() const { return int(m_listBox->count()); }
00169 void insertStringList(const QStringList& list, int index=-1);
00173 void insertStrList(const QStrList* list, int index=-1);
00177 void insertStrList(const QStrList& list, int index=-1);
00181 void insertStrList(const char ** list, int numStrings=-1, int index=-1);
00185 void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
00189 void clear();
00193 QString text(int index) const { return m_listBox->text(index); }
00197 int currentItem() const;
00201 QString currentText() const { return m_listBox->currentText(); }
00202
00206 QStringList items() const;
00207
00208 signals:
00209 void changed();
00210
00216 void added( const QString & text );
00217
00223 void removed( const QString & text );
00224
00225 protected slots:
00226
00227 void moveItemUp();
00228 void moveItemDown();
00229 void addItem();
00230 void removeItem();
00231 void enableMoveButtons(int index);
00232 void typedSomething(const QString& text);
00233
00234 private:
00235 QListBox *m_listBox;
00236 QPushButton *servUpButton, *servDownButton;
00237 QPushButton *servNewButton, *servRemoveButton;
00238 KLineEdit *m_lineEdit;
00239
00240
00241 void init( bool checkAtEntering, int buttons,
00242 QWidget *representationWidget = 0L );
00243
00244 protected:
00245 virtual void virtual_hook( int id, void* data );
00246 private:
00247
00248 KEditListBoxPrivate* d;
00249 };
00250
00251 #endif
This file is part of the documentation for kdeui Library Version 3.3.90.