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 Qt3Support 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 Q3DATETIMEEDIT_H
|
|
43 |
#define Q3DATETIMEEDIT_H
|
|
44 |
|
|
45 |
#include <QtGui/qwidget.h>
|
|
46 |
#include <QtCore/qstring.h>
|
|
47 |
#include <QtCore/qdatetime.h>
|
|
48 |
|
|
49 |
QT_BEGIN_HEADER
|
|
50 |
|
|
51 |
QT_BEGIN_NAMESPACE
|
|
52 |
|
|
53 |
QT_MODULE(Qt3SupportLight)
|
|
54 |
|
|
55 |
#ifndef QT_NO_DATETIMEEDIT
|
|
56 |
|
|
57 |
class Q_COMPAT_EXPORT Q3DateTimeEditBase : public QWidget
|
|
58 |
{
|
|
59 |
Q_OBJECT
|
|
60 |
public:
|
|
61 |
Q3DateTimeEditBase(QWidget* parent=0, const char* name=0)
|
|
62 |
: QWidget(parent) { setObjectName(QString::fromAscii(name)); }
|
|
63 |
|
|
64 |
virtual bool setFocusSection(int sec) = 0;
|
|
65 |
virtual QString sectionFormattedText(int sec) = 0;
|
|
66 |
virtual void addNumber(int sec, int num) = 0;
|
|
67 |
virtual void removeLastNumber(int sec) = 0;
|
|
68 |
|
|
69 |
public Q_SLOTS:
|
|
70 |
virtual void stepUp() = 0;
|
|
71 |
virtual void stepDown() = 0;
|
|
72 |
|
|
73 |
private:
|
|
74 |
Q_DISABLE_COPY(Q3DateTimeEditBase)
|
|
75 |
};
|
|
76 |
|
|
77 |
class Q3DateEditPrivate;
|
|
78 |
|
|
79 |
class Q_COMPAT_EXPORT Q3DateEdit : public Q3DateTimeEditBase
|
|
80 |
{
|
|
81 |
Q_OBJECT
|
|
82 |
Q_ENUMS(Order)
|
|
83 |
Q_PROPERTY(Order order READ order WRITE setOrder)
|
|
84 |
Q_PROPERTY(QDate date READ date WRITE setDate USER true)
|
|
85 |
Q_PROPERTY(bool autoAdvance READ autoAdvance WRITE setAutoAdvance)
|
|
86 |
Q_PROPERTY(QDate maxValue READ maxValue WRITE setMaxValue)
|
|
87 |
Q_PROPERTY(QDate minValue READ minValue WRITE setMinValue)
|
|
88 |
|
|
89 |
public:
|
|
90 |
Q3DateEdit(QWidget* parent=0, const char* name=0);
|
|
91 |
Q3DateEdit(const QDate& date, QWidget* parent=0, const char* name=0);
|
|
92 |
~Q3DateEdit();
|
|
93 |
|
|
94 |
enum Order { DMY, MDY, YMD, YDM };
|
|
95 |
|
|
96 |
QSize sizeHint() const;
|
|
97 |
QSize minimumSizeHint() const;
|
|
98 |
|
|
99 |
public Q_SLOTS:
|
|
100 |
virtual void setDate(const QDate& date);
|
|
101 |
|
|
102 |
public:
|
|
103 |
QDate date() const;
|
|
104 |
virtual void setOrder(Order order);
|
|
105 |
Order order() const;
|
|
106 |
virtual void setAutoAdvance(bool advance);
|
|
107 |
bool autoAdvance() const;
|
|
108 |
|
|
109 |
virtual void setMinValue(const QDate& d) { setRange(d, maxValue()); }
|
|
110 |
QDate minValue() const;
|
|
111 |
virtual void setMaxValue(const QDate& d) { setRange(minValue(), d); }
|
|
112 |
QDate maxValue() const;
|
|
113 |
virtual void setRange(const QDate& min, const QDate& max);
|
|
114 |
QString separator() const;
|
|
115 |
virtual void setSeparator(const QString& s);
|
|
116 |
|
|
117 |
// Make removeFirstNumber() virtual in Q3DateTimeEditBase in 4.0
|
|
118 |
void removeFirstNumber(int sec);
|
|
119 |
|
|
120 |
Q_SIGNALS:
|
|
121 |
void valueChanged(const QDate& date);
|
|
122 |
|
|
123 |
protected:
|
|
124 |
bool event(QEvent *e);
|
|
125 |
void timerEvent(QTimerEvent *);
|
|
126 |
void resizeEvent(QResizeEvent *);
|
|
127 |
void stepUp();
|
|
128 |
void stepDown();
|
|
129 |
QString sectionFormattedText(int sec);
|
|
130 |
void addNumber(int sec, int num);
|
|
131 |
|
|
132 |
void removeLastNumber(int sec);
|
|
133 |
bool setFocusSection(int s);
|
|
134 |
|
|
135 |
virtual void setYear(int year);
|
|
136 |
virtual void setMonth(int month);
|
|
137 |
virtual void setDay(int day);
|
|
138 |
virtual void fix();
|
|
139 |
virtual bool outOfRange(int y, int m, int d) const;
|
|
140 |
|
|
141 |
protected Q_SLOTS:
|
|
142 |
void updateButtons();
|
|
143 |
|
|
144 |
private:
|
|
145 |
Q_DISABLE_COPY(Q3DateEdit)
|
|
146 |
|
|
147 |
void init();
|
|
148 |
int sectionOffsetEnd(int sec) const;
|
|
149 |
int sectionLength(int sec) const;
|
|
150 |
QString sectionText(int sec) const;
|
|
151 |
Q3DateEditPrivate* d;
|
|
152 |
};
|
|
153 |
|
|
154 |
class Q3TimeEditPrivate;
|
|
155 |
|
|
156 |
class Q_COMPAT_EXPORT Q3TimeEdit : public Q3DateTimeEditBase
|
|
157 |
{
|
|
158 |
Q_OBJECT
|
|
159 |
Q_FLAGS(Display)
|
|
160 |
Q_PROPERTY(QTime time READ time WRITE setTime USER true)
|
|
161 |
Q_PROPERTY(bool autoAdvance READ autoAdvance WRITE setAutoAdvance)
|
|
162 |
Q_PROPERTY(QTime maxValue READ maxValue WRITE setMaxValue)
|
|
163 |
Q_PROPERTY(QTime minValue READ minValue WRITE setMinValue)
|
|
164 |
Q_PROPERTY(Display display READ display WRITE setDisplay)
|
|
165 |
|
|
166 |
public:
|
|
167 |
enum Display {
|
|
168 |
Hours = 0x01,
|
|
169 |
Minutes = 0x02,
|
|
170 |
Seconds = 0x04,
|
|
171 |
/*Reserved = 0x08,*/
|
|
172 |
AMPM = 0x10
|
|
173 |
};
|
|
174 |
|
|
175 |
Q3TimeEdit(QWidget* parent=0, const char* name=0);
|
|
176 |
Q3TimeEdit(const QTime& time, QWidget* parent=0, const char* name=0);
|
|
177 |
~Q3TimeEdit();
|
|
178 |
|
|
179 |
QSize sizeHint() const;
|
|
180 |
QSize minimumSizeHint() const;
|
|
181 |
|
|
182 |
public Q_SLOTS:
|
|
183 |
virtual void setTime(const QTime& time);
|
|
184 |
|
|
185 |
public:
|
|
186 |
QTime time() const;
|
|
187 |
virtual void setAutoAdvance(bool advance);
|
|
188 |
bool autoAdvance() const;
|
|
189 |
|
|
190 |
virtual void setMinValue(const QTime& d) { setRange(d, maxValue()); }
|
|
191 |
QTime minValue() const;
|
|
192 |
virtual void setMaxValue(const QTime& d) { setRange(minValue(), d); }
|
|
193 |
QTime maxValue() const;
|
|
194 |
virtual void setRange(const QTime& min, const QTime& max);
|
|
195 |
QString separator() const;
|
|
196 |
virtual void setSeparator(const QString& s);
|
|
197 |
|
|
198 |
uint display() const;
|
|
199 |
void setDisplay(uint disp);
|
|
200 |
|
|
201 |
// Make removeFirstNumber() virtual in Q3DateTimeEditBase in 4.0
|
|
202 |
void removeFirstNumber(int sec);
|
|
203 |
|
|
204 |
Q_SIGNALS:
|
|
205 |
void valueChanged(const QTime& time);
|
|
206 |
|
|
207 |
protected:
|
|
208 |
bool event(QEvent *e);
|
|
209 |
void timerEvent(QTimerEvent *e);
|
|
210 |
void resizeEvent(QResizeEvent *);
|
|
211 |
void stepUp();
|
|
212 |
void stepDown();
|
|
213 |
QString sectionFormattedText(int sec);
|
|
214 |
void addNumber(int sec, int num);
|
|
215 |
void removeLastNumber(int sec);
|
|
216 |
bool setFocusSection(int s);
|
|
217 |
|
|
218 |
virtual bool outOfRange(int h, int m, int s) const;
|
|
219 |
virtual void setHour(int h);
|
|
220 |
virtual void setMinute(int m);
|
|
221 |
virtual void setSecond(int s);
|
|
222 |
|
|
223 |
protected Q_SLOTS:
|
|
224 |
void updateButtons();
|
|
225 |
|
|
226 |
private:
|
|
227 |
Q_DISABLE_COPY(Q3TimeEdit)
|
|
228 |
|
|
229 |
void init();
|
|
230 |
QString sectionText(int sec);
|
|
231 |
Q3TimeEditPrivate* d;
|
|
232 |
};
|
|
233 |
|
|
234 |
|
|
235 |
class Q3DateTimeEditPrivate;
|
|
236 |
|
|
237 |
class Q_COMPAT_EXPORT Q3DateTimeEdit : public QWidget
|
|
238 |
{
|
|
239 |
Q_OBJECT
|
|
240 |
Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime USER true)
|
|
241 |
|
|
242 |
public:
|
|
243 |
Q3DateTimeEdit(QWidget* parent=0, const char* name=0);
|
|
244 |
Q3DateTimeEdit(const QDateTime& datetime, QWidget* parent=0,
|
|
245 |
const char* name=0);
|
|
246 |
~Q3DateTimeEdit();
|
|
247 |
|
|
248 |
QSize sizeHint() const;
|
|
249 |
QSize minimumSizeHint() const;
|
|
250 |
|
|
251 |
public Q_SLOTS:
|
|
252 |
virtual void setDateTime(const QDateTime & dt);
|
|
253 |
|
|
254 |
public:
|
|
255 |
QDateTime dateTime() const;
|
|
256 |
|
|
257 |
Q3DateEdit* dateEdit() { return de; }
|
|
258 |
Q3TimeEdit* timeEdit() { return te; }
|
|
259 |
|
|
260 |
virtual void setAutoAdvance(bool advance);
|
|
261 |
bool autoAdvance() const;
|
|
262 |
|
|
263 |
Q_SIGNALS:
|
|
264 |
void valueChanged(const QDateTime& datetime);
|
|
265 |
|
|
266 |
protected:
|
|
267 |
void init();
|
|
268 |
void resizeEvent(QResizeEvent *);
|
|
269 |
|
|
270 |
protected Q_SLOTS:
|
|
271 |
void newValue(const QDate& d);
|
|
272 |
void newValue(const QTime& t);
|
|
273 |
|
|
274 |
private:
|
|
275 |
Q_DISABLE_COPY(Q3DateTimeEdit)
|
|
276 |
|
|
277 |
Q3DateEdit* de;
|
|
278 |
Q3TimeEdit* te;
|
|
279 |
Q3DateTimeEditPrivate* d;
|
|
280 |
};
|
|
281 |
|
|
282 |
#endif // QT_NO_DATETIMEEDIT
|
|
283 |
|
|
284 |
QT_END_NAMESPACE
|
|
285 |
|
|
286 |
QT_END_HEADER
|
|
287 |
|
|
288 |
#endif // Q3DATETIMEEDIT_H
|