not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / libs / plasmaclock / calendartable.h
blobb6674c5d67789ec3849ad911a8acb88dfb94fde8
1 /*
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>
29 namespace Plasma
32 class CalendarTablePrivate;
34 class PLASMACLOCK_EXPORT CalendarTable : public QGraphicsWidget
36 Q_OBJECT
38 public:
39 enum CellType { NoType = 0,
40 Today = 1,
41 Selected = 2,
42 Hovered = 4,
43 NotInCurrentMonth = 8 };
44 Q_DECLARE_FLAGS(CellTypes, CellType)
46 explicit CalendarTable(QGraphicsWidget *parent = 0);
47 CalendarTable(const QDate &, QGraphicsWidget *parent = 0);
48 ~CalendarTable();
50 const KCalendarSystem *calendar () const;
52 bool setDate(const QDate &date);
53 const QDate& date() const;
55 bool setCalendar(KCalendarSystem *calendar = 0);
57 Q_SIGNALS:
58 void dateChanged(const QDate &cur, const QDate &old);
59 void dateChanged(const QDate &date);
60 void tableClicked();
61 void displayedMonthChanged(int calendarSystemYear, int calendarSystemMonth);
62 void displayedYearChanged(int calendarSystemYear, int calendarSystemMonth);
64 protected:
65 int cellX(int weekDay);
66 int cellY(int week);
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);
79 private:
80 friend class CalendarTablePrivate;
81 CalendarTablePrivate* const d;
86 Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::CalendarTable::CellTypes)
87 #endif