KDEUI
kdatetimeedit.h
Go to the documentation of this file.
00001 /* 00002 Copyright 2011 John Layt <john@layt.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KDATETIMEEDIT_H 00021 #define KDATETIMEEDIT_H 00022 00023 #include <kdeui_export.h> 00024 00025 #include <QtGui/QWidget> 00026 00027 #include "klocale.h" 00028 #include "kdatetime.h" 00029 00030 class KDateTimeEditPrivate; 00031 class KCalendarSystem; 00032 00033 class KDEUI_EXPORT KDateTimeEdit : public QWidget 00034 { 00035 Q_OBJECT 00036 00037 Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true) 00038 Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged USER true) 00039 Q_PROPERTY(int timeListInterval READ timeListInterval WRITE setTimeListInterval) 00040 Q_PROPERTY(Options options READ options WRITE setOptions) 00041 Q_FLAGS(Options) 00042 00043 public: 00044 00050 enum Option { 00051 ShowCalendar = 0x00001, 00052 ShowDate = 0x00002, 00053 ShowTime = 0x00004, 00054 ShowTimeSpec = 0x00008, 00055 //EditCalendar = 0x00010, /**< Allow the user to manually edit the calendar */ 00056 EditDate = 0x00020, 00057 EditTime = 0x00040, 00058 //EditTimeSpec = 0x00080, /**< Allow the user to manually edit the time spec */ 00059 SelectCalendar = 0x00100, 00060 SelectDate = 0x00200, 00061 SelectTime = 0x00400, 00062 SelectTimeSpec = 0x00800, 00063 DatePicker = 0x01000, 00064 DateKeywords = 0x02000, 00065 ForceTime = 0x04000, 00066 WarnOnInvalid = 0x08000 00067 }; 00068 Q_DECLARE_FLAGS(Options, Option) 00069 00070 00073 explicit KDateTimeEdit(QWidget *parent = 0); 00074 00078 virtual ~KDateTimeEdit(); 00079 00085 Options options() const; 00086 00092 KDateTime dateTime() const; 00093 00101 KLocale::CalendarSystem calendarSystem() const; 00102 00116 const KCalendarSystem *calendar() const; 00117 00123 QDate date() const; 00124 00130 QTime time() const; 00131 00137 KDateTime::Spec timeSpec() const; 00138 00144 QList<KLocale::CalendarSystem> calendarSystemsList() const; 00145 00151 KDateTime minimumDateTime() const; 00152 00158 KDateTime maximumDateTime() const; 00159 00167 KLocale::DateFormat dateDisplayFormat() const; 00168 00176 QMap<QDate, QString> dateMap() const; 00177 00185 KLocale::TimeFormatOptions timeDisplayFormat() const; 00186 00192 int timeListInterval() const; 00193 00202 QList<QTime> timeList() const; 00203 00209 KTimeZones::ZoneMap timeZones() const; 00210 00219 bool isValid() const; 00220 00227 bool isNull() const; 00228 00237 bool isValidDate() const; 00238 00245 bool isNullDate() const; 00254 bool isValidTime() const; 00255 00262 bool isNullTime() const; 00263 00264 Q_SIGNALS: 00265 00273 void dateTimeEntered(const KDateTime &dateTime); 00274 00283 void dateTimeChanged(const KDateTime &dateTime); 00284 00292 void dateTimeEdited(const KDateTime &dateTime); 00293 00299 void calendarEntered(KLocale::CalendarSystem calendarSystem); 00300 00307 void calendarChanged(KLocale::CalendarSystem calendarSystem); 00308 00316 void dateEntered(const QDate &date); 00317 00326 void dateChanged(const QDate &date); 00327 00335 void dateEdited(const QDate &date); 00336 00344 void timeEntered(const QTime &time); 00345 00354 void timeChanged(const QTime &time); 00355 00363 void timeEdited(const QTime &time); 00364 00370 void timeSpecEntered(const KDateTime::Spec &spec); 00371 00378 void timeSpecChanged(const KDateTime::Spec &spec); 00379 00380 public Q_SLOTS: 00381 00387 void setOptions(Options options); 00388 00394 void setDateTime(const KDateTime &dateTime); 00395 00403 void setCalendarSystem(KLocale::CalendarSystem calendarSystem); 00404 00412 void setCalendar(KCalendarSystem *calendar = 0); 00413 00419 void setDate(const QDate &date); 00420 00426 void setTime(const QTime &time); 00427 00433 void setTimeSpec(const KDateTime::Spec &spec); 00434 00447 void setDateTimeRange(const KDateTime &minDateTime, 00448 const KDateTime &maxDateTime, 00449 const QString &minWarnMsg = QString(), 00450 const QString &maxWarnMsg = QString()); 00451 00455 void resetDateTimeRange(); 00456 00468 void setMinimumDateTime(const KDateTime &minDateTime, const QString &minWarnMsg = QString()); 00469 00473 void resetMinimumDateTime(); 00474 00486 void setMaximumDateTime(const KDateTime &maxDateTime, const QString &maxWarnMsg = QString()); 00487 00491 void resetMaximumDateTime(); 00492 00500 void setDateDisplayFormat(KLocale::DateFormat format); 00501 00507 void setCalendarSystemsList(QList<KLocale::CalendarSystem> calendars); 00508 00524 void setDateMap(QMap<QDate, QString> dateMap); 00525 00533 void setTimeDisplayFormat(KLocale::TimeFormatOptions formatOptions); 00534 00554 void setTimeListInterval(int minutes); 00555 00573 void setTimeList(QList<QTime> timeList, 00574 const QString &minWarnMsg = QString(), 00575 const QString &maxWarnMsg = QString()); 00576 00582 void setTimeZones(const KTimeZones::ZoneMap &zones); 00583 00584 protected: 00585 00586 virtual bool eventFilter(QObject *object, QEvent *event); 00587 virtual void focusInEvent(QFocusEvent *event); 00588 virtual void focusOutEvent(QFocusEvent *event); 00589 virtual void resizeEvent(QResizeEvent *event); 00590 00599 virtual void assignDateTime(const KDateTime &dateTime); 00600 00609 virtual void assignDate(const QDate &date); 00610 00619 void assignCalendarSystem(KLocale::CalendarSystem calendarSystem); 00620 00629 virtual void assignTime(const QTime &time); 00630 00639 void assignTimeSpec(const KDateTime::Spec &spec); 00640 00641 private: 00642 00643 friend class KDateTimeEditPrivate; 00644 KDateTimeEditPrivate *const d; 00645 00646 Q_PRIVATE_SLOT(d, void selectCalendar(int)) 00647 Q_PRIVATE_SLOT(d, void enterCalendar(KLocale::CalendarSystem)) 00648 Q_PRIVATE_SLOT(d, void selectTimeZone(int)) 00649 Q_PRIVATE_SLOT(d, void enterTimeZone(const QString&)) 00650 }; 00651 00652 Q_DECLARE_OPERATORS_FOR_FLAGS(KDateTimeEdit::Options) 00653 00654 #endif // KDATETIMEEDIT_H
KDE 4.7 API Reference