source: trunk/src/gui/widgets/qdatetimeedit.h@ 64

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

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

File size: 7.9 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 QtGui 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 QDATETIMEEDIT_H
43#define QDATETIMEEDIT_H
44
45#include <QtCore/qdatetime.h>
46#include <QtCore/qvariant.h>
47#include <QtGui/qabstractspinbox.h>
48
49QT_BEGIN_HEADER
50
51QT_BEGIN_NAMESPACE
52
53QT_MODULE(Gui)
54
55#ifndef QT_NO_DATETIMEEDIT
56
57class QDateTimeEditPrivate;
58class QStyleOptionSpinBox;
59class QCalendarWidget;
60
61class Q_GUI_EXPORT QDateTimeEdit : public QAbstractSpinBox
62{
63 Q_OBJECT
64
65 Q_ENUMS(Section)
66 Q_FLAGS(Sections)
67 Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged USER true)
68 Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged)
69 Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged)
70 Q_PROPERTY(QDateTime maximumDateTime READ maximumDateTime WRITE setMaximumDateTime RESET clearMaximumDateTime)
71 Q_PROPERTY(QDateTime minimumDateTime READ minimumDateTime WRITE setMinimumDateTime RESET clearMinimumDateTime)
72 Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate RESET clearMaximumDate)
73 Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate RESET clearMinimumDate)
74 Q_PROPERTY(QTime maximumTime READ maximumTime WRITE setMaximumTime RESET clearMaximumTime)
75 Q_PROPERTY(QTime minimumTime READ minimumTime WRITE setMinimumTime RESET clearMinimumTime)
76 Q_PROPERTY(Section currentSection READ currentSection WRITE setCurrentSection)
77 Q_PROPERTY(Sections displayedSections READ displayedSections)
78 Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
79 Q_PROPERTY(bool calendarPopup READ calendarPopup WRITE setCalendarPopup)
80 Q_PROPERTY(int currentSectionIndex READ currentSectionIndex WRITE setCurrentSectionIndex)
81 Q_PROPERTY(int sectionCount READ sectionCount)
82 Q_PROPERTY(Qt::TimeSpec timeSpec READ timeSpec WRITE setTimeSpec)
83public:
84 enum Section {
85 NoSection = 0x0000,
86 AmPmSection = 0x0001,
87 MSecSection = 0x0002,
88 SecondSection = 0x0004,
89 MinuteSection = 0x0008,
90 HourSection = 0x0010,
91 DaySection = 0x0100,
92 MonthSection = 0x0200,
93 YearSection = 0x0400,
94 TimeSections_Mask = AmPmSection|MSecSection|SecondSection|MinuteSection|HourSection,
95 DateSections_Mask = DaySection|MonthSection|YearSection
96 };
97
98 Q_DECLARE_FLAGS(Sections, Section)
99
100 explicit QDateTimeEdit(QWidget *parent = 0);
101 explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = 0);
102 explicit QDateTimeEdit(const QDate &d, QWidget *parent = 0);
103 explicit QDateTimeEdit(const QTime &t, QWidget *parent = 0);
104
105 QDateTime dateTime() const;
106 QDate date() const;
107 QTime time() const;
108
109 QDateTime minimumDateTime() const;
110 void clearMinimumDateTime();
111 void setMinimumDateTime(const QDateTime &dt);
112
113 QDateTime maximumDateTime() const;
114 void clearMaximumDateTime();
115 void setMaximumDateTime(const QDateTime &dt);
116
117 void setDateTimeRange(const QDateTime &min, const QDateTime &max);
118
119 QDate minimumDate() const;
120 void setMinimumDate(const QDate &min);
121 void clearMinimumDate();
122
123 QDate maximumDate() const;
124 void setMaximumDate(const QDate &max);
125 void clearMaximumDate();
126
127 void setDateRange(const QDate &min, const QDate &max);
128
129 QTime minimumTime() const;
130 void setMinimumTime(const QTime &min);
131 void clearMinimumTime();
132
133 QTime maximumTime() const;
134 void setMaximumTime(const QTime &max);
135 void clearMaximumTime();
136
137 void setTimeRange(const QTime &min, const QTime &max);
138
139 Sections displayedSections() const;
140 Section currentSection() const;
141 Section sectionAt(int index) const;
142 void setCurrentSection(Section section);
143
144 int currentSectionIndex() const;
145 void setCurrentSectionIndex(int index);
146
147 QCalendarWidget *calendarWidget() const;
148 void setCalendarWidget(QCalendarWidget *calendarWidget);
149
150 int sectionCount() const;
151
152 void setSelectedSection(Section section);
153
154 QString sectionText(Section section) const;
155
156 QString displayFormat() const;
157 void setDisplayFormat(const QString &format);
158
159 bool calendarPopup() const;
160 void setCalendarPopup(bool enable);
161
162 Qt::TimeSpec timeSpec() const;
163 void setTimeSpec(Qt::TimeSpec spec);
164
165 QSize sizeHint() const;
166
167 virtual void clear();
168 virtual void stepBy(int steps);
169
170 bool event(QEvent *event);
171Q_SIGNALS:
172 void dateTimeChanged(const QDateTime &date);
173 void timeChanged(const QTime &date);
174 void dateChanged(const QDate &date);
175
176public Q_SLOTS:
177 void setDateTime(const QDateTime &dateTime);
178 void setDate(const QDate &date);
179 void setTime(const QTime &time);
180
181protected:
182 virtual void keyPressEvent(QKeyEvent *event);
183#ifndef QT_NO_WHEELEVENT
184 virtual void wheelEvent(QWheelEvent *event);
185#endif
186 virtual void focusInEvent(QFocusEvent *event);
187 virtual bool focusNextPrevChild(bool next);
188 virtual QValidator::State validate(QString &input, int &pos) const;
189 virtual void fixup(QString &input) const;
190
191 virtual QDateTime dateTimeFromText(const QString &text) const;
192 virtual QString textFromDateTime(const QDateTime &dt) const;
193 virtual StepEnabled stepEnabled() const;
194 virtual void mousePressEvent(QMouseEvent *event);
195 virtual void paintEvent(QPaintEvent *event);
196 void initStyleOption(QStyleOptionSpinBox *option) const;
197
198 QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = 0);
199private:
200 Q_DECLARE_PRIVATE(QDateTimeEdit)
201 Q_DISABLE_COPY(QDateTimeEdit)
202
203 Q_PRIVATE_SLOT(d_func(), void _q_resetButton())
204};
205
206class Q_GUI_EXPORT QTimeEdit : public QDateTimeEdit
207{
208 Q_OBJECT
209 Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged USER true)
210public:
211 QTimeEdit(QWidget *parent = 0);
212 QTimeEdit(const QTime &time, QWidget *parent = 0);
213};
214
215class Q_GUI_EXPORT QDateEdit : public QDateTimeEdit
216{
217 Q_OBJECT
218 Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true)
219public:
220 QDateEdit(QWidget *parent = 0);
221 QDateEdit(const QDate &date, QWidget *parent = 0);
222};
223
224Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeEdit::Sections)
225
226#endif // QT_NO_DATETIMEEDIT
227
228QT_END_NAMESPACE
229
230QT_END_HEADER
231
232#endif // QDATETIMEEDIT_H
Note: See TracBrowser for help on using the repository browser.