0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
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 |
|
|
68 |
QT_BEGIN_NAMESPACE
|
|
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 {
|
|
76 |
EmitIfChanged,
|
|
77 |
AlwaysEmit,
|
|
78 |
NeverEmit
|
|
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;
|
|
92 |
class QAbstractSpinBoxPrivate : public QWidgetPrivate
|
|
93 |
{
|
|
94 |
Q_DECLARE_PUBLIC(QAbstractSpinBox)
|
|
95 |
public:
|
|
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 readOnly : 1;
|
|
139 |
uint wrapping : 1;
|
|
140 |
uint ignoreCursorPositionChanged : 1;
|
|
141 |
uint frame : 1;
|
|
142 |
uint accelerate : 1;
|
|
143 |
uint keyboardTracking : 1;
|
|
144 |
uint cleared : 1;
|
|
145 |
uint ignoreUpdateEdit : 1;
|
|
146 |
QAbstractSpinBox::CorrectionMode correctionMode;
|
|
147 |
int acceleration;
|
|
148 |
QStyle::SubControl hoverControl;
|
|
149 |
QRect hoverRect;
|
|
150 |
QAbstractSpinBox::ButtonSymbols buttonSymbols;
|
|
151 |
QSpinBoxValidator *validator;
|
|
152 |
};
|
|
153 |
|
|
154 |
class QSpinBoxValidator : public QValidator
|
|
155 |
{
|
|
156 |
public:
|
|
157 |
QSpinBoxValidator(QAbstractSpinBox *qptr, QAbstractSpinBoxPrivate *dptr);
|
|
158 |
QValidator::State validate(QString &input, int &) const;
|
|
159 |
void fixup(QString &) const;
|
|
160 |
private:
|
|
161 |
QAbstractSpinBox *qptr;
|
|
162 |
QAbstractSpinBoxPrivate *dptr;
|
|
163 |
};
|
|
164 |
|
|
165 |
QT_END_NAMESPACE
|
|
166 |
|
|
167 |
#endif // QT_NO_SPINBOX
|
|
168 |
|
|
169 |
#endif // QABSTRACTSPINBOX_P_H
|