• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

keditlistbox.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., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, 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     // ### KDE4: add virtual destructor
00059     class CustomEditor
00060     {
00061     public:
00062         KDEUI_EXPORT CustomEditor()
00063             : m_representationWidget( 0L ),
00064               m_lineEdit( 0L ) {}
00065         KDEUI_EXPORT CustomEditor( QWidget *repWidget, KLineEdit *edit )
00066             : m_representationWidget( repWidget ),
00067               m_lineEdit( edit ) {}
00068         KDEUI_EXPORT CustomEditor( KComboBox *combo );
00069 
00070         KDEUI_EXPORT void setRepresentationWidget( QWidget *repWidget ) {
00071             m_representationWidget = repWidget;
00072         }
00073         KDEUI_EXPORT void setLineEdit( KLineEdit *edit ) {
00074             m_lineEdit = edit;
00075         }
00076 
00077         KDEUI_EXPORT virtual QWidget   *representationWidget() const {
00078             return m_representationWidget;
00079         }
00080         KDEUI_EXPORT  virtual KLineEdit *lineEdit() const {
00081             return m_lineEdit;
00082         }
00083 
00084     protected:
00085         QWidget *m_representationWidget;
00086         KLineEdit *m_lineEdit;
00087     };
00088 
00089    public:
00090 
00095       enum Button { Add = 1, Remove = 2, UpDown = 4 };
00096       enum { All = Add|Remove|UpDown }; // separated so that it doesn't appear in Qt designer
00097 
00110       KEditListBox(QWidget *parent = 0, const char *name = 0,
00111            bool checkAtEntering=false, int buttons = All );
00118       KEditListBox(const QString& title, QWidget *parent = 0,
00119            const char *name = 0, bool checkAtEntering=false,
00120            int buttons = All );
00121 
00134       KEditListBox( const QString& title,
00135                     const CustomEditor &customEditor,
00136                     QWidget *parent = 0, const char *name = 0,
00137                     bool checkAtEntering = false, int buttons = All );
00138 
00139       virtual ~KEditListBox();
00140 
00144       QListBox* listBox() const     { return m_listBox; }
00148       KLineEdit* lineEdit() const     { return m_lineEdit; }
00152       QPushButton* addButton() const     { return servNewButton; }
00156       QPushButton* removeButton() const     { return servRemoveButton; }
00160       QPushButton* upButton() const     { return servUpButton; }
00164       QPushButton* downButton() const     { return servDownButton; }
00165 
00169       int count() const   { return int(m_listBox->count()); }
00173       void insertStringList(const QStringList& list, int index=-1);
00177       void insertStrList(const QStrList* list, int index=-1);
00181       void insertStrList(const QStrList& list, int index=-1);
00185       void insertStrList(const char ** list, int numStrings=-1, int index=-1);
00189       void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
00193       void clear();
00197       QString text(int index) const { return m_listBox->text(index); }
00201       int currentItem() const;
00205       QString currentText() const  { return m_listBox->currentText(); }
00206 
00210       QStringList items() const;
00211 
00217       void setItems(const QStringList& items);
00218 
00222       int buttons() const;
00223 
00227       void setButtons( uint buttons );
00228 
00229    signals:
00230       void changed();
00231 
00237       void added( const QString & text );
00238 
00244       void removed( const QString & text );
00245 
00246    protected slots:
00247       //the names should be self-explaining
00248       void moveItemUp();
00249       void moveItemDown();
00250       void addItem();
00251       void removeItem();
00252       void enableMoveButtons(int index);
00253       void typedSomething(const QString& text);
00254 
00255    private:
00256       QListBox *m_listBox;
00257       QPushButton *servUpButton, *servDownButton;
00258       QPushButton *servNewButton, *servRemoveButton;
00259       KLineEdit *m_lineEdit;
00260 
00261       //this is called in both ctors, to avoid code duplication
00262       void init( bool checkAtEntering, int buttons,
00263                  QWidget *representationWidget = 0L );
00264 
00265    protected:
00266       virtual void virtual_hook( int id, void* data );
00267    private:
00268       //our lovely private d-pointer
00269       KEditListBoxPrivate* const d;
00270 };
00271 
00272 #endif

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal