1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.widgets.datetimeedit; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.calendar; 19 import qt.core.coreevent; 20 import qt.core.datetime; 21 import qt.core.flags; 22 import qt.core.metatype; 23 import qt.core.namespace; 24 import qt.core.size; 25 import qt.core.string; 26 import qt.core.variant; 27 import qt.gui.event; 28 import qt.helpers; 29 import qt.widgets.abstractspinbox; 30 import qt.widgets.calendarwidget; 31 import qt.widgets.styleoption; 32 import qt.widgets.widget; 33 version(QT_NO_VALIDATOR){}else 34 import qt.gui.validator; 35 36 /+ QT_REQUIRE_CONFIG(datetimeedit); +/ 37 38 39 extern(C++, class) struct QDateTimeEditPrivate; 40 /+ class QStyleOptionSpinBox; 41 class QCalendarWidget; +/ 42 43 class /+ Q_WIDGETS_EXPORT +/ QDateTimeEdit : QAbstractSpinBox 44 { 45 mixin(Q_OBJECT); 46 47 /+ Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged USER true) 48 Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged) 49 Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged) 50 Q_PROPERTY(QDateTime maximumDateTime READ maximumDateTime WRITE setMaximumDateTime RESET clearMaximumDateTime) 51 Q_PROPERTY(QDateTime minimumDateTime READ minimumDateTime WRITE setMinimumDateTime RESET clearMinimumDateTime) 52 Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate RESET clearMaximumDate) 53 Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate RESET clearMinimumDate) 54 Q_PROPERTY(QTime maximumTime READ maximumTime WRITE setMaximumTime RESET clearMaximumTime) 55 Q_PROPERTY(QTime minimumTime READ minimumTime WRITE setMinimumTime RESET clearMinimumTime) 56 Q_PROPERTY(Section currentSection READ currentSection WRITE setCurrentSection) 57 Q_PROPERTY(Sections displayedSections READ displayedSections) 58 Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat) 59 Q_PROPERTY(bool calendarPopup READ calendarPopup WRITE setCalendarPopup) 60 Q_PROPERTY(int currentSectionIndex READ currentSectionIndex WRITE setCurrentSectionIndex) 61 Q_PROPERTY(int sectionCount READ sectionCount) 62 Q_PROPERTY(Qt::TimeSpec timeSpec READ timeSpec WRITE setTimeSpec) +/ 63 public: 64 enum Section { // a sub-type of QDateTimeParser's like-named enum. 65 NoSection = 0x0000, 66 AmPmSection = 0x0001, 67 MSecSection = 0x0002, 68 SecondSection = 0x0004, 69 MinuteSection = 0x0008, 70 HourSection = 0x0010, 71 DaySection = 0x0100, 72 MonthSection = 0x0200, 73 YearSection = 0x0400, 74 TimeSections_Mask = Section.AmPmSection|Section.MSecSection|Section.SecondSection|Section.MinuteSection|Section.HourSection, 75 DateSections_Mask = Section.DaySection|Section.MonthSection|Section.YearSection 76 } 77 /+ Q_ENUM(Section) +/ 78 79 /+ Q_DECLARE_FLAGS(Sections, Section) +/ 80 alias Sections = QFlags!(Section); /+ Q_FLAG(Sections) +/ 81 82 /+ explicit +/this(QWidget parent = null); 83 /+ explicit +/this(ref const(QDateTime) dt, QWidget parent = null); 84 /+ explicit +/this(ref const(QDate) d, QWidget parent = null); 85 /+ explicit +/this(ref const(QTime) t, QWidget parent = null); 86 ~this(); 87 88 final QDateTime dateTime() const; 89 final QDate date() const; 90 final QTime time() const; 91 92 final QCalendar calendar() const; 93 final void setCalendar(QCalendar calendar); 94 95 final QDateTime minimumDateTime() const; 96 final void clearMinimumDateTime(); 97 final void setMinimumDateTime(ref const(QDateTime) dt); 98 99 final QDateTime maximumDateTime() const; 100 final void clearMaximumDateTime(); 101 final void setMaximumDateTime(ref const(QDateTime) dt); 102 103 final void setDateTimeRange(ref const(QDateTime) min, ref const(QDateTime) max); 104 105 final QDate minimumDate() const; 106 final void setMinimumDate(ref const(QDate) min); 107 final void clearMinimumDate(); 108 109 final QDate maximumDate() const; 110 final void setMaximumDate(ref const(QDate) max); 111 final void clearMaximumDate(); 112 113 final void setDateRange(ref const(QDate) min, ref const(QDate) max); 114 115 final QTime minimumTime() const; 116 final void setMinimumTime(ref const(QTime) min); 117 final void clearMinimumTime(); 118 119 final QTime maximumTime() const; 120 final void setMaximumTime(ref const(QTime) max); 121 final void clearMaximumTime(); 122 123 final void setTimeRange(ref const(QTime) min, ref const(QTime) max); 124 125 final Sections displayedSections() const; 126 final Section currentSection() const; 127 final Section sectionAt(int index) const; 128 final void setCurrentSection(Section section); 129 130 final int currentSectionIndex() const; 131 final void setCurrentSectionIndex(int index); 132 133 final QCalendarWidget calendarWidget() const; 134 final void setCalendarWidget(QCalendarWidget calendarWidget); 135 136 final int sectionCount() const; 137 138 final void setSelectedSection(Section section); 139 140 final QString sectionText(Section section) const; 141 142 final QString displayFormat() const; 143 final void setDisplayFormat(ref const(QString) format); 144 145 final bool calendarPopup() const; 146 final void setCalendarPopup(bool enable); 147 148 final /+ Qt:: +/qt.core.namespace.TimeSpec timeSpec() const; 149 final void setTimeSpec(/+ Qt:: +/qt.core.namespace.TimeSpec spec); 150 151 override QSize sizeHint() const; 152 153 override void clear(); 154 override void stepBy(int steps); 155 156 override bool event(QEvent event); 157 /+ Q_SIGNALS +/public: 158 @QSignal final void dateTimeChanged(ref const(QDateTime) dateTime); 159 @QSignal final void timeChanged(ref const(QTime) time); 160 @QSignal final void dateChanged(ref const(QDate) date); 161 162 public /+ Q_SLOTS +/: 163 @QSlot final void setDateTime(ref const(QDateTime) dateTime); 164 @QSlot final void setDate(ref const(QDate) date); 165 @QSlot final void setTime(ref const(QTime) time); 166 167 protected: 168 override void keyPressEvent(QKeyEvent event); 169 /+ #if QT_CONFIG(wheelevent) +/ 170 override void wheelEvent(QWheelEvent event); 171 /+ #endif +/ 172 override void focusInEvent(QFocusEvent event); 173 override bool focusNextPrevChild(bool next); 174 override QValidator.State validate(ref QString input, ref int pos) const; 175 override void fixup(ref QString input) const; 176 177 /+ virtual +/ QDateTime dateTimeFromText(ref const(QString) text) const; 178 /+ virtual +/ QString textFromDateTime(ref const(QDateTime) dt) const; 179 override StepEnabled stepEnabled() const; 180 override void mousePressEvent(QMouseEvent event); 181 override void paintEvent(QPaintEvent event); 182 // final void initStyleOption(QStyleOptionSpinBox* option) const; 183 184 /+ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/ 185 this(ref const(QVariant) val, QVariant.Type parserType, QWidget parent = null); 186 /+ #endif +/ 187 this(ref const(QVariant) val, QMetaType.Type parserType, QWidget parent = null); 188 private: 189 /+ Q_DECLARE_PRIVATE(QDateTimeEdit) +/ 190 /+ Q_DISABLE_COPY(QDateTimeEdit) +/ 191 192 /+ Q_PRIVATE_SLOT(d_func(), void _q_resetButton()) +/ 193 } 194 195 class /+ Q_WIDGETS_EXPORT +/ QTimeEdit : QDateTimeEdit 196 { 197 mixin(Q_OBJECT); 198 /+ Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY userTimeChanged USER true) +/ 199 public: 200 /+ explicit +/this(QWidget parent = null); 201 /+ explicit +/this(ref const(QTime) time, QWidget parent = null); 202 ~this(); 203 204 /+ Q_SIGNALS +/public: 205 @QSignal final void userTimeChanged(ref const(QTime) time); 206 } 207 208 class /+ Q_WIDGETS_EXPORT +/ QDateEdit : QDateTimeEdit 209 { 210 mixin(Q_OBJECT); 211 /+ Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY userDateChanged USER true) +/ 212 public: 213 /+ explicit +/this(QWidget parent = null); 214 /+ explicit +/this(ref const(QDate) date, QWidget parent = null); 215 ~this(); 216 217 /+ Q_SIGNALS +/public: 218 @QSignal final void userDateChanged(ref const(QDate) date); 219 } 220 /+pragma(inline, true) QFlags!(QDateTimeEdit.Sections.enum_type) operator |(QDateTimeEdit.Sections.enum_type f1, QDateTimeEdit.Sections.enum_type f2)/+noexcept+/{return QFlags!(QDateTimeEdit.Sections.enum_type)(f1)|f2;}+/ 221 /+pragma(inline, true) QFlags!(QDateTimeEdit.Sections.enum_type) operator |(QDateTimeEdit.Sections.enum_type f1, QFlags!(QDateTimeEdit.Sections.enum_type) f2)/+noexcept+/{return f2|f1;}+/ 222 /+pragma(inline, true) QIncompatibleFlag operator |(QDateTimeEdit.Sections.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/ 223 224 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeEdit::Sections) +/