KItemViews

klistwidgetsearchline.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2003 Scott Wheeler <[email protected]>
4  SPDX-FileCopyrightText: 2004 Gustavo Sverzut Barbieri <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-only
7 */
8 
9 #ifndef KLISTWIDGETSEARCHLINE_H
10 #define KLISTWIDGETSEARCHLINE_H
11 
12 #include <QLineEdit>
13 
14 #include <kitemviews_export.h>
15 
16 class QListWidget;
17 class QListWidgetItem;
18 class QModelIndex;
19 
29 class KITEMVIEWS_EXPORT KListWidgetSearchLine : public QLineEdit
30 {
31  Q_OBJECT
32 #if KITEMVIEWS_BUILD_DEPRECATED_SINCE(5, 0)
33  Q_PROPERTY(QString clickMessage READ clickMessage WRITE setClickMessage)
34 #endif
35 
36 public:
37 
45  explicit KListWidgetSearchLine(QWidget *parent = nullptr,
46  QListWidget *listWidget = nullptr);
47 
51  virtual ~KListWidgetSearchLine();
52 
58  Qt::CaseSensitivity caseSensitive() const;
59 
65  QListWidget *listWidget() const;
66 
67 #if KITEMVIEWS_ENABLE_DEPRECATED_SINCE(5, 0)
68 
72  KITEMVIEWS_DEPRECATED_VERSION(5, 0, "Use QLineEdit::placeholderText()")
73  QString clickMessage() const { return placeholderText(); }
74 #endif
75 
76 #if KITEMVIEWS_ENABLE_DEPRECATED_SINCE(5, 0)
77 
83  KITEMVIEWS_DEPRECATED_VERSION(5, 0, "Use QLineEdit::setPlaceholderText(const QString&)")
84  void setClickMessage(const QString &msg) { setPlaceholderText(msg); }
85 #endif
86 
87 public Q_SLOTS:
92  virtual void updateSearch(const QString &s = QString());
93 
99  void setCaseSensitivity(Qt::CaseSensitivity cs);
100 
107  void setListWidget(QListWidget *lv);
108 
112  void clear();
113 
114 protected:
120  virtual bool itemMatches(const QListWidgetItem *item,
121  const QString &s) const;
125  bool event(QEvent *event) override;
126 
127 private:
128  class KListWidgetSearchLinePrivate;
129  KListWidgetSearchLinePrivate *const d;
130 
131  Q_PRIVATE_SLOT(d, void _k_listWidgetDeleted())
132  Q_PRIVATE_SLOT(d, void _k_queueSearch(const QString &))
133  Q_PRIVATE_SLOT(d, void _k_activateSearch())
134  Q_PRIVATE_SLOT(d, void _k_rowsInserted(const QModelIndex &, int, int))
135  Q_PRIVATE_SLOT(d, void _k_dataChanged(const QModelIndex &, const QModelIndex &))
136 };
137 
138 #endif /* KLISTWIDGETSEARCHLINE_H */
void clear()
virtual bool event(QEvent *e) override
CaseSensitivity
QString placeholderText() const const
Q_PROPERTY(...)
This class makes it easy to add a search line for filtering the items in a listwidget based on a simp...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:39:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.