summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.h
Unidiff
Diffstat (limited to 'korganizer/kodaymatrix.h') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index b96e08f..6edf7cd 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -1,202 +1,210 @@
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 <q3frame.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//Added by qt3to4:
38#include <QDragMoveEvent>
39#include <QDropEvent>
40#include <QDragLeaveEvent>
41#include <QPaintEvent>
42#include <QResizeEvent>
43#include <QMouseEvent>
44#include <QDragEnterEvent>
37 45
38class QDragEnterEvent; 46class QDragEnterEvent;
39class QDragMoveEvent; 47class QDragMoveEvent;
40class QDragLeaveEvent; 48class QDragLeaveEvent;
41class QDropEvent; 49class QDropEvent;
42 50
43class KODayMatrix; 51class KODayMatrix;
44class KODaymatrixWhatsThis; 52class KODaymatrixWhatsThis;
45 53
46using namespace KCal; 54using namespace KCal;
47 55
48 56
49/** 57/**
50 * small helper class to dynamically show tooltips inside the day matrix. 58 * small helper class to dynamically show tooltips inside the day matrix.
51 * This class asks the day matrix object for a appropriate label which 59 * This class asks the day matrix object for a appropriate label which
52 * is in our special case the name of the holiday or null if this day is no holiday. 60 * is in our special case the name of the holiday or null if this day is no holiday.
53 */ 61 */
54class DynamicTip : public QToolTip 62class DynamicTip /* TODO:hacker: : public QToolTip */
55{ 63{
56public: 64public:
57 65
58 /** 66 /**
59 * Constructor that expects a KODayMatrix object as parent. 67 * Constructor that expects a KODayMatrix object as parent.
60 * 68 *
61 * @param parent the parent KODayMatrix control. 69 * @param parent the parent KODayMatrix control.
62 */ 70 */
63 DynamicTip(QWidget* parent ); 71 DynamicTip(QWidget* parent );
64 72
65protected: 73protected:
66 74
67 /** 75 /**
68 * Qt's callback to ask the object to provide an approrpiate text for the 76 * Qt's callback to ask the object to provide an approrpiate text for the
69 * tooltip to be shown. 77 * tooltip to be shown.
70 * 78 *
71 * @param pos coordinates of the mouse. 79 * @param pos coordinates of the mouse.
72 */ 80 */
73 void maybeTip( const QPoint & pos); 81 void maybeTip( const QPoint & pos);
74 82
75private: 83private:
76 84
77 /** the parent control this tooltip is designed for. */ 85 /** the parent control this tooltip is designed for. */
78 KODayMatrix* matrix; 86 KODayMatrix* matrix;
79}; 87};
80 88
81/** 89/**
82 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. 90 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed.
83 * Cornelius thought this was a waste of memory and a lot of overhead. 91 * Cornelius thought this was a waste of memory and a lot of overhead.
84 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame 92 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame
85 * that draws the labels and allows for dragging selection while maintaining nearly full 93 * that draws the labels and allows for dragging selection while maintaining nearly full
86 * compatibility in behaviour with its predecessor. 94 * compatibility in behaviour with its predecessor.
87 * 95 *
88 * The following functionality has been changed: 96 * The following functionality has been changed:
89 * 97 *
90 * o when shifting events in the agenda view from one day to another the day matrix is updated now 98 * o when shifting events in the agenda view from one day to another the day matrix is updated now
91 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. 99 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date.
92 * o no support for Ctrl+click to create groups of dates 100 * o no support for Ctrl+click to create groups of dates
93 * (This has not really been supported in the predecessor. It was not very intuitive nor was it 101 * (This has not really been supported in the predecessor. It was not very intuitive nor was it
94 * user friendly.) 102 * user friendly.)
95 * This feature has been replaced with dragging a selection on the matrix. The matrix will 103 * This feature has been replaced with dragging a selection on the matrix. The matrix will
96 * automatically choose the appropriate selection (e.g. you are not any longer able to select 104 * automatically choose the appropriate selection (e.g. you are not any longer able to select
97 * two distinct groups of date selections as in the old class) 105 * two distinct groups of date selections as in the old class)
98 * o now that you can select more then a week it can happen that not all selected days are 106 * o now that you can select more then a week it can happen that not all selected days are
99 * displayed in the matrix. However this is preferred to the alternative which would mean to 107 * displayed in the matrix. However this is preferred to the alternative which would mean to
100 * adjust the selection and leave some days undisplayed while scrolling through the months 108 * adjust the selection and leave some days undisplayed while scrolling through the months
101 * 109 *
102 * @short day matrix widget of the KDateNavigator 110 * @short day matrix widget of the KDateNavigator
103 * 111 *
104 * @author Eitzenberger Thomas 112 * @author Eitzenberger Thomas
105 */ 113 */
106class KODayMatrix: public QFrame { 114class KODayMatrix: public Q3Frame {
107 115
108 Q_OBJECT 116 Q_OBJECT
109 117
110public: 118public:
111 119
112 /** constructor to create a day matrix widget. 120 /** constructor to create a day matrix widget.
113 * 121 *
114 * @param parent widget that is the parent of the day matrix. Normally this should 122 * @param parent widget that is the parent of the day matrix. Normally this should
115 * be a KDateNavigator 123 * be a KDateNavigator
116 * @param calendar instance of a calendar on which all calculations are based 124 * @param calendar instance of a calendar on which all calculations are based
117 * @param date start date of the matrix (is expected to be already fixed). It is 125 * @param date start date of the matrix (is expected to be already fixed). It is
118 * assumed that this date is the first week day to be shown in the matrix. 126 * assumed that this date is the first week day to be shown in the matrix.
119 * @param name name of the widget 127 * @param name name of the widget
120 */ 128 */
121 KODayMatrix( QWidget *parent, const char *name ); 129 KODayMatrix( QWidget *parent, const char *name );
122 //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); 130 //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name );
123 131
124 /** destructor that deallocates all dynamically allocated private members. 132 /** destructor that deallocates all dynamically allocated private members.
125 */ 133 */
126 ~KODayMatrix(); 134 ~KODayMatrix();
127 135
128 /** updates the day matrix to start with the given date. Does all the necessary 136 /** updates the day matrix to start with the given date. Does all the necessary
129 * checks for holidays or events on a day and stores them for display later on. 137 * checks for holidays or events on a day and stores them for display later on.
130 * Does NOT update the view visually. Call repaint() for this. 138 * Does NOT update the view visually. Call repaint() for this.
131 * 139 *
132 * @param actdate recalculates the day matrix to show NUMDAYS starting from this 140 * @param actdate recalculates the day matrix to show NUMDAYS starting from this
133 * date. 141 * date.
134 */ 142 */
135 void updateView(QDate actdate); 143 void updateView(QDate actdate);
136 void updateEvents(); 144 void updateEvents();
137 145
138 /** returns the QDate object associated with day indexed by the 146 /** returns the QDate object associated with day indexed by the
139 * supplied offset. 147 * supplied offset.
140 */ 148 */
141 const QDate& getDate(int offset); 149 const QDate& getDate(int offset);
142 void setCalendar( Calendar * ); 150 void setCalendar( Calendar * );
143 /** returns the official name of this holy day or 0 if there is no label 151 /** returns the official name of this holy day or 0 if there is no label
144 * for this day. 152 * for this day.
145 */ 153 */
146 QString getHolidayLabel(int offset); 154 QString getHolidayLabel(int offset);
147 155
148 /** adds all actual selected days from mSelStart to mSelEnd to the supplied 156 /** adds all actual selected days from mSelStart to mSelEnd to the supplied
149 * DateList. 157 * DateList.
150 */ 158 */
151 void addSelectedDaysTo(DateList&); 159 void addSelectedDaysTo(DateList&);
152 160
153 /** sets the actual to be displayed selection in the day matrix starting from 161 /** sets the actual to be displayed selection in the day matrix starting from
154 * start and ending with end. Theview must be manually updated by calling 162 * start and ending with end. Theview must be manually updated by calling
155 * repaint. (?) 163 * repaint. (?)
156 */ 164 */
157 bool setSelectedDaysFrom(const QDate& start, const QDate& end); 165 bool setSelectedDaysFrom(const QDate& start, const QDate& end);
158 void clearSelection(); 166 void clearSelection();
159 167
160 /** Is today visible in the view? Keep this in sync with 168 /** Is today visible in the view? Keep this in sync with
161 * the values today (below) can take. 169 * the values today (below) can take.
162 */ 170 */
163 bool isTodayVisible() const { return today>=0; } ; 171 bool isTodayVisible() const { return today>=0; } ;
164 172
165 /** If today is visible, then we can find out if today is 173 /** If today is visible, then we can find out if today is
166 * near the beginning or the end of the month. 174 * near the beginning or the end of the month.
167 * This is dependent on today remaining the index 175 * This is dependent on today remaining the index
168 * in the array of visible dates and going from 176 * in the array of visible dates and going from
169 * top left (0) to bottom right (41). 177 * top left (0) to bottom right (41).
170 */ 178 */
171 bool isBeginningOfMonth() const { return today<=8; } ; 179 bool isBeginningOfMonth() const { return today<=8; } ;
172 bool isEndOfMonth() const { return today>=27; } ; 180 bool isEndOfMonth() const { return today>=27; } ;
173 QString getWhatsThisText( QPoint ) ; 181 QString getWhatsThisText( QPoint ) ;
174 QSize sizeHint() const; 182 QSize sizeHint() const;
175 QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} 183 QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);}
176public slots: 184public slots:
177 /** Recalculates all the flags of the days in the matrix like holidays or events 185 /** Recalculates all the flags of the days in the matrix like holidays or events
178 * on a day (Actually calls above method with the actual startdate). 186 * on a day (Actually calls above method with the actual startdate).
179 */ 187 */
180 void updateView(); 188 void updateView();
181 void updateViewTimed(); 189 void updateViewTimed();
182 void repaintViewTimed(); 190 void repaintViewTimed();
183 191
184 /** 192 /**
185 * Calculate which square in the matrix should be 193 * Calculate which square in the matrix should be
186 * hilighted to indicate it's today. 194 * hilighted to indicate it's today.
187 */ 195 */
188 void recalculateToday(); 196 void recalculateToday();
189 197
190/* 198/*
191 void setStartDate(QDate); 199 void setStartDate(QDate);
192*/ 200*/
193 201
194signals: 202signals:
195 203
196 /** emitted if the user selects a block of days with the mouse by dragging a rectangle 204 /** emitted if the user selects a block of days with the mouse by dragging a rectangle
197 * inside the matrix 205 * inside the matrix
198 * 206 *
199 * @param daylist list of days that have been selected by the user 207 * @param daylist list of days that have been selected by the user
200 */ 208 */
201 void selected( const KCal::DateList &daylist ); 209 void selected( const KCal::DateList &daylist );
202 210