Qt 4.8
qdatetimeedit.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 
50 
52 
53 QT_MODULE(Gui)
54 
55 #ifndef QT_NO_DATETIMEEDIT
56 
59 class QCalendarWidget;
60 
62 {
63  Q_OBJECT
64 
66  Q_FLAGS(Sections)
67  QDateTime dateTime;
68  QDate date;
69  QTime time;
70  QDateTime maximumDateTime;
71  QDateTime minimumDateTime;
72  QDate maximumDate;
73  QDate minimumDate;
74  QTime maximumTime;
75  QTime minimumTime;
76  Section currentSection;
77  Sections displayedSections;
78  QString displayFormat;
79  bool calendarPopup;
80  int currentSectionIndex;
81  int sectionCount;
82  Qt::TimeSpec timeSpec;
83 public:
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);
171 Q_SIGNALS:
172  void dateTimeChanged(const QDateTime &date);
173  void timeChanged(const QTime &date);
174  void dateChanged(const QDate &date);
175 
176 public Q_SLOTS:
177  void setDateTime(const QDateTime &dateTime);
178  void setDate(const QDate &date);
179  void setTime(const QTime &time);
180 
181 protected:
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);
199 private:
202 
203  Q_PRIVATE_SLOT(d_func(), void _q_resetButton())
204 };
205 
207 {
208  Q_OBJECT
209 public:
210  QTimeEdit(QWidget *parent = 0);
211  QTimeEdit(const QTime &time, QWidget *parent = 0);
212 };
213 
215 {
216  Q_OBJECT
217 public:
218  QDateEdit(QWidget *parent = 0);
219  QDateEdit(const QDate &date, QWidget *parent = 0);
220 };
221 
222 Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeEdit::Sections)
223 
224 #endif // QT_NO_DATETIMEEDIT
225 
227 
229 
230 #endif // QDATETIMEEDIT_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
void focusInEvent(QFocusEvent *event)
Reimplemented Function
virtual StepEnabled stepEnabled() const
Virtual function that determines whether stepping up and down is legal at any given time...
The QKeyEvent class describes a key event.
Definition: qevent.h:224
virtual void fixup(QString &input) const
This virtual function is called by the QAbstractSpinBox if the input is not validated to QValidator::...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
void initStyleOption(QStyleOptionSpinBox *option) const
Initialize option with the values from this QSpinBox.
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
virtual void stepBy(int steps)
Virtual function that is called whenever the user triggers a step.
The QTimeEdit class provides a widget for editing times based on the QDateTimeEdit widget...
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QCalendarWidget class provides a monthly based calendar widget allowing the user to select a date...
The QDateEdit class provides a widget for editing dates based on the QDateTimeEdit widget...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void keyPressEvent(QKeyEvent *event)
This function handles keyboard input.
void wheelEvent(QWheelEvent *event)
Reimplemented Function
The QDate class provides date functions.
Definition: qdatetime.h:55
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
void mousePressEvent(QMouseEvent *event)
Reimplemented Function
#define Q_SIGNALS
Definition: qobjectdefs.h:72
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
TimeSpec
Definition: qnamespace.h:1404
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
virtual QValidator::State validate(QString &input, int &pos) const
This virtual function is called by the QAbstractSpinBox to determine whether input is valid...
QSize sizeHint() const
Reimplemented Function
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67
Definition: qnamespace.h:54
quint16 index
void paintEvent(QPaintEvent *event)
Reimplemented Function
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_FLAGS(x)
Definition: qobjectdefs.h:85
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
bool event(QEvent *event)
Reimplemented Function
virtual void clear()
Clears the lineedit of all text but prefix and suffix.
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
#define text
Definition: qobjectdefs.h:80