source: trunk/src/qt3support/widgets/q3datetimeedit.h@ 353

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

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

File size: 8.1 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 Qt3Support 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 Q3DATETIMEEDIT_H
43#define Q3DATETIMEEDIT_H
44
45#include <QtGui/qwidget.h>
46#include <QtCore/qstring.h>
47#include <QtCore/qdatetime.h>
48
49QT_BEGIN_HEADER
50
51QT_BEGIN_NAMESPACE
52
53QT_MODULE(Qt3SupportLight)
54
55#ifndef QT_NO_DATETIMEEDIT
56
57class Q_COMPAT_EXPORT Q3DateTimeEditBase : public QWidget
58{
59 Q_OBJECT
60public:
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
69public Q_SLOTS:
70 virtual void stepUp() = 0;
71 virtual void stepDown() = 0;
72
73private:
74 Q_DISABLE_COPY(Q3DateTimeEditBase)
75};
76
77class Q3DateEditPrivate;
78
79class 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
89public:
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
99public Q_SLOTS:
100 virtual void setDate(const QDate& date);
101
102public:
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
120Q_SIGNALS:
121 void valueChanged(const QDate& date);
122
123protected:
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
141protected Q_SLOTS:
142 void updateButtons();
143
144private:
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
154class Q3TimeEditPrivate;
155
156class 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
166public:
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
182public Q_SLOTS:
183 virtual void setTime(const QTime& time);
184
185public:
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
204Q_SIGNALS:
205 void valueChanged(const QTime& time);
206
207protected:
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
223protected Q_SLOTS:
224 void updateButtons();
225
226private:
227 Q_DISABLE_COPY(Q3TimeEdit)
228
229 void init();
230 QString sectionText(int sec);
231 Q3TimeEditPrivate* d;
232};
233
234
235class Q3DateTimeEditPrivate;
236
237class Q_COMPAT_EXPORT Q3DateTimeEdit : public QWidget
238{
239 Q_OBJECT
240 Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime USER true)
241
242public:
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
251public Q_SLOTS:
252 virtual void setDateTime(const QDateTime & dt);
253
254public:
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
263Q_SIGNALS:
264 void valueChanged(const QDateTime& datetime);
265
266protected:
267 void init();
268 void resizeEvent(QResizeEvent *);
269
270protected Q_SLOTS:
271 void newValue(const QDate& d);
272 void newValue(const QTime& t);
273
274private:
275 Q_DISABLE_COPY(Q3DateTimeEdit)
276
277 Q3DateEdit* de;
278 Q3TimeEdit* te;
279 Q3DateTimeEditPrivate* d;
280};
281
282#endif // QT_NO_DATETIMEEDIT
283
284QT_END_NAMESPACE
285
286QT_END_HEADER
287
288#endif // Q3DATETIMEEDIT_H
Note: See TracBrowser for help on using the repository browser.