Qt 4.8
qabstractspinbox_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui 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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QABSTRACTSPINBOX_P_H
43 #define QABSTRACTSPINBOX_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "QtGui/qabstractspinbox.h"
57 
58 #ifndef QT_NO_SPINBOX
59 
60 #include "QtGui/qlineedit.h"
61 #include "QtGui/qstyleoption.h"
62 #include "QtGui/qvalidator.h"
63 #include "QtCore/qdatetime.h"
64 #include "QtCore/qvariant.h"
65 #include "private/qwidget_p.h"
66 #include "private/qdatetime_p.h"
67 
69 
70 QVariant operator+(const QVariant &arg1, const QVariant &arg2);
71 QVariant operator-(const QVariant &arg1, const QVariant &arg2);
72 QVariant operator*(const QVariant &arg1, double multiplier);
73 double operator/(const QVariant &arg1, const QVariant &arg2);
74 
75 enum EmitPolicy {
79 };
80 
81 enum Button {
82  None = 0x000,
83  Keyboard = 0x001,
84  Mouse = 0x002,
85  Wheel = 0x004,
86  ButtonMask = 0x008,
87  Up = 0x010,
88  Down = 0x020,
89  DirectionMask = 0x040
90 };
91 class QSpinBoxValidator;
93 {
95 public:
98 
99  void init();
100  void reset();
101  void updateState(bool up, bool fromKeyboard = false);
102  QString stripped(const QString &text, int *pos = 0) const;
103  bool specialValue() const;
104  virtual QVariant getZeroVariant() const;
105  virtual void setRange(const QVariant &min, const QVariant &max);
106  void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit = true);
107  virtual QVariant bound(const QVariant &val, const QVariant &old = QVariant(), int steps = 0) const;
108  virtual void updateEdit();
109 
110  virtual void emitSignals(EmitPolicy ep, const QVariant &old);
111  virtual void interpret(EmitPolicy ep);
112  virtual QString textFromValue(const QVariant &n) const;
113  virtual QVariant valueFromText(const QString &input) const;
114 
115  void _q_editorTextChanged(const QString &);
116  virtual void _q_editorCursorPositionChanged(int oldpos, int newpos);
117 
118  virtual QStyle::SubControl newHoverControl(const QPoint &pos);
119  bool updateHoverControl(const QPoint &pos);
120 
121  virtual void clearCache() const;
122  virtual void updateEditFieldGeometry();
123 
124  static int variantCompare(const QVariant &arg1, const QVariant &arg2);
125  static QVariant variantBound(const QVariant &min, const QVariant &value, const QVariant &max);
126 
142  uint frame : 1;
153 };
154 
156 {
157 public:
159  QValidator::State validate(QString &input, int &) const;
160  void fixup(QString &) const;
161 private:
164 };
165 
167 
168 #endif // QT_NO_SPINBOX
169 
170 #endif // QABSTRACTSPINBOX_P_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
virtual QString textFromValue(const QVariant &n) const
Virtual method called that calls the public textFromValue() functions in the subclasses.
virtual QStyle::SubControl newHoverControl(const QPoint &pos)
Returns the hover control at pos.
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
bool updateHoverControl(const QPoint &pos)
Updates the old and new hover control.
void init()
Initialises the QAbstractSpinBoxPrivate object.
static int variantCompare(const QVariant &arg1, const QVariant &arg2)
EmitPolicy
virtual QVariant valueFromText(const QString &input) const
Virtual method called that calls the public valueFromText() functions in the subclasses.
virtual void updateEditFieldGeometry()
The QString class provides a Unicode character string.
Definition: qstring.h:83
ButtonSymbols
This enum type describes the symbols that can be displayed on the buttons in a spin box...
const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
Returns a byte array that is the result of concatenating byte array a1 and byte array a2...
Definition: qbytearray.h:564
static QVariant variantBound(const QVariant &min, const QVariant &value, const QVariant &max)
void reset()
Resets the state of the spinbox.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QValidator class provides validation of input text.
Definition: qvalidator.h:60
CorrectionMode
This enum type describes the mode the spinbox will use to correct an QValidator::Intermediate value i...
virtual void interpret(EmitPolicy ep)
Interprets text and emits signals.
QStyle::SubControl hoverControl
QValidator::State cachedState
void _q_editorTextChanged(const QString &)
Slot connected to the line edit's textChanged(const QString &) signal.
QAbstractSpinBox::ButtonSymbols buttonSymbols
unsigned int uint
Definition: qglobal.h:996
void updateState(bool up, bool fromKeyboard=false)
Updates the state of the spinbox.
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
QString stripped(const QString &text, int *pos=0) const
Strips any prefix/suffix from text.
virtual void setRange(const QVariant &min, const QVariant &max)
Convenience function to set min/max values.
QSpinBoxValidator * validator
virtual void updateEdit()
Updates the line edit to reflect the current value of the spin box.
virtual void emitSignals(EmitPolicy ep, const QVariant &old)
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
virtual QVariant bound(const QVariant &val, const QVariant &old=QVariant(), int steps=0) const
Bounds val to be within minimum and maximum.
virtual void _q_editorCursorPositionChanged(int oldpos, int newpos)
Virtual slot connected to the line edit's cursorPositionChanged(int, int) signal. ...
QAbstractSpinBox * qptr
QAbstractSpinBox::CorrectionMode correctionMode
virtual void clearCache() const
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67
QGenericMatrix< N, M, T > operator/(const QGenericMatrix< N, M, T > &matrix, T divisor)
Returns the result of dividing all elements of matrix by divisor.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit=true)
Sets the value of the spin box to val.
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QGenericMatrix< M1, M2, T > operator*(const QGenericMatrix< N, M2, T > &m1, const QGenericMatrix< M1, N, T > &m2)
virtual QVariant getZeroVariant() const
Convenience function to get a variant of the right type.
bool specialValue() const
Returns true if a specialValueText has been set and the current value is minimum. ...
#define text
Definition: qobjectdefs.h:80
QAbstractSpinBoxPrivate * dptr
Button
Definition: qmessagebox.cpp:82
QGenericMatrix< N, M, T > operator-(const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
Returns the difference of m1 and m2.