| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | 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 #include <kdelibs_export.h>
    00027
    00028 class KLineEdit;
    00029 class KComboBox;
    00030 class QPushButton;
    00031
    00032 class KEditListBoxPrivate;
    00044 class KDEUI_EXPORT KEditListBox : public QGroupBox
    00045 {
    00046    Q_OBJECT
    00047
    00048    Q_SETS( Button )
    00049    Q_PROPERTY( Button buttons READ buttons WRITE setButtons )
    00050    Q_PROPERTY( QStringList items READ items WRITE setItems )
    00051
    00052 public:
    00058     class CustomEditor
    00059     {
    00060     public:
    00061         KDEUI_EXPORT CustomEditor()
    00062             : m_representationWidget( 0L ),
    00063               m_lineEdit( 0L ) {}
    00064         KDEUI_EXPORT CustomEditor( QWidget *repWidget, KLineEdit *edit )
    00065             : m_representationWidget( repWidget ),
    00066               m_lineEdit( edit ) {}
    00067         KDEUI_EXPORT CustomEditor( KComboBox *combo );
    00068
    00069         KDEUI_EXPORT void setRepresentationWidget( QWidget *repWidget ) {
    00070             m_representationWidget = repWidget;
    00071         }
    00072         KDEUI_EXPORT void setLineEdit( KLineEdit *edit ) {
    00073             m_lineEdit = edit;
    00074         }
    00075
    00076         KDEUI_EXPORT virtual QWidget   *representationWidget() const {
    00077             return m_representationWidget;
    00078         }
    00079         KDEUI_EXPORT  virtual KLineEdit *lineEdit() const {
    00080             return m_lineEdit;
    00081         }
    00082
    00083     protected:
    00084         QWidget *m_representationWidget;
    00085         KLineEdit *m_lineEdit;
    00086     };
    00087
    00088    public:
    00089
    00094       enum Button { Add = 1, Remove = 2, UpDown = 4 };
    00095       enum { All = Add|Remove|UpDown }; // separated so that it doesn't appear in Qt designer
    00096
    00109       KEditListBox(QWidget *parent = 0, const char *name = 0,
    00110            bool checkAtEntering=false, int buttons = All );
    00117       KEditListBox(const QString& title, QWidget *parent = 0,
    00118            const char *name = 0, bool checkAtEntering=false,
    00119            int buttons = All );
    00120
    00133       KEditListBox( const QString& title,
    00134                     const CustomEditor &customEditor,
    00135                     QWidget *parent = 0, const char *name = 0,
    00136                     bool checkAtEntering = false, int buttons = All );
    00137
    00138       virtual ~KEditListBox();
    00139
    00143       QListBox* listBox() const     { return m_listBox; }
    00147       KLineEdit* lineEdit() const     { return m_lineEdit; }
    00151       QPushButton* addButton() const     { return servNewButton; }
    00155       QPushButton* removeButton() const     { return servRemoveButton; }
    00159       QPushButton* upButton() const     { return servUpButton; }
    00163       QPushButton* downButton() const     { return servDownButton; }
    00164
    00168       int count() const   { return int(m_listBox->count()); }
    00172       void insertStringList(const QStringList& list, int index=-1);
    00176       void insertStrList(const QStrList* list, int index=-1);
    00180       void insertStrList(const QStrList& list, int index=-1);
    00184       void insertStrList(const char ** list, int numStrings=-1, int index=-1);
    00188       void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
    00192       void clear();
    00196       QString text(int index) const { return m_listBox->text(index); }
    00200       int currentItem() const;
    00204       QString currentText() const  { return m_listBox->currentText(); }
    00205
    00209       QStringList items() const;
    00210
    00216       void setItems(const QStringList& items);
    00217
    00221       int buttons() const;
    00222
    00226       void setButtons( uint buttons );
    00227
    00228    signals:
    00229       void changed();
    00230
    00236       void added( const QString & text );
    00237
    00243       void removed( const QString & text );
    00244
    00245    protected slots:
    00246       //the names should be self-explaining
    00247       void moveItemUp();
    00248       void moveItemDown();
    00249       void addItem();
    00250       void removeItem();
    00251       void enableMoveButtons(int index);
    00252       void typedSomething(const QString& text);
    00253
    00254    private:
    00255       QListBox *m_listBox;
    00256       QPushButton *servUpButton, *servDownButton;
    00257       QPushButton *servNewButton, *servRemoveButton;
    00258       KLineEdit *m_lineEdit;
    00259
    00260       //this is called in both ctors, to avoid code duplication
    00261       void init( bool checkAtEntering, int buttons,
    00262                  QWidget *representationWidget = 0L );
    00263
    00264    protected:
    00265       virtual void virtual_hook( int id, void* data );
    00266    private:
    00267       //our lovely private d-pointer
    00268       KEditListBoxPrivate* const d;
    00269 };
    00270
    00271 #endif

This file is part of the documentation for kdeui Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:20:16 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003