source: trunk/src/gui/widgets/qcalendarwidget.h@ 324

Last change on this file since 324 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 7.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
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**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
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
48QT_BEGIN_HEADER
49
50QT_BEGIN_NAMESPACE
51
52QT_MODULE(Gui)
53
54#ifndef QT_NO_CALENDARWIDGET
55
56class QDate;
57class QTextCharFormat;
58class QCalendarWidgetPrivate;
59
60class 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
80public:
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
151protected:
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
162public 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
175Q_SIGNALS:
176 void selectionChanged();
177 void clicked(const QDate &date);
178 void activated(const QDate &date);
179 void currentPageChanged(int year, int month);
180
181private:
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
199QT_END_NAMESPACE
200
201QT_END_HEADER
202
203#endif // QCALENDARWIDGET_H
204
Note: See TracBrowser for help on using the repository browser.