source: trunk/src/gui/widgets/qabstractspinbox_p.h@ 500

Last change on this file since 500 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
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
68QT_BEGIN_NAMESPACE
69
70QVariant operator+(const QVariant &arg1, const QVariant &arg2);
71QVariant operator-(const QVariant &arg1, const QVariant &arg2);
72QVariant operator*(const QVariant &arg1, double multiplier);
73double operator/(const QVariant &arg1, const QVariant &arg2);
74
75enum EmitPolicy {
76 EmitIfChanged,
77 AlwaysEmit,
78 NeverEmit
79};
80
81enum 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};
91class QSpinBoxValidator;
92class QAbstractSpinBoxPrivate : public QWidgetPrivate
93{
94 Q_DECLARE_PUBLIC(QAbstractSpinBox)
95public:
96 QAbstractSpinBoxPrivate();
97 ~QAbstractSpinBoxPrivate();
98
99 void init();
100 void reset();
101 void updateState(bool up);
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
127 QLineEdit *edit;
128 QString prefix, suffix, specialValueText;
129 QVariant value, minimum, maximum, singleStep;
130 QVariant::Type type;
131 int spinClickTimerId, spinClickTimerInterval, spinClickThresholdTimerId, spinClickThresholdTimerInterval;
132 uint buttonState;
133 mutable QString cachedText;
134 mutable QVariant cachedValue;
135 mutable QValidator::State cachedState;
136 mutable QSize cachedSizeHint, cachedMinimumSizeHint;
137 uint pendingEmit : 1;
138 uint spindownEnabled : 1;
139 uint spinupEnabled : 1;
140 uint readOnly : 1;
141 uint wrapping : 1;
142 uint ignoreCursorPositionChanged : 1;
143 uint frame : 1;
144 uint accelerate : 1;
145 uint keyboardTracking : 1;
146 uint cleared : 1;
147 uint ignoreUpdateEdit : 1;
148 QAbstractSpinBox::CorrectionMode correctionMode;
149 int acceleration;
150 QStyle::SubControl hoverControl;
151 QRect hoverRect;
152 QAbstractSpinBox::ButtonSymbols buttonSymbols;
153 QSpinBoxValidator *validator;
154};
155
156class QSpinBoxValidator : public QValidator
157{
158public:
159 QSpinBoxValidator(QAbstractSpinBox *qptr, QAbstractSpinBoxPrivate *dptr);
160 QValidator::State validate(QString &input, int &) const;
161 void fixup(QString &) const;
162private:
163 QAbstractSpinBox *qptr;
164 QAbstractSpinBoxPrivate *dptr;
165};
166
167QT_END_NAMESPACE
168
169#endif // QT_NO_SPINBOX
170
171#endif // QABSTRACTSPINBOX_P_H
Note: See TracBrowser for help on using the repository browser.