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 class KLineEdit;
00027 class KComboBox;
00028 class QPushButton;
00029
00030 class KEditListBoxPrivate;
00039 class KEditListBox : public QGroupBox
00040 {
00041 Q_OBJECT
00042
00043 public:
00045 class CustomEditor
00046 {
00047 public:
00048 CustomEditor()
00049 : m_representationWidget( 0L ),
00050 m_lineEdit( 0L ) {}
00051 CustomEditor( QWidget *repWidget, KLineEdit *edit )
00052 : m_representationWidget( repWidget ),
00053 m_lineEdit( edit ) {}
00054 CustomEditor( KComboBox *combo );
00055
00056 void setRepresentationWidget( QWidget *repWidget ) {
00057 m_representationWidget = repWidget;
00058 }
00059 void setLineEdit( KLineEdit *edit ) {
00060 m_lineEdit = edit;
00061 }
00062
00063 virtual QWidget *representationWidget() const {
00064 return m_representationWidget;
00065 }
00066 virtual KLineEdit *lineEdit() const {
00067 return m_lineEdit;
00068 }
00069
00070 protected:
00071 QWidget *m_representationWidget;
00072 KLineEdit *m_lineEdit;
00073 };
00074
00075 public:
00076
00081 enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown };
00082
00095 KEditListBox(QWidget *parent = 0, const char *name = 0,
00096 bool checkAtEntering=false, int buttons = All );
00103 KEditListBox(const QString& title, QWidget *parent = 0,
00104 const char *name = 0, bool checkAtEntering=false,
00105 int buttons = All );
00106
00119 KEditListBox( const QString& title,
00120 const CustomEditor &customEditor,
00121 QWidget *parent = 0, const char *name = 0,
00122 bool checkAtEntering = false, int buttons = All );
00123
00124 virtual ~KEditListBox();
00125
00129 QListBox* listBox() const { return m_listBox; }
00133 KLineEdit* lineEdit() const { return m_lineEdit; }
00137 QPushButton* addButton() const { return servNewButton; }
00141 QPushButton* removeButton() const { return servRemoveButton; }
00145 QPushButton* upButton() const { return servUpButton; }
00149 QPushButton* downButton() const { return servDownButton; }
00150
00154 int count() const { return int(m_listBox->count()); }
00158 void insertStringList(const QStringList& list, int index=-1);
00162 void insertStrList(const QStrList* list, int index=-1);
00166 void insertStrList(const QStrList& list, int index=-1);
00170 void insertStrList(const char ** list, int numStrings=-1, int index=-1);
00174 void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
00178 void clear();
00182 QString text(int index) const { return m_listBox->text(index); }
00186 int currentItem() const;
00190 QString currentText() const { return m_listBox->currentText(); }
00191
00195 QStringList items() const;
00196
00197 signals:
00198 void changed();
00199
00200 protected slots:
00201
00202 void moveItemUp();
00203 void moveItemDown();
00204 void addItem();
00205 void removeItem();
00206 void enableMoveButtons(int index);
00207 void typedSomething(const QString& text);
00208
00209 private:
00210 QListBox *m_listBox;
00211 QPushButton *servUpButton, *servDownButton;
00212 QPushButton *servNewButton, *servRemoveButton;
00213 KLineEdit *m_lineEdit;
00214
00215
00216 void init( bool checkAtEntering, int buttons,
00217 QWidget *representationWidget = 0L );
00218
00219 protected:
00220 virtual void virtual_hook( int id, void* data );
00221 private:
00222
00223 KEditListBoxPrivate *d;
00224 };
00225
00226 #endif
This file is part of the documentation for kdelibs Version 3.1.5.