Qt 4.8
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;
59 
61 {
62  Q_OBJECT
67  QDate selectedDate;
68  QDate minimumDate;
69  QDate maximumDate;
70  Qt::DayOfWeek firstDayOfWeek;
71  bool gridVisible;
72  SelectionMode selectionMode;
73  HorizontalHeaderFormat horizontalHeaderFormat;
74  VerticalHeaderFormat verticalHeaderFormat;
75  bool headerVisible; // obsolete
76  bool navigationBarVisible;
77  bool dateEditEnabled;
78  int dateEditAcceptDelay;
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:
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 
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QKeyEvent class describes a key event.
Definition: qevent.h:224
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
virtual QSize minimumSizeHint() const
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QCalendarWidget class provides a monthly based calendar widget allowing the user to select a date...
virtual void mousePressEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition: qwidget.cpp:9261
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition: qwidget.cpp:9587
The QDate class provides date functions.
Definition: qdatetime.h:55
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
DayOfWeek
Definition: qnamespace.h:1410
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
SelectionMode
This enum describes the types of selection offered to the user for selecting dates in the calendar...
virtual QSize sizeHint() const
bool isNavigationBarVisible() const
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
virtual void keyPressEvent(QKeyEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
Definition: qwidget.cpp:9375
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
HorizontalHeaderFormat
This enum type defines the various formats the horizontal header can display.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
VerticalHeaderFormat
This enum type defines the various formats the vertical header can display.