KCompletion

khistorycombobox.h
1 /*
2  This file is part of the KDE libraries
3 
4  SPDX-FileCopyrightText: 2000, 2001 Dawit Alemayehu <[email protected]>
5  SPDX-FileCopyrightText: 2000, 2001 Carsten Pfeiffer <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.1-or-later
8 */
9 
10 #ifndef KHistoryComboBoxBOX_H
11 #define KHistoryComboBoxBOX_H
12 
13 #include <kcombobox.h>
14 #include <kcompletion_export.h>
15 
16 #include <functional>
17 
18 class KPixmapProvider;
19 class KHistoryComboBoxPrivate;
20 
42 class KCOMPLETION_EXPORT KHistoryComboBox : public KComboBox
43 {
44  Q_OBJECT
45 
46  Q_DECLARE_PRIVATE(KHistoryComboBox)
47 
48  Q_PROPERTY(QStringList historyItems READ historyItems WRITE setHistoryItems)
49 
50 public:
69  explicit KHistoryComboBox(QWidget *parent = nullptr);
70 
77  explicit KHistoryComboBox(bool useCompletion, QWidget *parent = nullptr);
78 
82  ~KHistoryComboBox() override;
83 
90  void setHistoryItems(const QStringList &items);
91 
135  void setHistoryItems(const QStringList &items, bool setCompletionList);
136 
143  QStringList historyItems() const;
144 
152  bool removeFromHistory(const QString &item);
153 
154 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 66)
155 
168  KCOMPLETION_DEPRECATED_VERSION(5, 66, "Use setIconProvider")
169  void setPixmapProvider(KPixmapProvider *provider);
170 #endif
171 
172 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 66)
173 
179  KCOMPLETION_DEPRECATED_VERSION(5, 66, "unused")
180  KPixmapProvider *pixmapProvider() const;
181 #endif
182 
188  void setIconProvider(std::function<QIcon(const QString &)> providerFunction);
189 
191 
192 public Q_SLOTS:
212  void addToHistory(const QString &item);
213 
217  void clearHistory();
218 
223  void reset();
224 
225 Q_SIGNALS:
229  void cleared();
230 
231 protected:
235  void keyPressEvent(QKeyEvent *) override;
236 
240  void wheelEvent(QWheelEvent *ev) override;
241 
250  void insertItems(const QStringList &items);
251 
255  bool useCompletion() const;
256 
257 private:
259  Q_PRIVATE_SLOT(d_func(), void _k_clear())
260  Q_PRIVATE_SLOT(d_func(), void _k_addContextMenuItems(QMenu *))
261  Q_PRIVATE_SLOT(d_func(), void _k_simulateActivated(const QString &))
262 
264 };
265 
266 #endif
267 
virtual void keyPressEvent(QKeyEvent *e) override
virtual void wheelEvent(QWheelEvent *e) override
A combobox for offering a history and completion.
Q_PROPERTY(...)
Q_DISABLE_COPY(Class)
A combo box with completion support.
Definition: kcombobox.h:133
void insertItems(int index, const QStringList &list)
A tiny abstract class with just one method: pixmapFor()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 10 2020 22:55:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.