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 <kdeui_export.h> 00024 00025 #include <QtGui/QGroupBox> 00026 #include <QtGui/QStringListModel> 00027 00028 class KLineEdit; 00029 class KComboBox; 00030 class QListView; 00031 class QPushButton; 00032 00033 class KEditListBoxPrivate; 00039 class KDEUI_EXPORT KEditListBox : public QGroupBox 00040 { 00041 Q_OBJECT 00042 00043 Q_FLAGS( Buttons ) 00044 Q_PROPERTY( Buttons buttons READ buttons WRITE setButtons ) 00045 Q_PROPERTY( QStringList items READ items WRITE setItems NOTIFY changed USER true ) 00046 00047 public: 00048 class CustomEditorPrivate; 00049 00053 class KDEUI_EXPORT CustomEditor 00054 { 00055 public: 00056 CustomEditor(); 00057 CustomEditor( QWidget *repWidget, KLineEdit *edit ); 00058 CustomEditor( KComboBox *combo ); 00059 virtual ~CustomEditor(); 00060 00061 void setRepresentationWidget( QWidget *repWidget ); 00062 void setLineEdit( KLineEdit *edit ); 00063 00064 virtual QWidget *representationWidget() const; 00065 virtual KLineEdit *lineEdit() const; 00066 00067 private: 00068 friend class CustomEditorPrivate; 00069 CustomEditorPrivate *const d; 00070 00071 Q_DISABLE_COPY(CustomEditor) 00072 }; 00073 00074 public: 00075 00080 enum Button { 00081 Add = 0x0001, 00082 Remove = 0x0002, 00083 UpDown = 0x0004, 00084 All = Add | Remove | UpDown 00085 }; 00086 00087 Q_DECLARE_FLAGS( Buttons, Button ) 00088 00089 00092 explicit KEditListBox(QWidget *parent = 0); 00093 00100 explicit KEditListBox(const QString& title, QWidget *parent = 0); 00101 00102 // ### KDE5: remove name arguments and simplify (merge?!) constructors 00103 00118 explicit KDE_DEPRECATED KEditListBox(QWidget *parent, const char *name, 00119 bool checkAtEntering = false, Buttons buttons = All ); 00128 explicit KDE_DEPRECATED KEditListBox(const QString& title, QWidget *parent, 00129 const char *name, bool checkAtEntering = false, 00130 Buttons buttons = All ); 00131 00143 KEditListBox( const QString& title, 00144 const CustomEditor &customEditor, 00145 QWidget *parent = 0, const char *name = 0, 00146 bool checkAtEntering = false, Buttons buttons = All ); 00147 00148 virtual ~KEditListBox(); 00149 00153 QListView* listView() const; 00157 KLineEdit* lineEdit() const; 00161 QPushButton* addButton() const; 00165 QPushButton* removeButton() const; 00169 QPushButton* upButton() const; 00173 QPushButton* downButton() const; 00174 00178 int count() const; 00182 void insertStringList(const QStringList& list, int index=-1); 00186 void insertItem(const QString& text, int index=-1); 00190 void clear(); 00194 QString text(int index) const; 00198 int currentItem() const; 00202 QString currentText() const; 00203 00207 QStringList items() const; 00208 00212 void setItems(const QStringList& items); 00213 00217 Buttons buttons() const; 00218 00222 void setButtons( Buttons buttons ); 00223 00235 void setCheckAtEntering(bool check); 00236 00240 bool checkAtEntering(); 00241 00253 void setCustomEditor( const CustomEditor& editor ); 00254 00258 bool eventFilter( QObject* o, QEvent* e ); 00259 00260 Q_SIGNALS: 00261 void changed(); 00262 00267 void added( const QString & text ); 00268 00273 void removed( const QString & text ); 00274 00275 protected Q_SLOTS: // KDE5: make private? 00276 void moveItemUp(); 00277 void moveItemDown(); 00278 void addItem(); 00279 void removeItem(); 00280 void enableMoveButtons(const QModelIndex&, const QModelIndex&); 00281 void typedSomething(const QString& text); 00282 00283 private Q_SLOTS: 00284 void slotSelectionChanged( const QItemSelection& selected, const QItemSelection& deselected ); 00285 00286 private: 00287 friend class KEditListBoxPrivate; 00288 KEditListBoxPrivate* const d; 00289 00290 Q_DISABLE_COPY(KEditListBox) 00291 }; 00292 00293 Q_DECLARE_OPERATORS_FOR_FLAGS(KEditListBox::Buttons) 00294 00295 #endif
KDE 4.6 API Reference