[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 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 | **
|
---|
[561] | 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.
|
---|
[2] | 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 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 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 |
|
---|
| 49 | QT_BEGIN_HEADER
|
---|
| 50 |
|
---|
| 51 | QT_BEGIN_NAMESPACE
|
---|
| 52 |
|
---|
| 53 | QT_MODULE(Gui)
|
---|
| 54 |
|
---|
| 55 | #ifndef QT_NO_DATETIMEEDIT
|
---|
| 56 |
|
---|
| 57 | class QDateTimeEditPrivate;
|
---|
| 58 | class QStyleOptionSpinBox;
|
---|
| 59 | class QCalendarWidget;
|
---|
| 60 |
|
---|
| 61 | class 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)
|
---|
| 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:
|
---|
| 200 | Q_DECLARE_PRIVATE(QDateTimeEdit)
|
---|
| 201 | Q_DISABLE_COPY(QDateTimeEdit)
|
---|
| 202 |
|
---|
| 203 | Q_PRIVATE_SLOT(d_func(), void _q_resetButton())
|
---|
| 204 | };
|
---|
| 205 |
|
---|
| 206 | class Q_GUI_EXPORT QTimeEdit : public QDateTimeEdit
|
---|
| 207 | {
|
---|
| 208 | Q_OBJECT
|
---|
| 209 | public:
|
---|
| 210 | QTimeEdit(QWidget *parent = 0);
|
---|
| 211 | QTimeEdit(const QTime &time, QWidget *parent = 0);
|
---|
| 212 | };
|
---|
| 213 |
|
---|
| 214 | class Q_GUI_EXPORT QDateEdit : public QDateTimeEdit
|
---|
| 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 |
|
---|
| 226 | QT_END_NAMESPACE
|
---|
| 227 |
|
---|
| 228 | QT_END_HEADER
|
---|
| 229 |
|
---|
| 230 | #endif // QDATETIMEEDIT_H
|
---|