QtBase  v6.3.1
qabstractspinbox_p.h
Go to the documentation of this file.
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 QtWidgets 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 QABSTRACTSPINBOX_P_H
41 #define QABSTRACTSPINBOX_P_H
42 
43 //
44 // W A R N I N G
45 // -------------
46 //
47 // This file is not part of the Qt API. It exists purely as an
48 // implementation detail. This header file may change from version to
49 // version without notice, or even be removed.
50 //
51 // We mean it.
52 //
53 
54 #include <QtWidgets/private/qtwidgetsglobal_p.h>
55 #include "QtWidgets/qabstractspinbox.h"
56 
57 #include "QtWidgets/qlineedit.h"
58 #include "QtWidgets/qstyleoption.h"
59 #include "QtGui/qvalidator.h"
60 #include "QtCore/qdatetime.h"
61 #include "QtCore/qvariant.h"
62 #include "private/qwidget_p.h"
63 
65 
67 
70 QVariant operator*(const QVariant &arg1, double multiplier);
71 double operator/(const QVariant &arg1, const QVariant &arg2);
72 
73 enum EmitPolicy {
76  NeverEmit
77 };
78 
79 enum Button {
80  None = 0x000,
81  Keyboard = 0x001,
82  Mouse = 0x002,
83  Wheel = 0x004,
84  ButtonMask = 0x008,
85  Up = 0x010,
86  Down = 0x020,
87  DirectionMask = 0x040
88 };
89 class QSpinBoxValidator;
91 {
92  Q_DECLARE_PUBLIC(QAbstractSpinBox)
93 public:
96 
97  void init();
98  void reset();
99  void updateState(bool up, bool fromKeyboard = false);
100  QString stripped(const QString &text, int *pos = nullptr) const;
101  bool specialValue() const;
102  virtual QVariant getZeroVariant() const;
103  virtual void setRange(const QVariant &min, const QVariant &max);
104  void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit = true);
105  virtual QVariant bound(const QVariant &val, const QVariant &old = QVariant(), int steps = 0) const;
106  virtual void updateEdit();
107 
108  virtual void emitSignals(EmitPolicy ep, const QVariant &old);
109  virtual void interpret(EmitPolicy ep);
110  virtual QString textFromValue(const QVariant &n) const;
111  virtual QVariant valueFromText(const QString &input) const;
112 
113  void _q_editorTextChanged(const QString &);
114  virtual void _q_editorCursorPositionChanged(int oldpos, int newpos);
115 
117  bool updateHoverControl(const QPoint &pos);
118 
119  virtual void clearCache() const;
120  virtual void updateEditFieldGeometry();
121 
122  static int variantCompare(const QVariant &arg1, const QVariant &arg2);
123  static QVariant variantBound(const QVariant &min, const QVariant &value, const QVariant &max);
124 
125  virtual QVariant calculateAdaptiveDecimalStep(int steps) const;
126 
130 
131  mutable QString cachedText = QLatin1String("\x01");
134  QLineEdit *edit = nullptr;
142  int acceleration = 0;
144 
145  Qt::KeyboardModifiers keyboardModifiers = Qt::NoModifier;
148  QAbstractSpinBox::StepType stepType = QAbstractSpinBox::StepType::DefaultStepType;
157  uint frame : 1;
163 };
164 
166 {
167 public:
169  QValidator::State validate(QString &input, int &) const override;
170  void fixup(QString &) const override;
171 private:
172  QAbstractSpinBox *qptr;
174 };
175 
177 
178 #endif // QABSTRACTSPINBOX_P_H
[0]
Definition: button.h:58
[0]
Definition: mouse.h:58
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
virtual QVariant valueFromText(const QString &input) const
virtual void emitSignals(EmitPolicy ep, const QVariant &old)
QAbstractSpinBox::StepType stepType
virtual QStyle::SubControl newHoverControl(const QPoint &pos)
static QVariant variantBound(const QVariant &min, const QVariant &value, const QVariant &max)
virtual QVariant getZeroVariant() const
QAbstractSpinBox::ButtonSymbols buttonSymbols
virtual void setRange(const QVariant &min, const QVariant &max)
QSpinBoxValidator * validator
static int variantCompare(const QVariant &arg1, const QVariant &arg2)
QString stripped(const QString &text, int *pos=nullptr) const
Qt::KeyboardModifier stepModifier
Qt::KeyboardModifiers keyboardModifiers
void _q_editorTextChanged(const QString &)
virtual void interpret(EmitPolicy ep)
QStyle::SubControl hoverControl
virtual void updateEditFieldGeometry()
virtual QString textFromValue(const QVariant &n) const
void updateState(bool up, bool fromKeyboard=false)
virtual void _q_editorCursorPositionChanged(int oldpos, int newpos)
virtual QVariant bound(const QVariant &val, const QVariant &old=QVariant(), int steps=0) const
virtual void clearCache() const
QValidator::State cachedState
void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit=true)
bool updateHoverControl(const QPoint &pos)
QAbstractSpinBox::CorrectionMode correctionMode
virtual QVariant calculateAdaptiveDecimalStep(int steps) const
const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:575
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
Definition: qstring.h:84
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:64
QMargins operator*(const QMargins &margins, int factor)
Definition: qmargins.h:192
QMargins operator/(const QMargins &margins, int divisor)
Definition: qmargins.h:216
QMargins operator-(const QMargins &m1, const QMargins &m2)
Definition: qmargins.h:168
@ UnknownType
Definition: qmetatype.h:346
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:55
void fixup(QString &) const override
QSpinBoxValidator(QAbstractSpinBox *qptr, QAbstractSpinBoxPrivate *dptr)
QValidator::State validate(QString &input, int &) const override
The QString class provides a Unicode character string.
Definition: qstring.h:388
SubControl
Definition: qstyle.h:383
@ SC_None
Definition: qstyle.h:384
The QValidator class provides validation of input text. \inmodule QtGui.
Definition: qvalidator.h:60
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
KeyboardModifier
Definition: qnamespace.h:1073
@ ControlModifier
Definition: qnamespace.h:1076
@ NoModifier
Definition: qnamespace.h:1074
@ Keyboard
@ DirectionMask
@ ButtonMask
@ Down
@ None
@ Wheel
QT_REQUIRE_CONFIG(spinbox)
EmitPolicy
@ EmitIfChanged
@ NeverEmit
@ AlwaysEmit
EGLOutputLayerEXT EGLint EGLAttrib value
unsigned int uint
Definition: qglobal.h:334
@ text
GLenum type
Definition: qopengl.h:270
GLfloat n
GLuint GLfloat * val
Definition: qopenglext.h:1513
GLuint GLuint GLuint GLuint arg1
Definition: qopenglext.h:6221
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: qopenglext.h:6222
GLenum GLenum GLenum input
Definition: qopenglext.h:10816