summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.h
Unidiff
Diffstat (limited to 'korganizer/kodaymatrix.h') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index c049942..39946de 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -1,321 +1,322 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KODAYMAT_H 23#ifndef _KODAYMAT_H
24#define _KODAYMAT_H 24#define _KODAYMAT_H
25 25
26#include <libkcal/calendar.h> 26#include <libkcal/calendar.h>
27 27
28#include <qstring.h> 28#include <qstring.h>
29#include <qframe.h> 29#include <qframe.h>
30#include <qcolor.h> 30#include <qcolor.h>
31#include <qpen.h> 31#include <qpen.h>
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qtooltip.h> 33#include <qtooltip.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35#include <qbitarray.h> 35#include <qbitarray.h>
36#include <qmap.h> 36#include <qmap.h>
37 37
38class QDragEnterEvent; 38class QDragEnterEvent;
39class QDragMoveEvent; 39class QDragMoveEvent;
40class QDragLeaveEvent; 40class QDragLeaveEvent;
41class QDropEvent; 41class QDropEvent;
42 42
43class KODayMatrix; 43class KODayMatrix;
44 44
45using namespace KCal; 45using namespace KCal;
46 46
47 47
48/** 48/**
49 * small helper class to dynamically show tooltips inside the day matrix. 49 * small helper class to dynamically show tooltips inside the day matrix.
50 * This class asks the day matrix object for a appropriate label which 50 * This class asks the day matrix object for a appropriate label which
51 * is in our special case the name of the holiday or null if this day is no holiday. 51 * is in our special case the name of the holiday or null if this day is no holiday.
52 */ 52 */
53class DynamicTip : public QToolTip 53class DynamicTip : public QToolTip
54{ 54{
55public: 55public:
56 56
57 /** 57 /**
58 * Constructor that expects a KODayMatrix object as parent. 58 * Constructor that expects a KODayMatrix object as parent.
59 * 59 *
60 * @param parent the parent KODayMatrix control. 60 * @param parent the parent KODayMatrix control.
61 */ 61 */
62 DynamicTip(QWidget* parent ); 62 DynamicTip(QWidget* parent );
63 63
64protected: 64protected:
65 65
66 /** 66 /**
67 * Qt's callback to ask the object to provide an approrpiate text for the 67 * Qt's callback to ask the object to provide an approrpiate text for the
68 * tooltip to be shown. 68 * tooltip to be shown.
69 * 69 *
70 * @param pos coordinates of the mouse. 70 * @param pos coordinates of the mouse.
71 */ 71 */
72 void maybeTip( const QPoint & pos); 72 void maybeTip( const QPoint & pos);
73 73
74private: 74private:
75 75
76 /** the parent control this tooltip is designed for. */ 76 /** the parent control this tooltip is designed for. */
77 KODayMatrix* matrix; 77 KODayMatrix* matrix;
78}; 78};
79 79
80/** 80/**
81 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. 81 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed.
82 * Cornelius thought this was a waste of memory and a lot of overhead. 82 * Cornelius thought this was a waste of memory and a lot of overhead.
83 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame 83 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame
84 * that draws the labels and allows for dragging selection while maintaining nearly full 84 * that draws the labels and allows for dragging selection while maintaining nearly full
85 * compatibility in behaviour with its predecessor. 85 * compatibility in behaviour with its predecessor.
86 * 86 *
87 * The following functionality has been changed: 87 * The following functionality has been changed:
88 * 88 *
89 * o when shifting events in the agenda view from one day to another the day matrix is updated now 89 * o when shifting events in the agenda view from one day to another the day matrix is updated now
90 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. 90 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date.
91 * o no support for Ctrl+click to create groups of dates 91 * o no support for Ctrl+click to create groups of dates
92 * (This has not really been supported in the predecessor. It was not very intuitive nor was it 92 * (This has not really been supported in the predecessor. It was not very intuitive nor was it
93 * user friendly.) 93 * user friendly.)
94 * This feature has been replaced with dragging a selection on the matrix. The matrix will 94 * This feature has been replaced with dragging a selection on the matrix. The matrix will
95 * automatically choose the appropriate selection (e.g. you are not any longer able to select 95 * automatically choose the appropriate selection (e.g. you are not any longer able to select
96 * two distinct groups of date selections as in the old class) 96 * two distinct groups of date selections as in the old class)
97 * o now that you can select more then a week it can happen that not all selected days are 97 * o now that you can select more then a week it can happen that not all selected days are
98 * displayed in the matrix. However this is preferred to the alternative which would mean to 98 * displayed in the matrix. However this is preferred to the alternative which would mean to
99 * adjust the selection and leave some days undisplayed while scrolling through the months 99 * adjust the selection and leave some days undisplayed while scrolling through the months
100 * 100 *
101 * @short day matrix widget of the KDateNavigator 101 * @short day matrix widget of the KDateNavigator
102 * 102 *
103 * @author Eitzenberger Thomas 103 * @author Eitzenberger Thomas
104 */ 104 */
105class KODayMatrix: public QFrame { 105class KODayMatrix: public QFrame {
106 106
107 Q_OBJECT 107 Q_OBJECT
108 108
109public: 109public:
110 110
111 /** constructor to create a day matrix widget. 111 /** constructor to create a day matrix widget.
112 * 112 *
113 * @param parent widget that is the parent of the day matrix. Normally this should 113 * @param parent widget that is the parent of the day matrix. Normally this should
114 * be a KDateNavigator 114 * be a KDateNavigator
115 * @param calendar instance of a calendar on which all calculations are based 115 * @param calendar instance of a calendar on which all calculations are based
116 * @param date start date of the matrix (is expected to be already fixed). It is 116 * @param date start date of the matrix (is expected to be already fixed). It is
117 * assumed that this date is the first week day to be shown in the matrix. 117 * assumed that this date is the first week day to be shown in the matrix.
118 * @param name name of the widget 118 * @param name name of the widget
119 */ 119 */
120 KODayMatrix( QWidget *parent, const char *name ); 120 KODayMatrix( QWidget *parent, const char *name );
121 //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); 121 //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name );
122 122
123 /** destructor that deallocates all dynamically allocated private members. 123 /** destructor that deallocates all dynamically allocated private members.
124 */ 124 */
125 ~KODayMatrix(); 125 ~KODayMatrix();
126 126
127 /** updates the day matrix to start with the given date. Does all the necessary 127 /** updates the day matrix to start with the given date. Does all the necessary
128 * checks for holidays or events on a day and stores them for display later on. 128 * checks for holidays or events on a day and stores them for display later on.
129 * Does NOT update the view visually. Call repaint() for this. 129 * Does NOT update the view visually. Call repaint() for this.
130 * 130 *
131 * @param actdate recalculates the day matrix to show NUMDAYS starting from this 131 * @param actdate recalculates the day matrix to show NUMDAYS starting from this
132 * date. 132 * date.
133 */ 133 */
134 void updateView(QDate actdate); 134 void updateView(QDate actdate);
135 void updateEvents(); 135 void updateEvents();
136 136
137 /** returns the QDate object associated with day indexed by the 137 /** returns the QDate object associated with day indexed by the
138 * supplied offset. 138 * supplied offset.
139 */ 139 */
140 const QDate& getDate(int offset); 140 const QDate& getDate(int offset);
141 void setCalendar( Calendar * ); 141 void setCalendar( Calendar * );
142 /** returns the official name of this holy day or 0 if there is no label 142 /** returns the official name of this holy day or 0 if there is no label
143 * for this day. 143 * for this day.
144 */ 144 */
145 QString getHolidayLabel(int offset); 145 QString getHolidayLabel(int offset);
146 146
147 /** adds all actual selected days from mSelStart to mSelEnd to the supplied 147 /** adds all actual selected days from mSelStart to mSelEnd to the supplied
148 * DateList. 148 * DateList.
149 */ 149 */
150 void addSelectedDaysTo(DateList&); 150 void addSelectedDaysTo(DateList&);
151 151
152 /** sets the actual to be displayed selection in the day matrix starting from 152 /** sets the actual to be displayed selection in the day matrix starting from
153 * start and ending with end. Theview must be manually updated by calling 153 * start and ending with end. Theview must be manually updated by calling
154 * repaint. (?) 154 * repaint. (?)
155 */ 155 */
156 void setSelectedDaysFrom(const QDate& start, const QDate& end); 156 void setSelectedDaysFrom(const QDate& start, const QDate& end);
157 void clearSelection(); 157 void clearSelection();
158 158
159 /** Is today visible in the view? Keep this in sync with 159 /** Is today visible in the view? Keep this in sync with
160 * the values today (below) can take. 160 * the values today (below) can take.
161 */ 161 */
162 bool isTodayVisible() const { return today>=0; } ; 162 bool isTodayVisible() const { return today>=0; } ;
163 163
164 /** If today is visible, then we can find out if today is 164 /** If today is visible, then we can find out if today is
165 * near the beginning or the end of the month. 165 * near the beginning or the end of the month.
166 * This is dependent on today remaining the index 166 * This is dependent on today remaining the index
167 * in the array of visible dates and going from 167 * in the array of visible dates and going from
168 * top left (0) to bottom right (41). 168 * top left (0) to bottom right (41).
169 */ 169 */
170 bool isBeginningOfMonth() const { return today<=8; } ; 170 bool isBeginningOfMonth() const { return today<=8; } ;
171 bool isEndOfMonth() const { return today>=27; } ; 171 bool isEndOfMonth() const { return today>=27; } ;
172 QString getWhatsThisText( QPoint ) ; 172 QString getWhatsThisText( QPoint ) ;
173 QSize sizeHint() const;
173 174
174public slots: 175public slots:
175 /** Recalculates all the flags of the days in the matrix like holidays or events 176 /** Recalculates all the flags of the days in the matrix like holidays or events
176 * on a day (Actually calls above method with the actual startdate). 177 * on a day (Actually calls above method with the actual startdate).
177 */ 178 */
178 void updateView(); 179 void updateView();
179 void updateViewTimed(); 180 void updateViewTimed();
180 void repaintViewTimed(); 181 void repaintViewTimed();
181 182
182 /** 183 /**
183 * Calculate which square in the matrix should be 184 * Calculate which square in the matrix should be
184 * hilighted to indicate it's today. 185 * hilighted to indicate it's today.
185 */ 186 */
186 void recalculateToday(); 187 void recalculateToday();
187 188
188/* 189/*
189 void setStartDate(QDate); 190 void setStartDate(QDate);
190*/ 191*/
191 192
192signals: 193signals:
193 194
194 /** emitted if the user selects a block of days with the mouse by dragging a rectangle 195 /** emitted if the user selects a block of days with the mouse by dragging a rectangle
195 * inside the matrix 196 * inside the matrix
196 * 197 *
197 * @param daylist list of days that have been selected by the user 198 * @param daylist list of days that have been selected by the user
198 */ 199 */
199 void selected( const KCal::DateList &daylist ); 200 void selected( const KCal::DateList &daylist );
200 201
201 /** emitted if the user has dropped an event inside the matrix 202 /** emitted if the user has dropped an event inside the matrix
202 * 203 *
203 * @param event the dropped calendar event 204 * @param event the dropped calendar event
204 */ 205 */
205 void eventDropped(Event *event); 206 void eventDropped(Event *event);
206 207
207protected: 208protected:
208 209
209 void paintEvent(QPaintEvent *ev); 210 void paintEvent(QPaintEvent *ev);
210 211
211 void mousePressEvent (QMouseEvent* e); 212 void mousePressEvent (QMouseEvent* e);
212 213
213 void mouseReleaseEvent (QMouseEvent* e); 214 void mouseReleaseEvent (QMouseEvent* e);
214 215
215 void mouseMoveEvent (QMouseEvent* e); 216 void mouseMoveEvent (QMouseEvent* e);
216 217
217 void dragEnterEvent(QDragEnterEvent *); 218 void dragEnterEvent(QDragEnterEvent *);
218 219
219 void dragMoveEvent(QDragMoveEvent *); 220 void dragMoveEvent(QDragMoveEvent *);
220 221
221 void dragLeaveEvent(QDragLeaveEvent *); 222 void dragLeaveEvent(QDragLeaveEvent *);
222 223
223 void dropEvent(QDropEvent *); 224 void dropEvent(QDropEvent *);
224 225
225 void resizeEvent(QResizeEvent *); 226 void resizeEvent(QResizeEvent *);
226 227
227private: 228private:
228 bool mouseDown; 229 bool mouseDown;
229 QBitArray bDays; 230 QBitArray bDays;
230 QPixmap myPix; 231 QPixmap myPix;
231 QTimer* mUpdateTimer; 232 QTimer* mUpdateTimer;
232 QTimer* mRepaintTimer; 233 QTimer* mRepaintTimer;
233 bool mDayChanged; 234 bool mDayChanged;
234 bool mPendingUpdateBeforeRepaint; 235 bool mPendingUpdateBeforeRepaint;
235 236
236 /** returns the index of the day located at the matrix's widget (x,y) position. 237 /** returns the index of the day located at the matrix's widget (x,y) position.
237 * 238 *
238 * @param x horizontal coordinate 239 * @param x horizontal coordinate
239 * @param y vertical coordinate 240 * @param y vertical coordinate
240 */ 241 */
241 int getDayIndexFrom(int x, int y); 242 int getDayIndexFrom(int x, int y);
242 243
243 /** calculates a "shaded" color from the supplied color object. 244 /** calculates a "shaded" color from the supplied color object.
244 * (Copied from Cornelius's kdpdatebutton.cpp) 245 * (Copied from Cornelius's kdpdatebutton.cpp)
245 * 246 *
246 * @param color source based on which a shaded color should be calculated. 247 * @param color source based on which a shaded color should be calculated.
247 */ 248 */
248 QColor getShadedColor(QColor color); 249 QColor getShadedColor(QColor color);
249 250
250 /** number of days to be displayed. For now there is no support for any other number then 42. 251 /** number of days to be displayed. For now there is no support for any other number then 42.
251 so change it at your own risk :o) */ 252 so change it at your own risk :o) */
252 static const int NUMDAYS; 253 static const int NUMDAYS;
253 254
254 /** calendar instance to be queried for holidays, events, ... */ 255 /** calendar instance to be queried for holidays, events, ... */
255 Calendar *mCalendar; 256 Calendar *mCalendar;
256 257
257 /** starting date of the matrix */ 258 /** starting date of the matrix */
258 QDate startdate; 259 QDate startdate;
259 260
260 /** array of day labels to optimeize drawing performance. */ 261 /** array of day labels to optimeize drawing performance. */
261 QString *daylbls; 262 QString *daylbls;
262 263
263 /** array of days displayed to reduce memory consumption by 264 /** array of days displayed to reduce memory consumption by
264 subsequently calling QDate::addDays(). */ 265 subsequently calling QDate::addDays(). */
265 QDate *days; 266 QDate *days;
266 267
267 /** array of storing the number of events on a given day. 268 /** array of storing the number of events on a given day.
268 * used for drawing a bold font if there is at least one event on that day. 269 * used for drawing a bold font if there is at least one event on that day.
269 */ 270 */
270 int *events; 271 int *events;
271 272
272 /** stores holiday names of the days shown in the matrix. */ 273 /** stores holiday names of the days shown in the matrix. */
273 QMap<int,QString> mHolidays; 274 QMap<int,QString> mHolidays;
274 275
275 /** indey of today or -1 if today is not visible in the matrix. */ 276 /** indey of today or -1 if today is not visible in the matrix. */
276 int today; 277 int today;
277 278
278 /** index of day where dragged selection was initiated. 279 /** index of day where dragged selection was initiated.
279 used to detect "negative" timely selections */ 280 used to detect "negative" timely selections */
280 int mSelInit; 281 int mSelInit;
281 282
282 /** if mSelStart has this value it indicates that there is no 283 /** if mSelStart has this value it indicates that there is no
283 actual selection in the matrix. */ 284 actual selection in the matrix. */
284 static const int NOSELECTION; 285 static const int NOSELECTION;
285 286
286 /** index of first selected day. */ 287 /** index of first selected day. */
287 int mSelStart; 288 int mSelStart;
288 289
289 /** index of last selected day. */ 290 /** index of last selected day. */
290 int mSelEnd; 291 int mSelEnd;
291 292
292 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ 293 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */
293 DynamicTip* mToolTip; 294 DynamicTip* mToolTip;
294 295
295 296
296 /** default background colour of the matrix. */ 297 /** default background colour of the matrix. */
297 QColor mDefaultBackColor; 298 QColor mDefaultBackColor;
298 299
299 /** default text color of the matrix. */ 300 /** default text color of the matrix. */
300 QColor mDefaultTextColor; 301 QColor mDefaultTextColor;
301 302
302 /** default text color for days not in the actual month. */ 303 /** default text color for days not in the actual month. */
303 QColor mDefaultTextColorShaded; 304 QColor mDefaultTextColorShaded;
304 305
305 /** default text color for holidays not in the actual month. */ 306 /** default text color for holidays not in the actual month. */
306 QColor mHolidayColorShaded; 307 QColor mHolidayColorShaded;
307 308
308 /** text color for selected days. */ 309 /** text color for selected days. */
309 QColor mSelectedDaysColor; 310 QColor mSelectedDaysColor;
310 311
311 /** default width of the frame drawn around today if it is visible in the matrix. */ 312 /** default width of the frame drawn around today if it is visible in the matrix. */
312 int mTodayMarginWidth; 313 int mTodayMarginWidth;
313 314
314 /** stores actual size of each day in the widget so that I dont need to ask this data 315 /** stores actual size of each day in the widget so that I dont need to ask this data
315 * on every repaint. 316 * on every repaint.
316 */ 317 */
317 QRect daysize; 318 QRect daysize;
318 319
319}; 320};
320 321
321#endif 322#endif