Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

oeditlistbox.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017     Boston, MA 02111-1307, USA.
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, // 0 0001
00033         BeginsWith      = 0x00002, // 0 0010
00034         EndsWith        = 0x00004, // 0 0100
00035         Contains        = 0x00008, // 0 1000
00036         ExactMatch      = 0x00010  // 1 0000
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       //the names should be self-explaining
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       //this is called in both ctors, to avoid code duplication
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       //our lovely private d-pointer
00247       OEditListBoxPrivate *d;
00248 };
00249 
00250 #endif // OEDITLISTBOX

Generated on Sat Nov 5 16:16:29 2005 for OPIE by  doxygen 1.4.2