| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 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 | ** 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 have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia 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 |
|
|---|
| 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, 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 |
|
|---|
| 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 | int effectiveSpinRepeatRate;
|
|---|
| 133 | uint buttonState;
|
|---|
| 134 | mutable QString cachedText;
|
|---|
| 135 | mutable QVariant cachedValue;
|
|---|
| 136 | mutable QValidator::State cachedState;
|
|---|
| 137 | mutable QSize cachedSizeHint, cachedMinimumSizeHint;
|
|---|
| 138 | uint pendingEmit : 1;
|
|---|
| 139 | uint readOnly : 1;
|
|---|
| 140 | uint wrapping : 1;
|
|---|
| 141 | uint ignoreCursorPositionChanged : 1;
|
|---|
| 142 | uint frame : 1;
|
|---|
| 143 | uint accelerate : 1;
|
|---|
| 144 | uint keyboardTracking : 1;
|
|---|
| 145 | uint cleared : 1;
|
|---|
| 146 | uint ignoreUpdateEdit : 1;
|
|---|
| 147 | QAbstractSpinBox::CorrectionMode correctionMode;
|
|---|
| 148 | int acceleration;
|
|---|
| 149 | QStyle::SubControl hoverControl;
|
|---|
| 150 | QRect hoverRect;
|
|---|
| 151 | QAbstractSpinBox::ButtonSymbols buttonSymbols;
|
|---|
| 152 | QSpinBoxValidator *validator;
|
|---|
| 153 | };
|
|---|
| 154 |
|
|---|
| 155 | class QSpinBoxValidator : public QValidator
|
|---|
| 156 | {
|
|---|
| 157 | public:
|
|---|
| 158 | QSpinBoxValidator(QAbstractSpinBox *qptr, QAbstractSpinBoxPrivate *dptr);
|
|---|
| 159 | QValidator::State validate(QString &input, int &) const;
|
|---|
| 160 | void fixup(QString &) const;
|
|---|
| 161 | private:
|
|---|
| 162 | QAbstractSpinBox *qptr;
|
|---|
| 163 | QAbstractSpinBoxPrivate *dptr;
|
|---|
| 164 | };
|
|---|
| 165 |
|
|---|
| 166 | QT_END_NAMESPACE
|
|---|
| 167 |
|
|---|
| 168 | #endif // QT_NO_SPINBOX
|
|---|
| 169 |
|
|---|
| 170 | #endif // QABSTRACTSPINBOX_P_H
|
|---|