KDELibs4Support

keditlistbox.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 David Faure <[email protected]>, Alexander Neundorf <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KEDITLISTBOX_H
21 #define KEDITLISTBOX_H
22 
23 #include <kdelibs4support_export.h>
24 
25 #include <QGroupBox>
26 #include <QStringListModel>
27 
28 class KLineEdit;
29 class KComboBox;
30 class QListView;
31 class QPushButton;
32 class QItemSelection;
33 
34 class KEditListBoxPrivate;
40 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KEditListBox : public QGroupBox
41 {
42  Q_OBJECT
43 
45  Q_PROPERTY(Buttons buttons READ buttons WRITE setButtons)
46  Q_PROPERTY(QStringList items READ items WRITE setItems NOTIFY changed USER true)
47 
48 public:
49  class CustomEditorPrivate;
50 
54  class KDELIBS4SUPPORT_DEPRECATED_EXPORT CustomEditor
55  {
56  public:
57  CustomEditor();
58  CustomEditor(QWidget *repWidget, KLineEdit *edit);
59  CustomEditor(KComboBox *combo);
60  virtual ~CustomEditor();
61 
62  void setRepresentationWidget(QWidget *repWidget);
63  void setLineEdit(KLineEdit *edit);
64 
65  virtual QWidget *representationWidget() const;
66  virtual KLineEdit *lineEdit() const;
67 
68  private:
69  friend class CustomEditorPrivate;
70  CustomEditorPrivate *const d;
71 
72  Q_DISABLE_COPY(CustomEditor)
73  };
74 
75 public:
76 
81  enum Button {
82  Add = 0x0001,
83  Remove = 0x0002,
84  UpDown = 0x0004,
85  All = Add | Remove | UpDown
86  };
87 
88  Q_DECLARE_FLAGS(Buttons, Button)
89 
90 
93  KDELIBS4SUPPORT_DEPRECATED explicit KEditListBox(QWidget *parent = nullptr);
94 
101  KDELIBS4SUPPORT_DEPRECATED explicit KEditListBox(const QString &title, QWidget *parent = nullptr);
102 
103 // ### KDE5: remove name arguments and simplify (merge?!) constructors
104 
119  KDELIBS4SUPPORT_DEPRECATED explicit KEditListBox(QWidget *parent, const char *name,
120  bool checkAtEntering = false, Buttons buttons = All);
129  KDELIBS4SUPPORT_DEPRECATED explicit KEditListBox(const QString &title, QWidget *parent,
130  const char *name, bool checkAtEntering = false,
131  Buttons buttons = All);
132 
144  KEditListBox(const QString &title,
145  const CustomEditor &customEditor,
146  QWidget *parent = nullptr, const char *name = nullptr,
147  bool checkAtEntering = false, Buttons buttons = All);
148 
149  virtual ~KEditListBox();
150 
154  QListView *listView() const;
158  KLineEdit *lineEdit() const;
162  QPushButton *addButton() const;
166  QPushButton *removeButton() const;
170  QPushButton *upButton() const;
174  QPushButton *downButton() const;
175 
179  int count() const;
183  void insertStringList(const QStringList &list, int index = -1);
187  void insertItem(const QString &text, int index = -1);
191  void clear();
195  QString text(int index) const;
199  int currentItem() const;
203  QString currentText() const;
204 
208  QStringList items() const;
209 
213  void setItems(const QStringList &items);
214 
218  Buttons buttons() const;
219 
223  void setButtons(Buttons buttons);
224 
236  void setCheckAtEntering(bool check);
237 
241  bool checkAtEntering();
242 
254  void setCustomEditor(const CustomEditor &editor);
255 
259  bool eventFilter(QObject *o, QEvent *e) override;
260 
261 Q_SIGNALS:
262  void changed();
263 
268  void added(const QString &text);
269 
274  void removed(const QString &text);
275 
276 protected Q_SLOTS: // KDE5: make private?
277  void moveItemUp();
278  void moveItemDown();
279  void addItem();
280  void removeItem();
281  void enableMoveButtons(const QModelIndex &, const QModelIndex &);
282  void typedSomething(const QString &text);
283 
284 private Q_SLOTS:
285  void slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
286 
287 private:
288  friend class KEditListBoxPrivate;
289  KEditListBoxPrivate *const d;
290 
291  Q_DISABLE_COPY(KEditListBox)
292 };
293 
294 Q_DECLARE_OPERATORS_FOR_FLAGS(KEditListBox::Buttons)
295 
296 #endif
Q_FLAGS(...)
Custom editor class.
Definition: keditlistbox.h:54
Q_PROPERTY(...)
Button
Enumeration of the buttons, the listbox offers.
Definition: keditlistbox.h:81
An editable listbox.
Definition: keditlistbox.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed May 27 2020 22:55:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.