pqSearchBox.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqSearchBox_h
5 #define pqSearchBox_h
6 
7 #include "pqComponentsModule.h"
8 #include <QScopedPointer>
9 #include <QWidget>
10 
11 class QSettings;
25 class PQCOMPONENTS_EXPORT pqSearchBox : public QWidget
26 {
27  Q_OBJECT
28 
34  Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true)
35 
36 
42  Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
43 
50  Q_PROPERTY(bool advancedSearchActive READ isAdvancedSearchActive WRITE setAdvancedSearchActive
51  NOTIFY advancedSearchActivated)
52 
58  Q_PROPERTY(bool advancedSearchEnabled READ isAdvancedSearchEnabled WRITE setAdvancedSearchEnabled)
59 
72  Q_PROPERTY(QString settingKey READ settingKey WRITE setSettingKey NOTIFY settingKeyChanged)
73 
74 public:
75  typedef QWidget Superclass;
76 
77  pqSearchBox(QWidget* parent = nullptr);
79  bool advancedSearchEnabled, const QString& settingKey = "", QWidget* parent = nullptr);
80 
81  ~pqSearchBox() override;
82 
87  bool isAdvancedSearchActive() const;
88 
93  QString text() const;
94 
99  QString placeholderText() const;
100  void setPlaceholderText(const QString& text);
101 
106  QString settingKey() const;
107 
112  QSettings* settings() const;
113 
118  bool isAdvancedSearchEnabled() const;
119 
120 Q_SIGNALS:
126  void advancedSearchActivated(bool);
127 
132  void textChanged(const QString&);
133 
138  void settingKeyChanged(const QString&);
139 
140 public Q_SLOTS:
146  void setAdvancedSearchActive(bool use);
147 
152  void setText(const QString& text);
153 
162  QString setSettingKey(const QString& key);
163 
168  void setAdvancedSearchEnabled(bool enable);
169 
170 protected:
171  void keyPressEvent(QKeyEvent* e) override;
172 
173 protected Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
174  void onAdvancedButtonClicked(bool);
175  void updateSettings();
176  void updateFromSettings();
177 
178 private:
179  Q_DISABLE_COPY(pqSearchBox)
180 
181  class pqInternals;
182  friend class pqInternals;
183 
184  const QScopedPointer<pqInternals> Internals;
185  QString SettingKey;
186 };
187 
188 #endif
#define PQCOMPONENTS_EXPORT
pqSearchBox is a line edit and an advanced tool button in the same layout.
Definition: pqSearchBox.h:25
QWidget Superclass
Definition: pqSearchBox.h:75
#define const
Definition: zconf.h:238