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 #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_PROPERTY( QStringList items READ items WRITE setItems )
00049 
00050 public:
00056     class CustomEditor
00057     {
00058     public:
00059         CustomEditor()
00060             : m_representationWidget( 0L ),
00061               m_lineEdit( 0L ) {}
00062         CustomEditor( QWidget *repWidget, KLineEdit *edit )
00063             : m_representationWidget( repWidget ),
00064               m_lineEdit( edit ) {}
00065         CustomEditor( KComboBox *combo );
00066 
00067         void setRepresentationWidget( QWidget *repWidget ) {
00068             m_representationWidget = repWidget;
00069         }
00070         void setLineEdit( KLineEdit *edit ) {
00071             m_lineEdit = edit;
00072         }
00073 
00074         virtual QWidget   *representationWidget() const {
00075             return m_representationWidget;
00076         }
00077         virtual KLineEdit *lineEdit() const {
00078             return m_lineEdit;
00079         }
00080 
00081     protected:
00082         QWidget *m_representationWidget;
00083         KLineEdit *m_lineEdit;
00084     };
00085 
00086    public:
00087 
00092       enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown };
00093 
00106       KEditListBox(QWidget *parent = 0, const char *name = 0,
00107            bool checkAtEntering=false, int buttons = All );
00114       KEditListBox(const QString& title, QWidget *parent = 0,
00115            const char *name = 0, bool checkAtEntering=false,
00116            int buttons = All );
00117 
00130       KEditListBox( const QString& title,
00131                     const CustomEditor &customEditor,
00132                     QWidget *parent = 0, const char *name = 0,
00133                     bool checkAtEntering = false, int buttons = All );
00134 
00135       virtual ~KEditListBox();
00136 
00140       QListBox* listBox() const     { return m_listBox; }
00144       KLineEdit* lineEdit() const     { return m_lineEdit; }
00148       QPushButton* addButton() const     { return servNewButton; }
00152       QPushButton* removeButton() const     { return servRemoveButton; }
00156       QPushButton* upButton() const     { return servUpButton; }
00160       QPushButton* downButton() const     { return servDownButton; }
00161 
00165       int count() const   { return int(m_listBox->count()); }
00169       void insertStringList(const QStringList& list, int index=-1);
00173       void insertStrList(const QStrList* list, int index=-1);
00177       void insertStrList(const QStrList& list, int index=-1);
00181       void insertStrList(const char ** list, int numStrings=-1, int index=-1);
00185       void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
00189       void clear();
00193       QString text(int index) const { return m_listBox->text(index); }
00197       int currentItem() const;
00201       QString currentText() const  { return m_listBox->currentText(); }
00202 
00206       QStringList items() const;
00207 
00208    signals:
00209       void changed();
00210 
00216       void added( const QString & text );
00217 
00223       void removed( const QString & text );
00224 
00225    protected slots:
00226       //the names should be self-explaining
00227       void moveItemUp();
00228       void moveItemDown();
00229       void addItem();
00230       void removeItem();
00231       void enableMoveButtons(int index);
00232       void typedSomething(const QString& text);
00233 
00234    private:
00235       QListBox *m_listBox;
00236       QPushButton *servUpButton, *servDownButton;
00237       QPushButton *servNewButton, *servRemoveButton;
00238       KLineEdit *m_lineEdit;
00239 
00240       //this is called in both ctors, to avoid code duplication
00241       void init( bool checkAtEntering, int buttons,
00242                  QWidget *representationWidget = 0L );
00243 
00244    protected:
00245       virtual void virtual_hook( int id, void* data );
00246    private:
00247       //our lovely private d-pointer
00248       KEditListBoxPrivate* d;
00249 };
00250 
00251 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:12:00 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003