kdeui Library API Documentation

keditlistbox.h

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 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       //the names should be self-explaining
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       //this is called in both ctors, to avoid code duplication
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       //our lovely private d-pointer
00240       KEditListBoxPrivate *d;
00241 };
00242 
00243 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 4 22:43:51 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003