1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Controls module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QQUICKSPINBOXVALIDATOR_P_H
41#define QQUICKSPINBOXVALIDATOR_P_H
42
43#include <QtGui/qvalidator.h>
44#include <QtQml/qqml.h>
45
46#if QT_CONFIG(validator)
47
48QT_BEGIN_NAMESPACE
49
50class QQuickSpinBoxValidator1 : public QValidator, public QQmlParserStatus
51{
52 Q_OBJECT
53 Q_INTERFACES(QQmlParserStatus)
54 Q_PROPERTY(QString text READ text NOTIFY textChanged)
55 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
56 Q_PROPERTY(qreal minimumValue READ minimumValue WRITE setMinimumValue NOTIFY minimumValueChanged)
57 Q_PROPERTY(qreal maximumValue READ maximumValue WRITE setMaximumValue NOTIFY maximumValueChanged)
58 Q_PROPERTY(int decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged)
59 Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged)
60 Q_PROPERTY(QString prefix READ prefix WRITE setPrefix NOTIFY prefixChanged)
61 Q_PROPERTY(QString suffix READ suffix WRITE setSuffix NOTIFY suffixChanged)
62
63public:
64 explicit QQuickSpinBoxValidator1(QObject *parent = 0);
65 virtual ~QQuickSpinBoxValidator1();
66
67 QString text() const;
68
69 qreal value() const;
70 void setValue(qreal value);
71
72 qreal minimumValue() const;
73 void setMinimumValue(qreal min);
74
75 qreal maximumValue() const;
76 void setMaximumValue(qreal max);
77
78 int decimals() const;
79 void setDecimals(int decimals);
80
81 qreal stepSize() const;
82 void setStepSize(qreal step);
83
84 QString prefix() const;
85 void setPrefix(const QString &prefix);
86
87 QString suffix() const;
88 void setSuffix(const QString &suffix);
89
90 void fixup(QString &input) const override;
91 State validate(QString &input, int &pos) const override;
92
93 void classBegin() override { }
94 void componentComplete() override;
95
96public Q_SLOTS:
97 void increment();
98 void decrement();
99
100Q_SIGNALS:
101 void valueChanged();
102 void minimumValueChanged();
103 void maximumValueChanged();
104 void decimalsChanged();
105 void stepSizeChanged();
106 void prefixChanged();
107 void suffixChanged();
108 void textChanged();
109
110protected:
111 QString textFromValue(qreal value) const;
112
113private:
114 qreal m_value;
115 qreal m_step;
116 QString m_prefix;
117 QString m_suffix;
118 bool m_initialized;
119 QDoubleValidator m_validator;
120
121 Q_DISABLE_COPY(QQuickSpinBoxValidator1)
122};
123
124QT_END_NAMESPACE
125
126QML_DECLARE_TYPE(QQuickSpinBoxValidator1)
127
128#endif // QT_CONFIG(validator)
129#endif // QQUICKSPINBOXVALIDATOR_P_H
130

source code of qtquickcontrols/src/controls/Private/qquickspinboxvalidator_p.h