2 * Copyright 2008 Davide Bettio <davide.bettio@kdemail.net>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef PLASMA_CALENDARWIDGET_H
21 #define PLASMA_CALENDARWIDGET_H
23 #include <QtGui/QGraphicsWidget>
25 #include "plasmaclock_export.h"
27 #include <kcalendarsystem.h>
32 class CalendarTablePrivate
;
34 class PLASMACLOCK_EXPORT CalendarTable
: public QGraphicsWidget
39 enum CellType
{ NoType
= 0,
43 NotInCurrentMonth
= 8 };
44 Q_DECLARE_FLAGS(CellTypes
, CellType
)
46 explicit CalendarTable(QGraphicsWidget
*parent
= 0);
47 CalendarTable(const QDate
&, QGraphicsWidget
*parent
= 0);
50 const KCalendarSystem
*calendar () const;
52 bool setDate(const QDate
&date
);
53 const QDate
& date() const;
55 bool setCalendar(KCalendarSystem
*calendar
= 0);
58 void dateChanged(const QDate
&cur
, const QDate
&old
);
59 void dateChanged(const QDate
&date
);
61 void displayedMonthChanged(int calendarSystemYear
, int calendarSystemMonth
);
62 void displayedYearChanged(int calendarSystemYear
, int calendarSystemMonth
);
65 int cellX(int weekDay
);
68 void paint(QPainter
*p
, const QStyleOptionGraphicsItem
*option
, QWidget
*widget
= 0);
69 void wheelEvent(QGraphicsSceneWheelEvent
*event
);
70 void mousePressEvent(QGraphicsSceneMouseEvent
*event
);
71 void mouseMoveEvent(QGraphicsSceneMouseEvent
*event
);
72 void mouseReleaseEvent(QGraphicsSceneMouseEvent
*event
);
73 void hoverMoveEvent(QGraphicsSceneHoverEvent
*event
);
74 void resizeEvent(QGraphicsSceneResizeEvent
* event
);
76 virtual void paintCell(QPainter
*p
, int cell
, int week
, int weekDay
, CellTypes type
, const QDate
&cellDate
);
77 virtual void paintBorder(QPainter
*p
, int cell
, int week
, int weekDay
, CellTypes type
, const QDate
&cellDate
);
80 friend class CalendarTablePrivate
;
81 CalendarTablePrivate
* const d
;
86 Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::CalendarTable::CellTypes
)