KCompletion

kcompletionbox.h
1 /*
2  This file is part of the KDE libraries
3 
4  SPDX-FileCopyrightText: 2000 Carsten Pfeiffer <[email protected]>
5  SPDX-FileCopyrightText: 2000 Stefan Schimanski <[email protected]>
6  SPDX-FileCopyrightText: 2000, 2001, 2002, 2003, 2004 Dawit Alemayehu <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10 
11 #ifndef KCOMPLETIONBOX_H
12 #define KCOMPLETIONBOX_H
13 
14 #include <QListWidget>
15 #include "kcompletion_export.h"
16 
17 class KCompletionBoxPrivate;
18 class QEvent;
19 
35 class KCOMPLETION_EXPORT KCompletionBox : public QListWidget
36 {
37  Q_OBJECT
38  Q_DECLARE_PRIVATE(KCompletionBox)
39  Q_PROPERTY(bool isTabHandling READ isTabHandling WRITE setTabHandling)
40  Q_PROPERTY(QString cancelledText READ cancelledText WRITE setCancelledText)
41  Q_PROPERTY(bool activateOnSelect READ activateOnSelect WRITE setActivateOnSelect)
42 
43 public:
50  explicit KCompletionBox(QWidget *parent = nullptr);
51 
55  ~KCompletionBox() override;
56 
57  QSize sizeHint() const override;
58 
62  bool activateOnSelect() const;
63 
67  QStringList items() const;
68 
77  bool isTabHandling() const;
78 
82  QString cancelledText() const;
83 
84 public Q_SLOTS:
90  void insertItems(const QStringList &items, int index = -1);
91 
95  void setItems(const QStringList &items);
96 
108  virtual void popup();
109 
120  void setTabHandling(bool enable);
121 
132  void setCancelledText(const QString &text);
133 
140  void setActivateOnSelect(bool doEmit);
141 
145  void down();
146 
150  void up();
151 
155  void pageDown();
156 
160  void pageUp();
161 
165  void home();
166 
170  void end();
171 
176  void setVisible(bool visible) override;
177 
178 Q_SIGNALS:
183  void activated(const QString &);
184 
189  void userCancelled(const QString &);
190 
191 protected:
197  QRect calculateGeometry() const;
198 
199 #if KCOMPLETION_ENABLE_DEPRECATED_SINCE(5, 0)
200 
203  KCOMPLETION_DEPRECATED_VERSION(5, 0, "Use KCompletionBox::resizeAndReposition()")
204  void sizeAndPosition()
205  {
206  resizeAndReposition();
207  }
208 #endif
209 
215  void resizeAndReposition();
216 
221  bool eventFilter(QObject *, QEvent *) override;
222 
227  virtual QPoint globalPositionHint() const;
228 
229 protected Q_SLOTS:
234  virtual void slotActivated(QListWidgetItem *);
235 
236 private:
238 
239  Q_PRIVATE_SLOT(d_func(), void _k_itemClicked(QListWidgetItem *))
240 };
241 
242 #endif // KCOMPLETIONBOX_H
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
virtual void setVisible(bool visible)
virtual QSize sizeHint() const const override
QList< QListWidgetItem * > items(const QMimeData *data) const const
virtual bool eventFilter(QObject *object, QEvent *event) override
Q_PROPERTY(...)
void activated(const QModelIndex &index)
void insertItems(int row, const QStringList &labels)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Aug 2 2020 22:51:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.