| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# 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;
    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       //the names should be self-explaining
    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       //this is called in both ctors, to avoid code duplication
    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       //our lovely private d-pointer
    00223       KEditListBoxPrivate *d;
    00224 };
    00225
    00226 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:56:45 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001