Debian Codegraph @

widgets/clearspinbox.h

raw symbols SCIP
1 #ifndef WIDGETS_CLEARSPINBOX_H
2 #define WIDGETS_CLEARSPINBOX_H
3
4 #include "./buttonoverlay.h"
5
6 #include <QLineEdit>
7 #include <QSpinBox>
8
9 QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
10
11 namespace QtUtilities {
12
13 class IconButton;
14
15 class QT_UTILITIES_EXPORT ClearSpinBox : public QSpinBox, public ButtonOverlay {
16 Q_OBJECT
17 Q_PROPERTY(bool cleared READ isCleared)
18 Q_PROPERTY(bool minimumHidden READ minimumHidden WRITE setMinimumHidden)
19 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
20
21 public:
22 explicit ClearSpinBox(QWidget *parent = nullptr);
23 ~ClearSpinBox() override;
24 bool minimumHidden() const;
25 void setMinimumHidden(bool value);
26 QString placeholderText() const;
27 void setPlaceholderText(const QString &placeholderText);
28 bool isCleared() const override;
29
30 protected:
31 int valueFromText(const QString &text) const override;
32 QString textFromValue(int val) const override;
33
34 private Q_SLOTS:
35 void handleValueChanged(int value);
36 void handleClearButtonClicked() override;
37 void handleCustomLayoutCreated() override;
38
39 private:
40 bool m_minimumHidden;
41 };
42
43 /*!
44 * \brief Returns whether the minimum value will be hidden.
45 */
46 inline bool ClearSpinBox::minimumHidden() const
47 {
48 return m_minimumHidden;
49 }
50
51 /*!
52 * \brief Sets whether the minimum value should be hidden.
53 */
54 inline void ClearSpinBox::setMinimumHidden(bool value)
55 {
56 m_minimumHidden = value;
57 }
58
59 /*!
60 * \brief Returns the placeholder text.
61 * \sa QLineEdit::placeholderText()
62 */
63 inline QString ClearSpinBox::placeholderText() const
64 {
65 return lineEdit()->placeholderText();
66 }
67
68 /*!
69 * \brief Sets the placeholder text.
70 * \sa QLineEdit::setPlaceholderText()
71 */
72 inline void ClearSpinBox::setPlaceholderText(const QString &placeholderText)
73 {
74 lineEdit()->setPlaceholderText(placeholderText);
75 }
76 } // namespace QtUtilities
77
78 #endif // WIDGETS_CLEARSPINBOX_H