~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/widgets/qabstractspinbox_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the widgets module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QABSTRACTSPINBOX_P_H
 
30
#define QABSTRACTSPINBOX_P_H
 
31
 
 
32
//
 
33
//  W A R N I N G
 
34
//  -------------
 
35
//
 
36
// This file is not part of the Qt API.  It exists purely as an
 
37
// implementation detail.  This header file may change from version to
 
38
// version without notice, or even be removed.
 
39
//
 
40
// We mean it.
 
41
//
 
42
 
 
43
#include "qabstractspinbox.h"
 
44
#include <qlineedit.h>
 
45
#include <qstyleoption.h>
 
46
#include <qdatetime.h>
 
47
#include <qvariant.h>
 
48
#include <qvalidator.h>
 
49
#include <private/qwidget_p.h>
 
50
 
 
51
bool operator<(const QVariant &arg1, const QVariant &arg2);
 
52
bool operator>(const QVariant &arg1, const QVariant &arg2);
 
53
bool operator<=(const QVariant &arg1, const QVariant &arg2);
 
54
bool operator>=(const QVariant &arg1, const QVariant &arg2);
 
55
QVariant operator+(const QVariant &arg1, const QVariant &arg2);
 
56
QVariant operator-(const QVariant &arg1, const QVariant &arg2);
 
57
QVariant operator*(const QVariant &arg1, double multiplier);
 
58
double operator/(const QVariant &arg1, const QVariant &arg2);
 
59
 
 
60
#define TIME_MIN QTime(0, 0, 0, 0)
 
61
#define TIME_MAX QTime(23, 59, 59, 999)
 
62
#define DATE_MIN QDate(1752, 9, 14)
 
63
#define DATE_MAX QDate(7999, 12, 31)
 
64
#define DATETIME_MIN QDateTime(DATE_MIN, TIME_MIN)
 
65
#define DATETIME_MAX QDateTime(DATE_MAX, TIME_MAX)
 
66
#define DATE_INITIAL QDate(2000, 1, 1)
 
67
 
 
68
enum EmitPolicy {
 
69
    EmitIfChanged,
 
70
    AlwaysEmit,
 
71
    NeverEmit
 
72
};
 
73
 
 
74
enum Boundary {
 
75
    Minimum,
 
76
    Maximum
 
77
};
 
78
enum Button {
 
79
    None = 0x000,
 
80
    Keyboard = 0x001,
 
81
    Mouse = 0x002,
 
82
    Wheel = 0x004,
 
83
    ButtonMask = 0x008,
 
84
    Up = 0x010,
 
85
    Down = 0x020,
 
86
    DirectionMask = 0x040
 
87
};
 
88
class QSpinBoxValidator;
 
89
class QAbstractSpinBoxPrivate : public QWidgetPrivate
 
90
{
 
91
    Q_DECLARE_PUBLIC(QAbstractSpinBox)
 
92
public:
 
93
    QAbstractSpinBoxPrivate();
 
94
    ~QAbstractSpinBoxPrivate();
 
95
 
 
96
    void init();
 
97
    void resetState();
 
98
    void updateState(bool up);
 
99
    QString stripped(const QString &text) const;
 
100
    bool specialValue() const;
 
101
    QVariant getZeroVariant() const;
 
102
    void setBoundary(Boundary b, const QVariant &val);
 
103
    void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit = true);
 
104
    virtual QVariant bound(const QVariant &val, const QVariant &old = QVariant(), int steps = 0) const;
 
105
    QLineEdit *lineEdit();
 
106
    void updateSpinBox();
 
107
    void update();
 
108
    void updateEdit() const;
 
109
 
 
110
    virtual QStyleOptionSpinBox getStyleOption() const;
 
111
 
 
112
    virtual void emitSignals(EmitPolicy ep, const QVariant &old);
 
113
    virtual void interpret(EmitPolicy ep);
 
114
    virtual QString textFromValue(const QVariant &n) const;
 
115
    virtual QVariant valueFromText(const QString &input) const;
 
116
 
 
117
    void editorTextChanged(const QString &);
 
118
    virtual void editorCursorPositionChanged(int oldpos, int newpos);
 
119
 
 
120
    QStyle::SubControl newHoverControl(const QPoint &pos);
 
121
    bool updateHoverControl(const QPoint &pos);
 
122
 
 
123
    QLineEdit *edit;
 
124
    QString prefix, suffix, specialValueText;
 
125
    QVariant value, minimum, maximum, singleStep;
 
126
    QVariant::Type type;
 
127
    int spinClickTimerId, spinClickTimerInterval;
 
128
    uint buttonState;
 
129
    mutable uint dirty : 1;
 
130
    mutable QString cachedText;
 
131
    mutable QVariant cachedValue;
 
132
    mutable QValidator::State cachedState;
 
133
    uint pendingEmit : 1;
 
134
    uint spindownEnabled : 1;
 
135
    uint spinupEnabled : 1;
 
136
    uint readOnly : 1;
 
137
    uint wrapping : 1;
 
138
    uint ignoreCursorPositionChanged : 1;
 
139
    uint frame : 1;
 
140
    QStyle::SubControl hoverControl;
 
141
    QRect hoverRect;
 
142
    QAbstractSpinBox::ButtonSymbols buttonSymbols;
 
143
    QSpinBoxValidator *validator;
 
144
};
 
145
 
 
146
class QSpinBoxValidator : public QValidator
 
147
{
 
148
public:
 
149
    QSpinBoxValidator(QAbstractSpinBox *qptr, QAbstractSpinBoxPrivate *dptr);
 
150
    QValidator::State validate(QString &input, int &) const;
 
151
    void fixup(QString &) const;
 
152
private:
 
153
    QAbstractSpinBox *qptr;
 
154
    QAbstractSpinBoxPrivate *dptr;
 
155
};
 
156
 
 
157
#endif // QABSTRACTSPINBOX_P_H