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;
00042 class KEditListBox : public QGroupBox
00043 {
00044 Q_OBJECT
00045
00046 public:
00048 class CustomEditor
00049 {
00050 public:
00051 CustomEditor()
00052 : m_representationWidget( 0L ),
00053 m_lineEdit( 0L ) {}
00054 CustomEditor( QWidget *repWidget, KLineEdit *edit )
00055 : m_representationWidget( repWidget ),
00056 m_lineEdit( edit ) {}
00057 CustomEditor( KComboBox *combo );
00058
00059 void setRepresentationWidget( QWidget *repWidget ) {
00060 m_representationWidget = repWidget;
00061 }
00062 void setLineEdit( KLineEdit *edit ) {
00063 m_lineEdit = edit;
00064 }
00065
00066 virtual QWidget *representationWidget() const {
00067 return m_representationWidget;
00068 }
00069 virtual KLineEdit *lineEdit() const {
00070 return m_lineEdit;
00071 }
00072
00073 protected:
00074 QWidget *m_representationWidget;
00075 KLineEdit *m_lineEdit;
00076 };
00077
00078 public:
00079
00084 enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown };
00085
00098 KEditListBox(QWidget *parent = 0, const char *name = 0,
00099 bool checkAtEntering=false, int buttons = All );
00106 KEditListBox(const QString& title, QWidget *parent = 0,
00107 const char *name = 0, bool checkAtEntering=false,
00108 int buttons = All );
00109
00122 KEditListBox( const QString& title,
00123 const CustomEditor &customEditor,
00124 QWidget *parent = 0, const char *name = 0,
00125 bool checkAtEntering = false, int buttons = All );
00126
00127 virtual ~KEditListBox();
00128
00132 QListBox* listBox() const { return m_listBox; }
00136 KLineEdit* lineEdit() const { return m_lineEdit; }
00140 QPushButton* addButton() const { return servNewButton; }
00144 QPushButton* removeButton() const { return servRemoveButton; }
00148 QPushButton* upButton() const { return servUpButton; }
00152 QPushButton* downButton() const { return servDownButton; }
00153
00157 int count() const { return int(m_listBox->count()); }
00161 void insertStringList(const QStringList& list, int index=-1);
00165 void insertStrList(const QStrList* list, int index=-1);
00169 void insertStrList(const QStrList& list, int index=-1);
00173 void insertStrList(const char ** list, int numStrings=-1, int index=-1);
00177 void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
00181 void clear();
00185 QString text(int index) const { return m_listBox->text(index); }
00189 int currentItem() const;
00193 QString currentText() const { return m_listBox->currentText(); }
00194
00198 QStringList items() const;
00199
00200 signals:
00201 void changed();
00202
00208 void added( const QString & text );
00209
00215 void removed( const QString & text );
00216
00217 protected slots:
00218
00219 void moveItemUp();
00220 void moveItemDown();
00221 void addItem();
00222 void removeItem();
00223 void enableMoveButtons(int index);
00224 void typedSomething(const QString& text);
00225
00226 private:
00227 QListBox *m_listBox;
00228 QPushButton *servUpButton, *servDownButton;
00229 QPushButton *servNewButton, *servRemoveButton;
00230 KLineEdit *m_lineEdit;
00231
00232
00233 void init( bool checkAtEntering, int buttons,
00234 QWidget *representationWidget = 0L );
00235
00236 protected:
00237 virtual void virtual_hook( int id, void* data );
00238 private:
00239
00240 KEditListBoxPrivate *d;
00241 };
00242
00243 #endif
This file is part of the documentation for kdeui Library Version 3.2.3.