00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OEDITLISTBOX_H
00021 #define OEDITLISTBOX_H
00022
00023 #include <qgroupbox.h>
00024 #include <qlistbox.h>
00025
00026 class OLineEdit;
00027 class OComboBox;
00028 class QPushButton;
00029
00030 #if QT_VERSION < 0x030000
00031 enum StringComparisonMode {
00032 CaseSensitive = 0x00001,
00033 BeginsWith = 0x00002,
00034 EndsWith = 0x00004,
00035 Contains = 0x00008,
00036 ExactMatch = 0x00010
00037 };
00038 #endif
00039
00040 class OEditListBoxPrivate;
00049 class OEditListBox : public QGroupBox
00050 {
00051 Q_OBJECT
00052
00053 public:
00055 class CustomEditor
00056 {
00057 public:
00058 CustomEditor()
00059 : m_representationWidget( 0L ),
00060 m_lineEdit( 0L ) {}
00061 CustomEditor( QWidget *repWidget, OLineEdit *edit )
00062 : m_representationWidget( repWidget ),
00063 m_lineEdit( edit ) {}
00064 CustomEditor( OComboBox *combo );
00065
00066 void setRepresentationWidget( QWidget *repWidget ) {
00067 m_representationWidget = repWidget;
00068 }
00069 void setLineEdit( OLineEdit *edit ) {
00070 m_lineEdit = edit;
00071 }
00072
00073 virtual QWidget *representationWidget() const {
00074 return m_representationWidget;
00075 }
00076 virtual OLineEdit *lineEdit() const {
00077 return m_lineEdit;
00078 }
00079
00080 protected:
00081 QWidget *m_representationWidget;
00082 OLineEdit *m_lineEdit;
00083 };
00084
00085 public:
00086
00091 enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown };
00092
00105 OEditListBox(QWidget *parent = 0, const char *name = 0,
00106 bool checkAtEntering=false, int buttons = All );
00113 OEditListBox(const QString& title, QWidget *parent = 0,
00114 const char *name = 0, bool checkAtEntering=false,
00115 int buttons = All );
00116
00129 OEditListBox( const QString& title,
00130 const CustomEditor &customEditor,
00131 QWidget *parent = 0, const char *name = 0,
00132 bool checkAtEntering = false, int buttons = All );
00133
00134 virtual ~OEditListBox();
00135
00139 QListBox* listBox() const { return m_listBox; }
00143 OLineEdit* lineEdit() const { return m_lineEdit; }
00147 QPushButton* addButton() const { return servNewButton; }
00151 QPushButton* removeButton() const { return servRemoveButton; }
00155 QPushButton* upButton() const { return servUpButton; }
00159 QPushButton* downButton() const { return servDownButton; }
00160
00164 int count() const { return int(m_listBox->count()); }
00168 void insertStringList(const QStringList& list, int index=-1);
00172 void insertStrList(const QStrList* list, int index=-1);
00176 void insertStrList(const QStrList& list, int index=-1);
00180 void insertStrList(const char ** list, int numStrings=-1, int index=-1);
00184 void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
00188 void clear();
00192 QString text(int index) const { return m_listBox->text(index); }
00196 int currentItem() const;
00200 QString currentText() const { return m_listBox->currentText(); }
00201
00205 QStringList items() const;
00206
00207 signals:
00208 void changed();
00209
00215 void added( const QString & text );
00216
00222 void removed( const QString & text );
00223
00224 protected slots:
00225
00226 void moveItemUp();
00227 void moveItemDown();
00228 void addItem();
00229 void removeItem();
00230 void enableMoveButtons(int index);
00231 void typedSomething(const QString& text);
00232
00233 private:
00234 QListBox *m_listBox;
00235 QPushButton *servUpButton, *servDownButton;
00236 QPushButton *servNewButton, *servRemoveButton;
00237 OLineEdit *m_lineEdit;
00238
00239
00240 void init( bool checkAtEntering, int buttons,
00241 QWidget *representationWidget = 0L );
00242
00243 protected:
00244 virtual void virtual_hook( int id, void* data );
00245 private:
00246
00247 OEditListBoxPrivate *d;
00248 };
00249
00250 #endif // OEDITLISTBOX