QtGui/qcalendarwidget.h Source File

qcalendarwidget.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 
49 
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
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:
85  LongDayNames
86  };
87 
90  ISOWeekNumbers
91  };
92 
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 
200 
202 
203 #endif // QCALENDARWIDGET_H
204 
GLint mode
Definition: GLee.h:4479
virtual bool eventFilter(QObject *, QEvent *)
bool event(QEvent *)
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
int int * max
Definition: GLee.h:10568
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
bool isNavigationBarVisible() const
virtual void keyPressEvent(QKeyEvent *)
Definition: qnamespace.h:54
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
virtual void resizeEvent(QResizeEvent *)
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLenum GLsizei GLenum format
Definition: GLee.h:873
DayOfWeek
Definition: qnamespace.h:1410
virtual QSize sizeHint() const
#define Q_OBJECT
Definition: qobjectdefs.h:157
Definition: qrect.h:58
Definition: qsize.h:53
SelectionMode
Definition: preferences.h:40
virtual void mousePressEvent(QMouseEvent *)
virtual QSize minimumSizeHint() const
#define QT_END_HEADER
Definition: qglobal.h:142