[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 QCALENDARWIDGET_H
|
---|
| 43 | #define QCALENDARWIDGET_H
|
---|
| 44 |
|
---|
| 45 | #include <QtGui/qwidget.h>
|
---|
| 46 | #include <QtCore/qdatetime.h>
|
---|
| 47 |
|
---|
| 48 | QT_BEGIN_HEADER
|
---|
| 49 |
|
---|
| 50 | QT_BEGIN_NAMESPACE
|
---|
| 51 |
|
---|
| 52 | QT_MODULE(Gui)
|
---|
| 53 |
|
---|
| 54 | #ifndef QT_NO_CALENDARWIDGET
|
---|
| 55 |
|
---|
| 56 | class QDate;
|
---|
| 57 | class QTextCharFormat;
|
---|
| 58 | class QCalendarWidgetPrivate;
|
---|
| 59 |
|
---|
| 60 | class Q_GUI_EXPORT QCalendarWidget : public QWidget
|
---|
| 61 | {
|
---|
| 62 | Q_OBJECT
|
---|
| 63 | Q_ENUMS(Qt::DayOfWeek)
|
---|
| 64 | Q_ENUMS(HorizontalHeaderFormat)
|
---|
| 65 | Q_ENUMS(VerticalHeaderFormat)
|
---|
| 66 | Q_ENUMS(SelectionMode)
|
---|
| 67 | Q_PROPERTY(QDate selectedDate READ selectedDate WRITE setSelectedDate)
|
---|
| 68 | Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate)
|
---|
| 69 | Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate)
|
---|
| 70 | Q_PROPERTY(Qt::DayOfWeek firstDayOfWeek READ firstDayOfWeek WRITE setFirstDayOfWeek)
|
---|
| 71 | Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible)
|
---|
| 72 | Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
|
---|
| 73 | Q_PROPERTY(HorizontalHeaderFormat horizontalHeaderFormat READ horizontalHeaderFormat WRITE setHorizontalHeaderFormat)
|
---|
| 74 | Q_PROPERTY(VerticalHeaderFormat verticalHeaderFormat READ verticalHeaderFormat WRITE setVerticalHeaderFormat)
|
---|
| 75 | Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible STORED false DESIGNABLE false) // obsolete
|
---|
| 76 | Q_PROPERTY(bool navigationBarVisible READ isNavigationBarVisible WRITE setNavigationBarVisible)
|
---|
| 77 | Q_PROPERTY(bool dateEditEnabled READ isDateEditEnabled WRITE setDateEditEnabled)
|
---|
| 78 | Q_PROPERTY(int dateEditAcceptDelay READ dateEditAcceptDelay WRITE setDateEditAcceptDelay)
|
---|
| 79 |
|
---|
| 80 | public:
|
---|
| 81 | enum HorizontalHeaderFormat {
|
---|
| 82 | NoHorizontalHeader,
|
---|
| 83 | SingleLetterDayNames,
|
---|
| 84 | ShortDayNames,
|
---|
| 85 | LongDayNames
|
---|
| 86 | };
|
---|
| 87 |
|
---|
| 88 | enum VerticalHeaderFormat {
|
---|
| 89 | NoVerticalHeader,
|
---|
| 90 | ISOWeekNumbers
|
---|
| 91 | };
|
---|
| 92 |
|
---|
| 93 | enum SelectionMode {
|
---|
| 94 | NoSelection,
|
---|
| 95 | SingleSelection
|
---|
| 96 | };
|
---|
| 97 |
|
---|
| 98 | explicit QCalendarWidget(QWidget *parent = 0);
|
---|
| 99 | ~QCalendarWidget();
|
---|
| 100 |
|
---|
| 101 | virtual QSize sizeHint() const;
|
---|
| 102 | virtual QSize minimumSizeHint() const;
|
---|
| 103 |
|
---|
| 104 | QDate selectedDate() const;
|
---|
| 105 |
|
---|
| 106 | int yearShown() const;
|
---|
| 107 | int monthShown() const;
|
---|
| 108 |
|
---|
| 109 | QDate minimumDate() const;
|
---|
| 110 | void setMinimumDate(const QDate &date);
|
---|
| 111 |
|
---|
| 112 | QDate maximumDate() const;
|
---|
| 113 | void setMaximumDate(const QDate &date);
|
---|
| 114 |
|
---|
| 115 | Qt::DayOfWeek firstDayOfWeek() const;
|
---|
| 116 | void setFirstDayOfWeek(Qt::DayOfWeek dayOfWeek);
|
---|
| 117 |
|
---|
| 118 | // ### Qt 5: eliminate these two
|
---|
| 119 | bool isHeaderVisible() const;
|
---|
| 120 | void setHeaderVisible(bool show);
|
---|
| 121 |
|
---|
| 122 | inline bool isNavigationBarVisible() const { return isHeaderVisible(); }
|
---|
| 123 |
|
---|
| 124 | bool isGridVisible() const;
|
---|
| 125 |
|
---|
| 126 | SelectionMode selectionMode() const;
|
---|
| 127 | void setSelectionMode(SelectionMode mode);
|
---|
| 128 |
|
---|
| 129 | HorizontalHeaderFormat horizontalHeaderFormat() const;
|
---|
| 130 | void setHorizontalHeaderFormat(HorizontalHeaderFormat format);
|
---|
| 131 |
|
---|
| 132 | VerticalHeaderFormat verticalHeaderFormat() const;
|
---|
| 133 | void setVerticalHeaderFormat(VerticalHeaderFormat format);
|
---|
| 134 |
|
---|
| 135 | QTextCharFormat headerTextFormat() const;
|
---|
| 136 | void setHeaderTextFormat(const QTextCharFormat &format);
|
---|
| 137 |
|
---|
| 138 | QTextCharFormat weekdayTextFormat(Qt::DayOfWeek dayOfWeek) const;
|
---|
| 139 | void setWeekdayTextFormat(Qt::DayOfWeek dayOfWeek, const QTextCharFormat &format);
|
---|
| 140 |
|
---|
| 141 | QMap<QDate, QTextCharFormat> dateTextFormat() const;
|
---|
| 142 | QTextCharFormat dateTextFormat(const QDate &date) const;
|
---|
| 143 | void setDateTextFormat(const QDate &date, const QTextCharFormat &format);
|
---|
| 144 |
|
---|
| 145 | bool isDateEditEnabled() const;
|
---|
| 146 | void setDateEditEnabled(bool enable);
|
---|
| 147 |
|
---|
| 148 | int dateEditAcceptDelay() const;
|
---|
| 149 | void setDateEditAcceptDelay(int delay);
|
---|
| 150 |
|
---|
| 151 | protected:
|
---|
| 152 | bool event(QEvent *event);
|
---|
| 153 | bool eventFilter(QObject *watched, QEvent *event);
|
---|
| 154 | void mousePressEvent(QMouseEvent *event);
|
---|
| 155 | void resizeEvent(QResizeEvent * event);
|
---|
| 156 | void keyPressEvent(QKeyEvent * event);
|
---|
| 157 |
|
---|
| 158 | virtual void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;
|
---|
| 159 | void updateCell(const QDate &date);
|
---|
| 160 | void updateCells();
|
---|
| 161 |
|
---|
| 162 | public Q_SLOTS:
|
---|
| 163 | void setSelectedDate(const QDate &date);
|
---|
| 164 | void setDateRange(const QDate &min, const QDate &max);
|
---|
| 165 | void setCurrentPage(int year, int month);
|
---|
| 166 | void setGridVisible(bool show);
|
---|
| 167 | void setNavigationBarVisible(bool visible);
|
---|
| 168 | void showNextMonth();
|
---|
| 169 | void showPreviousMonth();
|
---|
| 170 | void showNextYear();
|
---|
| 171 | void showPreviousYear();
|
---|
| 172 | void showSelectedDate();
|
---|
| 173 | void showToday();
|
---|
| 174 |
|
---|
| 175 | Q_SIGNALS:
|
---|
| 176 | void selectionChanged();
|
---|
| 177 | void clicked(const QDate &date);
|
---|
| 178 | void activated(const QDate &date);
|
---|
| 179 | void currentPageChanged(int year, int month);
|
---|
| 180 |
|
---|
| 181 | private:
|
---|
| 182 | Q_DECLARE_PRIVATE(QCalendarWidget)
|
---|
| 183 | Q_DISABLE_COPY(QCalendarWidget)
|
---|
| 184 |
|
---|
| 185 | Q_PRIVATE_SLOT(d_func(), void _q_slotShowDate(const QDate &date))
|
---|
| 186 | Q_PRIVATE_SLOT(d_func(), void _q_slotChangeDate(const QDate &date))
|
---|
| 187 | Q_PRIVATE_SLOT(d_func(), void _q_slotChangeDate(const QDate &date, bool changeMonth))
|
---|
| 188 | Q_PRIVATE_SLOT(d_func(), void _q_editingFinished())
|
---|
| 189 | Q_PRIVATE_SLOT(d_func(), void _q_prevMonthClicked())
|
---|
| 190 | Q_PRIVATE_SLOT(d_func(), void _q_nextMonthClicked())
|
---|
| 191 | Q_PRIVATE_SLOT(d_func(), void _q_yearEditingFinished())
|
---|
| 192 | Q_PRIVATE_SLOT(d_func(), void _q_yearClicked())
|
---|
| 193 | Q_PRIVATE_SLOT(d_func(), void _q_monthChanged(QAction *act))
|
---|
| 194 |
|
---|
| 195 | };
|
---|
| 196 |
|
---|
| 197 | #endif // QT_NO_CALENDARWIDGET
|
---|
| 198 |
|
---|
| 199 | QT_END_NAMESPACE
|
---|
| 200 |
|
---|
| 201 | QT_END_HEADER
|
---|
| 202 |
|
---|
| 203 | #endif // QCALENDARWIDGET_H
|
---|
| 204 |
|
---|