summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp134
-rw-r--r--korganizer/koagendaview.h2
-rw-r--r--korganizer/kodaymatrix.cpp493
-rw-r--r--korganizer/kodaymatrix.h1
4 files changed, 326 insertions, 304 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 2996acb..218396d 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,294 +1,304 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
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 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 );
84 mRows = rows; 85 mRows = rows;
85 86
87 mRedrawNeeded = true;
86 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
87 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
88 90
89 enableClipper(true); 91 enableClipper(true);
90 92
91 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
93 95
94 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
95 97
96 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
97} 99}
98 100
99void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
100{ 102{
101 mCellHeight = height; 103 mCellHeight = height;
102} 104}
103 105
104/* 106/*
105 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 109*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 111{
110 112
111 // if ( globalFlagBlockAgenda ) 113 // if ( globalFlagBlockAgenda )
112 // return; 114 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 115 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 116 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 117 // code assumes the latter...
116 118
117 // now, for a workaround... 119 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 120 // these two assignments fix the weird redraw bug
119 cx = contentsX() + 2; 121 if ( mRedrawNeeded ) {
120 cw = contentsWidth() - 2; 122 cx = contentsX() + 2;
121 // end of workaround 123 cw = contentsWidth() - 2;
122 124 // end of workaround
123 int cell = ((int)(cy/mCellHeight)); 125
124 int y = cell * mCellHeight; 126 int cell = ((int)(cy/mCellHeight));
125 QFontMetrics fm = fontMetrics(); 127 int y = cell * mCellHeight;
126 QString hour; 128 QFontMetrics fm = fontMetrics();
127 QString suffix; 129 QString hour;
128 int tW = fm.width("24:00i"); 130 QString suffix;
129 int timeHeight = fm.height(); 131 int tW = fm.width("24:00i");
130 //timeHeight -= (timeHeight/4-2); 132 int timeHeight = fm.height();
131 int borderWidth = 0; 133 //timeHeight -= (timeHeight/4-2);
132 QFont nFont = p->font(); 134 int borderWidth = 0;
135 QFont nFont = p->font();
133 136
134 if (!KGlobal::locale()->use12Clock()) 137 if (!KGlobal::locale()->use12Clock())
135 suffix = "00"; 138 suffix = "00";
136 else 139 else
137 borderWidth = 0; 140 borderWidth = 0;
138 if ( timeHeight > mCellHeight ) { 141 if ( timeHeight > mCellHeight ) {
139 timeHeight = mCellHeight-1; 142 timeHeight = mCellHeight-1;
140 int pointS = nFont.pointSize(); 143 int pointS = nFont.pointSize();
141 while ( pointS > 4 ) { 144 while ( pointS > 4 ) {
142 nFont.setPointSize( pointS ); 145 nFont.setPointSize( pointS );
146 fm = QFontMetrics( nFont );
147 if ( fm.height() < mCellHeight )
148 break;
149 -- pointS;
150 }
143 fm = QFontMetrics( nFont ); 151 fm = QFontMetrics( nFont );
144 if ( fm.height() < mCellHeight ) 152 borderWidth = 4;
145 break; 153 timeHeight = fm.height();
146 -- pointS;
147 }
148 fm = QFontMetrics( nFont );
149 borderWidth = 4;
150 timeHeight = fm.height();
151 }
152 timeHeight -= (timeHeight/4-2);
153 QFont sFont = nFont;
154 sFont.setPointSize( sFont.pointSize()/2+2 );
155 QFontMetrics fmS( sFont );
156 int sHei = fmS.height();
157 sHei -= (sHei/4-2);
158 int startW = this->width() - frameWidth();
159 while (y < cy + ch) {
160 p->drawLine(cx,y,cx+tW,y);
161 hour.setNum(cell);
162
163 // handle 24h and am/pm time formats
164 if (KGlobal::locale()->use12Clock()) {
165 if (cell > 11) suffix = "pm";
166 else
167 suffix = "am";
168 if (cell == 0) hour.setNum(12);
169 if (cell > 12) hour.setNum(cell - 12);
170 } 154 }
155 timeHeight -= (timeHeight/4-2);
156 QFont sFont = nFont;
157 sFont.setPointSize( sFont.pointSize()/2+2 );
158 QFontMetrics fmS( sFont );
159 int sHei = fmS.height();
160 sHei -= (sHei/4-2);
161 int startW = this->width() - frameWidth();
162 while (y < cy + ch) {
163 p->drawLine(cx,y,cx+tW,y);
164 hour.setNum(cell);
165
166 // handle 24h and am/pm time formats
167 if (KGlobal::locale()->use12Clock()) {
168 if (cell > 11) suffix = "pm";
169 else
170 suffix = "am";
171 if (cell == 0) hour.setNum(12);
172 if (cell > 12) hour.setNum(cell - 12);
173 }
171 174
172 // center and draw the time label 175 // center and draw the time label
173 int timeWidth = fm.width(hour+"i"); 176 int timeWidth = fm.width(hour+"i");
174 int tw2 = fm.width(suffix); 177 int tw2 = fm.width(suffix);
175 int offset = startW - timeWidth - tw2 ; 178 int offset = startW - timeWidth - tw2 ;
176 p->setFont( nFont ); 179 p->setFont( nFont );
177 p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); 180 p->drawText(cx - borderWidth + offset, y+ timeHeight, hour);
178 p->setFont( sFont ); 181 p->setFont( sFont );
179 offset = startW - tw2-1; 182 offset = startW - tw2-1;
180 p->drawText(cx - borderWidth + offset, y+ sHei, suffix); 183 p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
181 184
182 // increment indices 185 // increment indices
183 y += mCellHeight; 186 y += mCellHeight;
184 cell++; 187 cell++;
188 }
189 } else {
190 //qDebug("NO redraw ");
185 } 191 }
192 // double buffer not yet implemented
193 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
194 //mRedrawNeeded = false;
186} 195}
187 196
188/** 197/**
189 Calculates the minimum width. 198 Calculates the minimum width.
190*/ 199*/
191int TimeLabels::minimumWidth() const 200int TimeLabels::minimumWidth() const
192{ 201{
193 return mMiniWidth; 202 return mMiniWidth;
194} 203}
195 204
196/** updates widget's internal state */ 205/** updates widget's internal state */
197void TimeLabels::updateConfig() 206void TimeLabels::updateConfig()
198{ 207{
208 mRedrawNeeded = true;
199 // set the font 209 // set the font
200 // config->setGroup("Fonts"); 210 // config->setGroup("Fonts");
201 // QFont font = config->readFontEntry("TimeBar Font"); 211 // QFont font = config->readFontEntry("TimeBar Font");
202 setFont(KOPrefs::instance()->mTimeBarFont); 212 setFont(KOPrefs::instance()->mTimeBarFont);
203 QString test = "88:88"; 213 QString test = "88:88";
204 if (KGlobal::locale()->use12Clock()) 214 if (KGlobal::locale()->use12Clock())
205 test += "i"; 215 test += "i";
206 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; 216 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ;
207 // update geometry restrictions based on new settings 217 // update geometry restrictions based on new settings
208 setFixedWidth(minimumWidth()); 218 setFixedWidth(minimumWidth());
209 219
210 // update HourSize 220 // update HourSize
211 mCellHeight = KOPrefs::instance()->mHourSize*4; 221 mCellHeight = KOPrefs::instance()->mHourSize*4;
212 resizeContents(50,mRows * mCellHeight); 222 resizeContents(50,mRows * mCellHeight);
213} 223}
214 224
215/** update time label positions */ 225/** update time label positions */
216void TimeLabels::positionChanged() 226void TimeLabels::positionChanged()
217{ 227{
218 int adjustment = mAgenda->contentsY(); 228 int adjustment = mAgenda->contentsY();
219 setContentsPos(0, adjustment); 229 setContentsPos(0, adjustment);
220} 230}
221 231
222/** */ 232/** */
223void TimeLabels::setAgenda(KOAgenda* agenda) 233void TimeLabels::setAgenda(KOAgenda* agenda)
224{ 234{
225 mAgenda = agenda; 235 mAgenda = agenda;
226} 236}
227 237
228void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 238void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
229{ 239{
230 mMouseDownY = e->pos().y(); 240 mMouseDownY = e->pos().y();
231 mOrgCap = topLevelWidget()->caption(); 241 mOrgCap = topLevelWidget()->caption();
232} 242}
233 243
234void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 244void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
235{ 245{
236 int diff = mMouseDownY - e->pos().y(); 246 int diff = mMouseDownY - e->pos().y();
237 if ( diff < 10 && diff > -10 ) 247 if ( diff < 10 && diff > -10 )
238 return; 248 return;
239 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 249 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
240 if ( tSize < 4 ) 250 if ( tSize < 4 )
241 tSize = 4; 251 tSize = 4;
242 if ( tSize > 22 ) 252 if ( tSize > 22 )
243 tSize = 22; 253 tSize = 22;
244 tSize = (tSize-2)/2; 254 tSize = (tSize-2)/2;
245 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 255 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
246 256
247} 257}
248void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 258void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
249{ 259{
250 topLevelWidget()->setCaption( mOrgCap ); 260 topLevelWidget()->setCaption( mOrgCap );
251 int diff = mMouseDownY - e->pos().y(); 261 int diff = mMouseDownY - e->pos().y();
252 if ( diff < 10 && diff > -10 ) 262 if ( diff < 10 && diff > -10 )
253 return; 263 return;
254 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 264 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
255 if ( tSize < 4 ) 265 if ( tSize < 4 )
256 tSize = 4; 266 tSize = 4;
257 if ( tSize > 22 ) 267 if ( tSize > 22 )
258 tSize = 22; 268 tSize = 22;
259 tSize = (tSize/2)*2; 269 tSize = (tSize/2)*2;
260 if ( tSize == KOPrefs::instance()->mHourSize ) 270 if ( tSize == KOPrefs::instance()->mHourSize )
261 return; 271 return;
262 KOPrefs::instance()->mHourSize = tSize; 272 KOPrefs::instance()->mHourSize = tSize;
263 emit scaleChanged(); 273 emit scaleChanged();
264} 274}
265 275
266/** This is called in response to repaint() */ 276/** This is called in response to repaint() */
267void TimeLabels::paintEvent(QPaintEvent*) 277void TimeLabels::paintEvent(QPaintEvent*)
268{ 278{
269 279
270 // kdDebug() << "paintevent..." << endl; 280 // kdDebug() << "paintevent..." << endl;
271 // this is another hack! 281 // this is another hack!
272 // QPainter painter(this); 282 // QPainter painter(this);
273 //QString c 283 //QString c
274 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 284 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
275} 285}
276 286
277//////////////////////////////////////////////////////////////////////////// 287////////////////////////////////////////////////////////////////////////////
278 288
279EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 289EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
280 : QFrame(parent,name) 290 : QFrame(parent,name)
281{ 291{
282 mColumns = 1; 292 mColumns = 1;
283 mTopBox = 0; 293 mTopBox = 0;
284 mLocation = loc; 294 mLocation = loc;
285 mTopLayout = 0; 295 mTopLayout = 0;
286 mPaintWidget = 0; 296 mPaintWidget = 0;
287 mXOffset = 0; 297 mXOffset = 0;
288 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 298 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
289 else mPixmap = SmallIcon("1downarrow"); 299 else mPixmap = SmallIcon("1downarrow");
290 mEnabled.resize(mColumns); 300 mEnabled.resize(mColumns);
291 mEnabled.fill( false ); 301 mEnabled.fill( false );
292 setMinimumHeight(mPixmap.height()); 302 setMinimumHeight(mPixmap.height());
293} 303}
294 304
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 6dc81c6..30c9b05 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -8,192 +8,194 @@
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 KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qksplitter.h> 31#include <qksplitter.h>
32#else 32#else
33#include <qsplitter.h> 33#include <qsplitter.h>
34#endif 34#endif
35#include <qmemarray.h> 35#include <qmemarray.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix;
105 bool mRedrawNeeded;
104 int mMiniWidth; 106 int mMiniWidth;
105 int mMouseDownY; 107 int mMouseDownY;
106 QString mOrgCap; 108 QString mOrgCap;
107 int mRows; 109 int mRows;
108 int mCellHeight; 110 int mCellHeight;
109 111
110 /** */ 112 /** */
111 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
112}; 114};
113 115
114class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
115 Q_OBJECT 117 Q_OBJECT
116 public: 118 public:
117 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
118 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
119 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
120 122
121 void changeColumns(int columns); 123 void changeColumns(int columns);
122 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
123 void setXOffset( int ); 125 void setXOffset( int );
124 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
125 127
126 protected: 128 protected:
127 void drawContents(QPainter *); 129 void drawContents(QPainter *);
128 130
129 private: 131 private:
130 int mXOffset; 132 int mXOffset;
131 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
132 int mColumns; 134 int mColumns;
133 QHBox *mTopBox; 135 QHBox *mTopBox;
134 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
135 Location mLocation; 137 Location mLocation;
136 QPixmap mPixmap; 138 QPixmap mPixmap;
137 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
138}; 140};
139 141
140/** 142/**
141 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
142 multi-day view. 144 multi-day view.
143*/ 145*/
144class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
145 Q_OBJECT 147 Q_OBJECT
146 public: 148 public:
147 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
148 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
149 void setStartHour( int ); 151 void setStartHour( int );
150 void toggleAllDay(); 152 void toggleAllDay();
151 153
152 154
153 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
154 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
155 157
156 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
157 virtual int currentDateCount(); 159 virtual int currentDateCount();
158 160
159 /** returns the currently selected events */ 161 /** returns the currently selected events */
160 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
161 163
162 /** returns the currently selected events */ 164 /** returns the currently selected events */
163 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
164 166
165 /** Remove all events from view */ 167 /** Remove all events from view */
166 void clearView(); 168 void clearView();
167 KOAgenda *agenda() { return mAgenda;} 169 KOAgenda *agenda() { return mAgenda;}
168 virtual void printPreview(CalPrinter *calPrinter, 170 virtual void printPreview(CalPrinter *calPrinter,
169 const QDate &, const QDate &); 171 const QDate &, const QDate &);
170 172
171 /** start-datetime of selection */ 173 /** start-datetime of selection */
172 QDateTime selectionStart() {return mTimeSpanBegin;} 174 QDateTime selectionStart() {return mTimeSpanBegin;}
173 /** end-datetime of selection */ 175 /** end-datetime of selection */
174 QDateTime selectionEnd() {return mTimeSpanEnd;} 176 QDateTime selectionEnd() {return mTimeSpanEnd;}
175 /** returns true if selection is for whole day */ 177 /** returns true if selection is for whole day */
176 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 178 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
177 /** make selected start/end invalid */ 179 /** make selected start/end invalid */
178 void deleteSelectedDateTime(); 180 void deleteSelectedDateTime();
179 void repaintAgenda(); 181 void repaintAgenda();
180 public slots: 182 public slots:
181 void setInitStartHour(); 183 void setInitStartHour();
182 virtual void updateView(); 184 virtual void updateView();
183 virtual void updateConfig(); 185 virtual void updateConfig();
184 virtual void showDates(const QDate &start, const QDate &end); 186 virtual void showDates(const QDate &start, const QDate &end);
185 virtual void showEvents(QPtrList<Event> eventList); 187 virtual void showEvents(QPtrList<Event> eventList);
186 188
187 void updateTodo( Todo *, int ); 189 void updateTodo( Todo *, int );
188 void changeEventDisplay(Event *, int); 190 void changeEventDisplay(Event *, int);
189 191
190 void clearSelection(); 192 void clearSelection();
191 193
192 void newTodo(int gx,int gy); 194 void newTodo(int gx,int gy);
193 void newEvent(int gx,int gy); 195 void newEvent(int gx,int gy);
194 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 196 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
195 void newEventAllDay(int gx, int gy); 197 void newEventAllDay(int gx, int gy);
196 void newTodoAllDay(int gx, int gy); 198 void newTodoAllDay(int gx, int gy);
197 199
198 void startDrag(Event *); 200 void startDrag(Event *);
199 201
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index d543aaf..dfc6af7 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -17,192 +17,193 @@
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source ode for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <libkcal/vcaldrag.h> 35#include <libkcal/vcaldrag.h>
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/dndfactory.h> 37#include <libkcal/dndfactory.h>
38#include <libkcal/calendarresources.h> 38#include <libkcal/calendarresources.h>
39#include <libkcal/resourcecalendar.h> 39#include <libkcal/resourcecalendar.h>
40#include <kresources/resourceselectdialog.h> 40#include <kresources/resourceselectdialog.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
45#include "kocore.h" 45#include "kocore.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#include "koglobals.h" 48#include "koglobals.h"
49 49
50#include "kodaymatrix.h" 50#include "kodaymatrix.h"
51 51
52// ============================================================================ 52// ============================================================================
53// D Y N A M I C T I P 53// D Y N A M I C T I P
54// ============================================================================ 54// ============================================================================
55 55
56DynamicTip::DynamicTip( QWidget * parent ) 56DynamicTip::DynamicTip( QWidget * parent )
57 : QToolTip( parent ) 57 : QToolTip( parent )
58{ 58{
59 matrix = (KODayMatrix*)parent; 59 matrix = (KODayMatrix*)parent;
60} 60}
61 61
62class KODaymatrixWhatsThis :public QWhatsThis 62class KODaymatrixWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; 65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;};
66 ~KODaymatrixWhatsThis() { ; }; 66 ~KODaymatrixWhatsThis() { ; };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p ) 69 virtual QString text( const QPoint& p )
70 { 70 {
71 return _view->getWhatsThisText( p ) ; 71 return _view->getWhatsThisText( p ) ;
72 } 72 }
73private: 73private:
74 KODayMatrix * _view; 74 KODayMatrix * _view;
75}; 75};
76 76
77void DynamicTip::maybeTip( const QPoint &pos ) 77void DynamicTip::maybeTip( const QPoint &pos )
78{ 78{
79 //calculate which cell of the matrix the mouse is in 79 //calculate which cell of the matrix the mouse is in
80 QRect sz = matrix->frameRect(); 80 QRect sz = matrix->frameRect();
81 int dheight = sz.height()*7 / 42; 81 int dheight = sz.height()*7 / 42;
82 int dwidth = sz.width() / 7; 82 int dwidth = sz.width() / 7;
83 int row = pos.y()/dheight; 83 int row = pos.y()/dheight;
84 int col = pos.x()/dwidth; 84 int col = pos.x()/dwidth;
85 85
86 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 86 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
87 87
88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
89// col << "][" << row << "] => " <<(col+row*7) << endl; 89// col << "][" << row << "] => " <<(col+row*7) << endl;
90 90
91 //show holiday names only 91 //show holiday names only
92 QString str = matrix->getHolidayLabel(col+row*7); 92 QString str = matrix->getHolidayLabel(col+row*7);
93 if (str.isEmpty()) return; 93 if (str.isEmpty()) return;
94 tip(rct, str); 94 tip(rct, str);
95} 95}
96 96
97 97
98// ============================================================================ 98// ============================================================================
99// K O D A Y M A T R I X 99// K O D A Y M A T R I X
100// ============================================================================ 100// ============================================================================
101 101
102const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
103const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
104 104
105KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) 106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 )
107 107
108#if 0 108#if 0
109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
110 QFrame(parent, name) 110 QFrame(parent, name)
111#endif 111#endif
112{ 112{
113 mRedrawNeeded = true;
113 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 114 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
114 mPendingUpdateBeforeRepaint = false; 115 mPendingUpdateBeforeRepaint = false;
115 mouseDown = false; 116 mouseDown = false;
116 // initialize dynamic arrays 117 // initialize dynamic arrays
117 bDays.resize ( NUMDAYS ); 118 bDays.resize ( NUMDAYS );
118 hDays.resize ( NUMDAYS );; 119 hDays.resize ( NUMDAYS );;
119 eDays.resize ( NUMDAYS );; 120 eDays.resize ( NUMDAYS );;
120 days = new QDate[NUMDAYS]; 121 days = new QDate[NUMDAYS];
121 daylbls = new QString[NUMDAYS]; 122 daylbls = new QString[NUMDAYS];
122 //events = new int[NUMDAYS]; 123 //events = new int[NUMDAYS];
123 mToolTip = new DynamicTip(this); 124 mToolTip = new DynamicTip(this);
124 125
125 // set default values used for drawing the matrix 126 // set default values used for drawing the matrix
126 mDefaultBackColor = palette().active().base(); 127 mDefaultBackColor = palette().active().base();
127 mDefaultTextColor = palette().active().foreground(); 128 mDefaultTextColor = palette().active().foreground();
128 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 129 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
129 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 130 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
130 mSelectedDaysColor = QColor("white"); 131 mSelectedDaysColor = QColor("white");
131 mTodayMarginWidth = 2; 132 mTodayMarginWidth = 2;
132 mSelEnd = mSelStart = NOSELECTION; 133 mSelEnd = mSelStart = NOSELECTION;
133 134
134 setAcceptDrops(true); 135 setAcceptDrops(true);
135 //setFont( QFont("Arial", 10) ); 136 //setFont( QFont("Arial", 10) );
136 137
137 mUpdateTimer = new QTimer( this ); 138 mUpdateTimer = new QTimer( this );
138 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 139 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
139 mRepaintTimer = new QTimer( this ); 140 mRepaintTimer = new QTimer( this );
140 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 141 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
141 mDayChanged = false; 142 mDayChanged = false;
142 updateView(); 143 updateView();
143} 144}
144QString KODayMatrix::getWhatsThisText( QPoint p ) 145QString KODayMatrix::getWhatsThisText( QPoint p )
145{ 146{
146 147
147 int tmp = getDayIndexFrom(p.x(), p.y()); 148 int tmp = getDayIndexFrom(p.x(), p.y());
148 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) 149 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar )
149 return QString(); 150 return QString();
150 QDate mDate = days[tmp]; 151 QDate mDate = days[tmp];
151 QPtrList<Event> eventlist = mCalendar->events(mDate); 152 QPtrList<Event> eventlist = mCalendar->events(mDate);
152 Event *event; 153 Event *event;
153 QStringList mToolTip; 154 QStringList mToolTip;
154 for(event=eventlist.first();event != 0;event=eventlist.next()) { 155 for(event=eventlist.first();event != 0;event=eventlist.next()) {
155 QString mToolTipText; 156 QString mToolTipText;
156 QString text; 157 QString text;
157 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 158 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
158 if (event->isMultiDay()) { 159 if (event->isMultiDay()) {
159 QString prefix = "<->";multiday = 2; 160 QString prefix = "<->";multiday = 2;
160 QString time; 161 QString time;
161 if ( event->doesRecur() ) { 162 if ( event->doesRecur() ) {
162 if ( event->recursOn( mDate) ) { 163 if ( event->recursOn( mDate) ) {
163 prefix ="->" ;multiday = 1; 164 prefix ="->" ;multiday = 1;
164 } 165 }
165 else { 166 else {
166 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 167 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
167 if ( event->recursOn( mDate.addDays( -days)) ) { 168 if ( event->recursOn( mDate.addDays( -days)) ) {
168 prefix ="<-" ;multiday = 3; 169 prefix ="<-" ;multiday = 3;
169 } 170 }
170 } 171 }
171 } else { 172 } else {
172 if (mDate == event->dtStart().date()) { 173 if (mDate == event->dtStart().date()) {
173 prefix ="->" ;multiday = 1; 174 prefix ="->" ;multiday = 1;
174 } else if (mDate == event->dtEnd().date()) { 175 } else if (mDate == event->dtEnd().date()) {
175 prefix ="<-" ;multiday = 3; 176 prefix ="<-" ;multiday = 3;
176 } 177 }
177 } 178 }
178 if ( !event->doesFloat() ) { 179 if ( !event->doesFloat() ) {
179 if ( mDate == event->dtStart().date () ) 180 if ( mDate == event->dtStart().date () )
180 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 181 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
181 else if ( mDate == event->dtEnd().date () ) 182 else if ( mDate == event->dtEnd().date () )
182 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 183 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
183 184
184 } 185 }
185 text = time + event->summary(); 186 text = time + event->summary();
186 mToolTipText += prefix + text; 187 mToolTipText += prefix + text;
187 } else { 188 } else {
188 if (event->doesFloat()) { 189 if (event->doesFloat()) {
189 text = event->summary(); 190 text = event->summary();
190 mToolTipText += text; 191 mToolTipText += text;
191 } 192 }
192 else { 193 else {
193 text = KGlobal::locale()->formatTime(event->dtStart().time()); 194 text = KGlobal::locale()->formatTime(event->dtStart().time());
194 text += " " + event->summary(); 195 text += " " + event->summary();
195 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 196 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
196 } 197 }
197 } 198 }
198 if ( !event->location().isEmpty() ) 199 if ( !event->location().isEmpty() )
199 mToolTipText += " (" + event->location() + ")"; 200 mToolTipText += " (" + event->location() + ")";
200#if QT_VERSION >= 0x030000 201#if QT_VERSION >= 0x030000
201 mToolTipText.replace( '<' , "&lt;" ); 202 mToolTipText.replace( '<' , "&lt;" );
202 mToolTipText.replace( '>' , "&gt;" ); 203 mToolTipText.replace( '>' , "&gt;" );
203#else 204#else
204 if ( mToolTipText.find ('<') >= 0 ) { 205 if ( mToolTipText.find ('<') >= 0 ) {
205 mToolTipText.replace( QRegExp("<") , "&lt;" ); 206 mToolTipText.replace( QRegExp("<") , "&lt;" );
206 } 207 }
207 if ( mToolTipText.find ('>') >= 0 ) { 208 if ( mToolTipText.find ('>') >= 0 ) {
208 mToolTipText.replace( QRegExp(">") , "&gt;" ); 209 mToolTipText.replace( QRegExp(">") , "&gt;" );
@@ -293,235 +294,237 @@ bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
293 if ( mSelStart < 0 ) 294 if ( mSelStart < 0 )
294 mSelStart = 0; 295 mSelStart = 0;
295 mSelEnd = startdate.daysTo(end); 296 mSelEnd = startdate.daysTo(end);
296 if ( mSelEnd > NUMDAYS-1 ) 297 if ( mSelEnd > NUMDAYS-1 )
297 mSelEnd = NUMDAYS-1; 298 mSelEnd = NUMDAYS-1;
298 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { 299 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
299 clearSelection(); 300 clearSelection();
300 if ( noSel ) 301 if ( noSel )
301 return false; 302 return false;
302 } 303 }
303 304
304 return true; 305 return true;
305} 306}
306void KODayMatrix::clearSelection() 307void KODayMatrix::clearSelection()
307{ 308{
308 mSelEnd = mSelStart = NOSELECTION; 309 mSelEnd = mSelStart = NOSELECTION;
309} 310}
310 311
311 312
312void KODayMatrix::recalculateToday() 313void KODayMatrix::recalculateToday()
313{ 314{
314 today = -1; 315 today = -1;
315 for (int i=0; i<NUMDAYS; i++) { 316 for (int i=0; i<NUMDAYS; i++) {
316 //events[i] = 0; 317 //events[i] = 0;
317 days[i] = startdate.addDays(i); 318 days[i] = startdate.addDays(i);
318 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 319 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
319 320
320 // if today is in the currently displayed month, hilight today 321 // if today is in the currently displayed month, hilight today
321 if (days[i].year() == QDate::currentDate().year() && 322 if (days[i].year() == QDate::currentDate().year() &&
322 days[i].month() == QDate::currentDate().month() && 323 days[i].month() == QDate::currentDate().month() &&
323 days[i].day() == QDate::currentDate().day()) { 324 days[i].day() == QDate::currentDate().day()) {
324 today = i; 325 today = i;
325 } 326 }
326 } 327 }
327 // qDebug(QString("Today is visible at %1.").arg(today)); 328 // qDebug(QString("Today is visible at %1.").arg(today));
328} 329}
329 330
330void KODayMatrix::updateView() 331void KODayMatrix::updateView()
331{ 332{
332 updateView(startdate); 333 updateView(startdate);
333} 334}
334void KODayMatrix::repaintViewTimed() 335void KODayMatrix::repaintViewTimed()
335{ 336{
336 mRepaintTimer->stop(); 337 mRepaintTimer->stop();
337 repaint(false); 338 repaint(false);
338} 339}
339void KODayMatrix::updateViewTimed() 340void KODayMatrix::updateViewTimed()
340{ 341{
341 mUpdateTimer->stop(); 342 mUpdateTimer->stop();
342 if ( !mCalendar ) { 343 if ( !mCalendar ) {
343 qDebug("NOT CAL "); 344 qDebug("NOT CAL ");
344 return; 345 return;
345 } 346 }
346 //qDebug("KODayMatrix::updateViewTimed "); 347 //qDebug("KODayMatrix::updateViewTimed ");
347 for(int i = 0; i < NUMDAYS; i++) { 348 for(int i = 0; i < NUMDAYS; i++) {
348 // if events are set for the day then remember to draw it bold 349 // if events are set for the day then remember to draw it bold
349 QPtrList<Event> eventlist = mCalendar->events(days[i]); 350 QPtrList<Event> eventlist = mCalendar->events(days[i]);
350 Event *event; 351 Event *event;
351 int numEvents = eventlist.count(); 352 int numEvents = eventlist.count();
352 QString holiStr = ""; 353 QString holiStr = "";
353 bDays.clearBit(i); 354 bDays.clearBit(i);
354 hDays.clearBit(i); 355 hDays.clearBit(i);
355 eDays.clearBit(i); 356 eDays.clearBit(i);
356 for(event=eventlist.first();event != 0;event=eventlist.next()) { 357 for(event=eventlist.first();event != 0;event=eventlist.next()) {
357 ushort recurType = event->recurrence()->doesRecur(); 358 ushort recurType = event->recurrence()->doesRecur();
358 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 359 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
359 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 360 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
360 numEvents--; 361 numEvents--;
361 } 362 }
362 if ( event->isHoliday()) { 363 if ( event->isHoliday()) {
363 hDays.setBit(i); 364 hDays.setBit(i);
364 if ( !holiStr.isEmpty() ) 365 if ( !holiStr.isEmpty() )
365 holiStr += "\n"; 366 holiStr += "\n";
366 holiStr += event->summary(); 367 holiStr += event->summary();
367 if ( !event->location().isEmpty() ) 368 if ( !event->location().isEmpty() )
368 holiStr += " (" + event->location() + ")"; 369 holiStr += " (" + event->location() + ")";
369 } 370 }
370 if ( event->isBirthday()) { 371 if ( event->isBirthday()) {
371 if ( !holiStr.isEmpty() ) 372 if ( !holiStr.isEmpty() )
372 holiStr += "\n"; 373 holiStr += "\n";
373 holiStr += i18n("Birthday") + ": "+event->summary(); 374 holiStr += i18n("Birthday") + ": "+event->summary();
374 if ( !event->location().isEmpty() ) 375 if ( !event->location().isEmpty() )
375 holiStr += " (" + event->location() + ")"; 376 holiStr += " (" + event->location() + ")";
376 bDays.setBit(i); 377 bDays.setBit(i);
377 } 378 }
378 } 379 }
379 if ( numEvents ) 380 if ( numEvents )
380 eDays.setBit(i); 381 eDays.setBit(i);
381 //if it is a holy day then draw it red. Sundays are consider holidays, too 382 //if it is a holy day then draw it red. Sundays are consider holidays, too
382 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 383 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
383 !holiStr.isEmpty()) { 384 !holiStr.isEmpty()) {
384 mHolidays[i] = holiStr; 385 mHolidays[i] = holiStr;
385 } else { 386 } else {
386 mHolidays[i] = QString::null; 387 mHolidays[i] = QString::null;
387 } 388 }
388 } 389 }
390 mRedrawNeeded = true;
389 if ( ! mPendingUpdateBeforeRepaint ) 391 if ( ! mPendingUpdateBeforeRepaint )
390 repaint(false); 392 repaint(false);
391} 393}
392void KODayMatrix::updateView(QDate actdate) 394void KODayMatrix::updateView(QDate actdate)
393{ 395{
394 396
395 if ( ! actdate.isValid() ) { 397 if ( ! actdate.isValid() ) {
396 //qDebug("date not valid "); 398 //qDebug("date not valid ");
397 return; 399 return;
398 } 400 }
399 mDayChanged = false; 401 mDayChanged = false;
400 //flag to indicate if the starting day of the matrix has changed by this call 402 //flag to indicate if the starting day of the matrix has changed by this call
401 //mDayChanged = false; 403 //mDayChanged = false;
402 // if a new startdate is to be set then apply Cornelius's calculation 404 // if a new startdate is to be set then apply Cornelius's calculation
403 // of the first day to be shown 405 // of the first day to be shown
404 if (actdate != startdate) { 406 if (actdate != startdate) {
405 // reset index of selection according to shift of starting date from startdate to actdate 407 // reset index of selection according to shift of starting date from startdate to actdate
406 if (mSelStart != NOSELECTION) { 408 if (mSelStart != NOSELECTION) {
407 int tmp = actdate.daysTo(startdate); 409 int tmp = actdate.daysTo(startdate);
408 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 410 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
409 // shift selection if new one would be visible at least partly ! 411 // shift selection if new one would be visible at least partly !
410 412
411 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 413 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
412 // nested if is required for next X display pushed from a different month - correction required 414 // nested if is required for next X display pushed from a different month - correction required
413 // otherwise, for month forward and backward, it must be avoided 415 // otherwise, for month forward and backward, it must be avoided
414 if( mSelStart > NUMDAYS || mSelStart < 0 ) 416 if( mSelStart > NUMDAYS || mSelStart < 0 )
415 mSelStart = mSelStart + tmp; 417 mSelStart = mSelStart + tmp;
416 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 418 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
417 mSelEnd = mSelEnd + tmp; 419 mSelEnd = mSelEnd + tmp;
418 } 420 }
419 } 421 }
420 startdate = actdate; 422 startdate = actdate;
421 mDayChanged = true; 423 mDayChanged = true;
422 recalculateToday(); 424 recalculateToday();
425 mRedrawNeeded = true;
423 } 426 }
424 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 427 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
425 if ( !isVisible() ) { 428 if ( !isVisible() ) {
426 mPendingUpdateBeforeRepaint = true; 429 mPendingUpdateBeforeRepaint = true;
427 } else { 430 } else {
428#ifdef DESKTOP_VERSION 431#ifdef DESKTOP_VERSION
429 //mRepaintTimer->start( 100 ); 432 //mRepaintTimer->start( 100 );
430 //updateViewTimed(); 433 //updateViewTimed();
431 mUpdateTimer->start( 20 ); 434 mUpdateTimer->start( 50 );
432#else 435#else
433 mRepaintTimer->start( 350 ); 436 mRepaintTimer->start( 350 );
434 mUpdateTimer->start( 1200 ); 437 mUpdateTimer->start( 1200 );
435#endif 438#endif
436 } 439 }
437} 440}
438void KODayMatrix::updateEvents() 441void KODayMatrix::updateEvents()
439{ 442{
440 if ( !mCalendar ) return; 443 if ( !mCalendar ) return;
441 444
442 for( int i = 0; i < NUMDAYS; i++ ) { 445 for( int i = 0; i < NUMDAYS; i++ ) {
443 // if events are set for the day then remember to draw it bold 446 // if events are set for the day then remember to draw it bold
444 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 447 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
445 int numEvents = eventlist.count(); 448 int numEvents = eventlist.count();
446 Event *event; 449 Event *event;
447 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 450 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
448 ushort recurType = event->doesRecur(); 451 ushort recurType = event->doesRecur();
449 452
450 if ( ( recurType == Recurrence::rDaily && 453 if ( ( recurType == Recurrence::rDaily &&
451 !KOPrefs::instance()->mDailyRecur ) || 454 !KOPrefs::instance()->mDailyRecur ) ||
452 ( recurType == Recurrence::rWeekly && 455 ( recurType == Recurrence::rWeekly &&
453 !KOPrefs::instance()->mWeeklyRecur ) ) { 456 !KOPrefs::instance()->mWeeklyRecur ) ) {
454 numEvents--; 457 numEvents--;
455 } 458 }
456 } 459 }
457 if ( numEvents ) 460 if ( numEvents )
458 eDays.setBit(i); 461 eDays.setBit(i);
459 else 462 else
460 eDays.clearBit(i); 463 eDays.clearBit(i);
461 } 464 }
462} 465}
463 466
464const QDate& KODayMatrix::getDate(int offset) 467const QDate& KODayMatrix::getDate(int offset)
465{ 468{
466 if (offset < 0 || offset > NUMDAYS-1) { 469 if (offset < 0 || offset > NUMDAYS-1) {
467 qDebug("Wrong offset2 %d", offset); 470 qDebug("Wrong offset2 %d", offset);
468 return days[0]; 471 return days[0];
469 } 472 }
470 return days[offset]; 473 return days[offset];
471} 474}
472 475
473QString KODayMatrix::getHolidayLabel(int offset) 476QString KODayMatrix::getHolidayLabel(int offset)
474{ 477{
475 if (offset < 0 || offset > NUMDAYS-1) { 478 if (offset < 0 || offset > NUMDAYS-1) {
476 qDebug("Wrong offset1 %d", offset); 479 qDebug("Wrong offset1 %d", offset);
477 return QString(); 480 return QString();
478 } 481 }
479 return mHolidays[offset]; 482 return mHolidays[offset];
480} 483}
481 484
482int KODayMatrix::getDayIndexFrom(int x, int y) 485int KODayMatrix::getDayIndexFrom(int x, int y)
483{ 486{
484 int colModulo = (width()-2) % 7; 487 int colModulo = (width()-2) % 7;
485 int rowModulo = (height()-2) % 6; 488 int rowModulo = (height()-2) % 6;
486#if 0 489#if 0
487 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 490 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
488 6 - x/daysize.width() : x/daysize.width()); 491 6 - x/daysize.width() : x/daysize.width());
489#endif 492#endif
490 int xVal = (x-colModulo/2-2)/daysize.width(); 493 int xVal = (x-colModulo/2-2)/daysize.width();
491 int yVal = (y-rowModulo/2-2)/daysize.height(); 494 int yVal = (y-rowModulo/2-2)/daysize.height();
492 495
493 496
494 return 7*(yVal) + xVal; 497 return 7*(yVal) + xVal;
495 498
496} 499}
497 500
498// ---------------------------------------------------------------------------- 501// ----------------------------------------------------------------------------
499// M O U S E E V E N T H A N D L I N G 502// M O U S E E V E N T H A N D L I N G
500// ---------------------------------------------------------------------------- 503// ----------------------------------------------------------------------------
501 504
502void KODayMatrix::mousePressEvent (QMouseEvent* e) 505void KODayMatrix::mousePressEvent (QMouseEvent* e)
503{ 506{
504 507
505 if ( e->button() == LeftButton ) 508 if ( e->button() == LeftButton )
506 mouseDown = true; 509 mouseDown = true;
507 mSelStart = getDayIndexFrom(e->x(), e->y()); 510 mSelStart = getDayIndexFrom(e->x(), e->y());
508 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 511 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
509 mSelInit = mSelStart; 512 mSelInit = mSelStart;
510 mSelEnd = mSelStart; 513 mSelEnd = mSelStart;
511 repaint(false); 514 repaint(false);
512} 515}
513 516
514void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 517void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
515{ 518{
516 if ( e->button() == LeftButton ) 519 if ( e->button() == LeftButton )
517 if ( ! mouseDown ) { 520 if ( ! mouseDown ) {
518 return; 521 return;
519 } 522 }
520 else 523 else
521 mouseDown = false; 524 mouseDown = false;
522 int tmp = getDayIndexFrom(e->x(), e->y()); 525 int tmp = getDayIndexFrom(e->x(), e->y());
523 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 526 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
524 527
525 if (mSelInit > tmp) { 528 if (mSelInit > tmp) {
526 mSelEnd = mSelInit; 529 mSelEnd = mSelInit;
527 if (tmp != mSelStart) { 530 if (tmp != mSelStart) {
@@ -585,371 +588,377 @@ void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
585 return; 588 return;
586 } 589 }
587 590
588 // some visual feedback 591 // some visual feedback
589// oldPalette = palette(); 592// oldPalette = palette();
590// setPalette(my_HilitePalette); 593// setPalette(my_HilitePalette);
591// update(); 594// update();
592#endif 595#endif
593} 596}
594 597
595void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 598void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
596{ 599{
597#ifndef KORG_NODND 600#ifndef KORG_NODND
598 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 601 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
599 e->ignore(); 602 e->ignore();
600 return; 603 return;
601 } 604 }
602 605
603 e->accept(); 606 e->accept();
604#endif 607#endif
605} 608}
606 609
607void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 610void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
608{ 611{
609#ifndef KORG_NODND 612#ifndef KORG_NODND
610// setPalette(oldPalette); 613// setPalette(oldPalette);
611// update(); 614// update();
612#endif 615#endif
613} 616}
614 617
615void KODayMatrix::dropEvent(QDropEvent *e) 618void KODayMatrix::dropEvent(QDropEvent *e)
616{ 619{
617#ifndef KORG_NODND 620#ifndef KORG_NODND
618// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 621// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
619 622
620 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 623 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
621 e->ignore(); 624 e->ignore();
622 return; 625 return;
623 } 626 }
624 627
625 DndFactory factory( mCalendar ); 628 DndFactory factory( mCalendar );
626 Event *event = factory.createDrop(e); 629 Event *event = factory.createDrop(e);
627 630
628 if (event) { 631 if (event) {
629 e->acceptAction(); 632 e->acceptAction();
630 633
631 Event *existingEvent = mCalendar->event(event->uid()); 634 Event *existingEvent = mCalendar->event(event->uid());
632 635
633 if(existingEvent) { 636 if(existingEvent) {
634 // uniquify event 637 // uniquify event
635 event->recreate(); 638 event->recreate();
636/* 639/*
637 KMessageBox::sorry(this, 640 KMessageBox::sorry(this,
638 i18n("Event already exists in this calendar."), 641 i18n("Event already exists in this calendar."),
639 i18n("Drop Event")); 642 i18n("Drop Event"));
640 delete event; 643 delete event;
641 return; 644 return;
642*/ 645*/
643 } 646 }
644// kdDebug() << "Drop new Event" << endl; 647// kdDebug() << "Drop new Event" << endl;
645 // Adjust date 648 // Adjust date
646 QDateTime start = event->dtStart(); 649 QDateTime start = event->dtStart();
647 QDateTime end = event->dtEnd(); 650 QDateTime end = event->dtEnd();
648 int duration = start.daysTo(end); 651 int duration = start.daysTo(end);
649 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 652 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
650 653
651 start.setDate(days[idx]); 654 start.setDate(days[idx]);
652 end.setDate(days[idx].addDays(duration)); 655 end.setDate(days[idx].addDays(duration));
653 656
654 event->setDtStart(start); 657 event->setDtStart(start);
655 event->setDtEnd(end); 658 event->setDtEnd(end);
656 mCalendar->addEvent(event); 659 mCalendar->addEvent(event);
657 660
658 emit eventDropped(event); 661 emit eventDropped(event);
659 } else { 662 } else {
660// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 663// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
661 e->ignore(); 664 e->ignore();
662 } 665 }
663#endif 666#endif
664} 667}
665 668
666// ---------------------------------------------------------------------------- 669// ----------------------------------------------------------------------------
667// P A I N T E V E N T H A N D L I N G 670// P A I N T E V E N T H A N D L I N G
668// ---------------------------------------------------------------------------- 671// ----------------------------------------------------------------------------
669 672
670void KODayMatrix::paintEvent(QPaintEvent * pevent) 673void KODayMatrix::paintEvent(QPaintEvent * pevent)
671{ 674{
672 675
673 if ( width() <= 0 || height() <= 0 ) 676 if ( width() <= 0 || height() <= 0 )
674 return; 677 return;
675 if ( mPendingUpdateBeforeRepaint ) { 678 if ( mPendingUpdateBeforeRepaint ) {
676 updateViewTimed(); 679 updateViewTimed();
677 mPendingUpdateBeforeRepaint = false; 680 mPendingUpdateBeforeRepaint = false;
678 } 681 }
679 if ( myPix.width() != width() || myPix.height()!=height() ) { 682 if ( myPix.width() != width() || myPix.height()!=height() ) {
680 myPix.resize(size() ); 683 myPix.resize(size() );
684 mRedrawNeeded = true;
681 } 685 }
682 QPainter p(&myPix);
683 p.setFont(font());
684 686
687 if ( mRedrawNeeded ) {
688 //qDebug("REDRAW ");
689 QPainter p(&myPix);
690 p.setFont(font());
685 691
686 int dheight = daysize.height(); 692
687 int dwidth = daysize.width(); 693 int dheight = daysize.height();
688 int row,col; 694 int dwidth = daysize.width();
689 int selw, selh; 695 int row,col;
690 int xyOff = frameWidth(); 696 int selw, selh;
691 int colModulo = (width()-2) % 7; 697 int xyOff = frameWidth();
692 int rowModulo = (height()-2) % 6; 698 int colModulo = (width()-2) % 7;
693 //qDebug("col %d row %d ",colModulo,rowModulo ); 699 int rowModulo = (height()-2) % 6;
700 //qDebug("col %d row %d ",colModulo,rowModulo );
694 701
695 bool isRTL = KOGlobals::self()->reverseLayout(); 702 bool isRTL = KOGlobals::self()->reverseLayout();
696 703
697 // draw background and topleft frame 704 // draw background and topleft frame
698 p.fillRect(0,0,width(),height(), mDefaultBackColor); 705 p.fillRect(0,0,width(),height(), mDefaultBackColor);
699 p.setPen(mDefaultTextColor); 706 p.setPen(mDefaultTextColor);
700 p.drawRect(0, 0, width(), height()); 707 p.drawRect(0, 0, width(), height());
701 int mSelStartT = mSelStart; 708 int mSelStartT = mSelStart;
702 int mSelEndT = mSelEnd; 709 int mSelEndT = mSelEnd;
703 if ( mSelEndT >= NUMDAYS ) 710 if ( mSelEndT >= NUMDAYS )
704 mSelEndT = NUMDAYS-1; 711 mSelEndT = NUMDAYS-1;
705 // draw selected days with highlighted background color 712 // draw selected days with highlighted background color
706 if (mSelStart != NOSELECTION) { 713 if (mSelStart != NOSELECTION) {
707 bool skip = false; 714 bool skip = false;
708 if ( ! mouseDown ) { 715 if ( ! mouseDown ) {
709 int mo = days[20].month(); 716 int mo = days[20].month();
710 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 717 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
711 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 718 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
712 int startMo = days[mSelStartT].month(); 719 int startMo = days[mSelStartT].month();
713 int endMo = days[mSelEndT].month(); 720 int endMo = days[mSelEndT].month();
714 if ( startMo == 12 && mo == 1 && endMo <= 2 ) 721 if ( startMo == 12 && mo == 1 && endMo <= 2 )
715 startMo = 1; 722 startMo = 1;
716 if ( endMo == 1 && mo == 12 ) 723 if ( endMo == 1 && mo == 12 )
717 endMo = 12; 724 endMo = 12;
718 if ( mo == 12 && startMo == 1 ) 725 if ( mo == 12 && startMo == 1 )
719 startMo = 13; 726 startMo = 13;
720 if ( (startMo > mo || endMo < mo) ) { 727 if ( (startMo > mo || endMo < mo) ) {
721 skip = true; 728 skip = true;
722 } else { 729 } else {
723 if ( days[mSelStartT].month() != mo ) { 730 if ( days[mSelStartT].month() != mo ) {
724 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 731 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
725 mSelStartT += add +1; 732 mSelStartT += add +1;
726 } 733 }
727 if ( days[mSelEndT].month() != mo ) { 734 if ( days[mSelEndT].month() != mo ) {
728 int sub = days[mSelEndT].day(); 735 int sub = days[mSelEndT].day();
729 mSelEndT -= sub ; 736 mSelEndT -= sub ;
730 } 737 }
731 } 738 }
732 } 739 }
733 //qDebug("SKIP %d ", skip); 740 //qDebug("SKIP %d ", skip);
734 if ( ! skip ) { 741 if ( ! skip ) {
735 row = mSelStartT/7; 742 row = mSelStartT/7;
736 col = mSelStartT -row*7; 743 col = mSelStartT -row*7;
737 QColor selcol = KOPrefs::instance()->mHighlightColor; 744 QColor selcol = KOPrefs::instance()->mHighlightColor;
738 int addCol = 0; 745 int addCol = 0;
739 int addRow = 0; 746 int addRow = 0;
740 int addRow2 = 0; 747 int addRow2 = 0;
741 int addCol2 = 0; 748 int addCol2 = 0;
742 if (row == mSelEndT/7) { 749 if (row == mSelEndT/7) {
743 if ( rowModulo ) { 750 if ( rowModulo ) {
744 if ( row >= 6 - rowModulo ) 751 if ( row >= 6 - rowModulo )
745 addRow = row - 5 + rowModulo; 752 addRow = row - 5 + rowModulo;
746 } 753 }
747 if ( colModulo ) { 754 if ( colModulo ) {
748 int colt1 = mSelEndT%7; 755 int colt1 = mSelEndT%7;
749 //qDebug("colt1 %d ", colt1 ); 756 //qDebug("colt1 %d ", colt1 );
750 if ( colt1 >= 7 - colModulo ) 757 if ( colt1 >= 7 - colModulo )
751 addCol = colt1 - 7 + colModulo+1; 758 addCol = colt1 - 7 + colModulo+1;
752 int colt = mSelStartT%7; 759 int colt = mSelStartT%7;
753 if ( colt >= 7 - colModulo ) 760 if ( colt >= 7 - colModulo )
754 addCol2 = colt - 7 + colModulo; 761 addCol2 = colt - 7 + colModulo;
755 addCol -= addCol2; 762 addCol -= addCol2;
756 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 763 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
757 } 764 }
758 // Single row selection 765 // Single row selection
759 if ( row == 0) 766 if ( row == 0)
760 addRow = 1; 767 addRow = 1;
761 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 768 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
762 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 769 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
763 } else { 770 } else {
764 // draw first row to the right 771 // draw first row to the right
765 if ( colModulo ) { 772 if ( colModulo ) {
766 if ( col >= 7 - colModulo ) 773 if ( col >= 7 - colModulo )
767 addCol2 = col - 7 + colModulo; 774 addCol2 = col - 7 + colModulo;
768 } 775 }
769 if ( rowModulo ) { 776 if ( rowModulo ) {
770 if ( row >= 6 - rowModulo ) 777 if ( row >= 6 - rowModulo )
771 addRow = row - 5 + rowModulo; 778 addRow = row - 5 + rowModulo;
772 } 779 }
773 if ( row == 0) 780 if ( row == 0)
774 addRow = 1; 781 addRow = 1;
775 int drawWid = width()-(col*dwidth+1+addCol2)-1; 782 int drawWid = width()-(col*dwidth+1+addCol2)-1;
776 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, 783 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
777 dheight+1, selcol); 784 dheight+1, selcol);
778 // draw full block till last line 785 // draw full block till last line
779 selh = mSelEndT/7-row; 786 selh = mSelEndT/7-row;
780 addRow = 0; 787 addRow = 0;
781 if ( rowModulo ) { 788 if ( rowModulo ) {
782 if ( mSelEndT/7 >= 6 - rowModulo ) 789 if ( mSelEndT/7 >= 6 - rowModulo )
783 addRow = mSelEndT/7 - 5 + rowModulo; 790 addRow = mSelEndT/7 - 5 + rowModulo;
784 } 791 }
785 if (selh > 1) { 792 if (selh > 1) {
786 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 793 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
787 } 794 }
788 // draw last block from left to mSelEndT 795 // draw last block from left to mSelEndT
789 selw = mSelEndT-7*(mSelEndT/7)+1; 796 selw = mSelEndT-7*(mSelEndT/7)+1;
790 //qDebug("esl %d ",selw ); 797 //qDebug("esl %d ",selw );
791 int add = 0; 798 int add = 0;
792 if ( colModulo ) { 799 if ( colModulo ) {
793 add = 7 - colModulo; 800 add = 7 - colModulo;
794 if ( selw > add ) 801 if ( selw > add )
795 add = selw - add; 802 add = selw - add;
796 else 803 else
797 add = 0; 804 add = 0;
798 } 805 }
799 //qDebug("add %d ", add); 806 //qDebug("add %d ", add);
800 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 807 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
801 selw*dwidth+add, dheight+1, selcol); 808 selw*dwidth+add, dheight+1, selcol);
802 } 809 }
803 } 810 }
804 } 811 }
805 812
806 // iterate over all days in the matrix and draw the day label in appropriate colors 813 // iterate over all days in the matrix and draw the day label in appropriate colors
807 QColor actcol = mDefaultTextColorShaded; 814 QColor actcol = mDefaultTextColorShaded;
808 p.setPen(actcol); 815 p.setPen(actcol);
809 QPen tmppen; 816 QPen tmppen;
810 for(int i = 0; i < NUMDAYS; i++) { 817 for(int i = 0; i < NUMDAYS; i++) {
811 row = i/7; 818 row = i/7;
812 col = isRTL ? 6-(i-row*7) : i-row*7; 819 col = isRTL ? 6-(i-row*7) : i-row*7;
813 820
814 // if it is the first day of a month switch color from normal to shaded and vice versa 821 // if it is the first day of a month switch color from normal to shaded and vice versa
815 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 822 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
816 if (actcol == mDefaultTextColorShaded) { 823 if (actcol == mDefaultTextColorShaded) {
817 actcol = mDefaultTextColor; 824 actcol = mDefaultTextColor;
818 } else { 825 } else {
819 actcol = mDefaultTextColorShaded; 826 actcol = mDefaultTextColorShaded;
820 } 827 }
821 p.setPen(actcol); 828 p.setPen(actcol);
822 } 829 }
823 if (actcol == mDefaultTextColorShaded) { 830 if (actcol == mDefaultTextColorShaded) {
824 if ( ! mouseDown ) { 831 if ( ! mouseDown ) {
825 continue; 832 continue;
826 } 833 }
827 } 834 }
828 //Reset pen color after selected days block 835 //Reset pen color after selected days block
829 if (i == mSelEndT+1) { 836 if (i == mSelEndT+1) {
830 p.setPen(actcol); 837 p.setPen(actcol);
831 } 838 }
832 839
833 // if today then draw rectangle around day 840 // if today then draw rectangle around day
834 if (today == i) { 841 if (today == i) {
835 tmppen = p.pen(); 842 tmppen = p.pen();
836 QPen mTodayPen(p.pen()); 843 QPen mTodayPen(p.pen());
837 if ( daysize.width() < 20 ) 844 if ( daysize.width() < 20 )
838 mTodayPen.setWidth(1); 845 mTodayPen.setWidth(1);
839 else 846 else
840 mTodayPen.setWidth(mTodayMarginWidth); 847 mTodayPen.setWidth(mTodayMarginWidth);
841 //draw red rectangle for holidays 848 //draw red rectangle for holidays
842 if (!mHolidays[i].isNull()) { 849 if (!mHolidays[i].isNull()) {
843 if (actcol == mDefaultTextColor) { 850 if (actcol == mDefaultTextColor) {
844 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 851 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
845 } else { 852 } else {
846 mTodayPen.setColor(mHolidayColorShaded); 853 mTodayPen.setColor(mHolidayColorShaded);
847 } 854 }
848 } 855 }
849 //draw gray rectangle for today if in selection 856 //draw gray rectangle for today if in selection
850 if (i >= mSelStartT && i <= mSelEndT) { 857 if (i >= mSelStartT && i <= mSelEndT) {
851 QColor grey("grey"); 858 QColor grey("grey");
852 mTodayPen.setColor(grey); 859 mTodayPen.setColor(grey);
853 } 860 }
854 p.setPen(mTodayPen); 861 p.setPen(mTodayPen);
855 862
856 863
857 int addCol = 0; 864 int addCol = 0;
858 int addRow = 0; 865 int addRow = 0;
859 if (rowModulo) { 866 if (rowModulo) {
860 if ( row >= 6 - rowModulo ) 867 if ( row >= 6 - rowModulo )
861 addRow = row - 5 + rowModulo; 868 addRow = row - 5 + rowModulo;
862 } 869 }
863 if ( colModulo ) { 870 if ( colModulo ) {
864 if ( col >= 7 - colModulo ) 871 if ( col >= 7 - colModulo )
865 addCol = col - 6 + colModulo-1; 872 addCol = col - 6 + colModulo-1;
866 } 873 }
867 874
868 addCol += 1; 875 addCol += 1;
869 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); 876 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1);
870 p.setPen(tmppen); 877 p.setPen(tmppen);
871 } 878 }
872 879
873 // if any events are on that day then draw it using a bold font 880 // if any events are on that day then draw it using a bold font
874 if ( eDays.testBit(i) ) { 881 if ( eDays.testBit(i) ) {
875 QFont myFont = font(); 882 QFont myFont = font();
876 myFont.setBold(true); 883 myFont.setBold(true);
877 p.setFont(myFont); 884 p.setFont(myFont);
878 } 885 }
879 886
880 // if it is a holiday then use the default holiday color 887 // if it is a holiday then use the default holiday color
881 if ( !mHolidays[i].isNull()) { 888 if ( !mHolidays[i].isNull()) {
882 if ( bDays.testBit(i) ) { 889 if ( bDays.testBit(i) ) {
883 if ( hDays.testBit(i) ) 890 if ( hDays.testBit(i) )
884 p.setPen(QColor(Qt::green)); 891 p.setPen(QColor(Qt::green));
885 else 892 else
886 p.setPen(QColor(Qt::green).dark()); 893 p.setPen(QColor(Qt::green).dark());
887 } else { 894 } else {
888 if (actcol == mDefaultTextColor ) { 895 if (actcol == mDefaultTextColor ) {
889 p.setPen(KOPrefs::instance()->mHolidayColor); 896 p.setPen(KOPrefs::instance()->mHolidayColor);
890 } else { 897 } else {
891 p.setPen(mHolidayColorShaded); 898 p.setPen(mHolidayColorShaded);
892 } 899 }
893 } 900 }
894 } 901 }
895 902
896 // draw selected days with special color 903 // draw selected days with special color
897 // DO NOT specially highlight holidays in selection ! 904 // DO NOT specially highlight holidays in selection !
898 if (i >= mSelStartT && i <= mSelEndT) { 905 if (i >= mSelStartT && i <= mSelEndT) {
899 ;//p.setPen(mSelectedDaysColor); 906 ;//p.setPen(mSelectedDaysColor);
900 } 907 }
901 908
902 int addCol = 0; 909 int addCol = 0;
903 int addRow = 0; 910 int addRow = 0;
904 if ( colModulo ) { 911 if ( colModulo ) {
905 if ( col >= 7 - colModulo ) 912 if ( col >= 7 - colModulo )
906 addCol = col - 7 + colModulo; 913 addCol = col - 7 + colModulo;
907 } 914 }
908 if ( rowModulo ) { 915 if ( rowModulo ) {
909 if ( row >= 6 - rowModulo ) 916 if ( row >= 6 - rowModulo )
910 addRow = row - 5 + rowModulo; 917 addRow = row - 5 + rowModulo;
911 } 918 }
912 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 919 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
913 ++addCol;//++addCol; 920 ++addCol;//++addCol;
914 if ( row == 0) 921 if ( row == 0)
915 addRow = 1; 922 addRow = 1;
916 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 923 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
917 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 924 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
918 925
919 // reset color to actual color 926 // reset color to actual color
920 if (!mHolidays[i].isNull()) { 927 if (!mHolidays[i].isNull()) {
921 p.setPen(actcol); 928 p.setPen(actcol);
922 } 929 }
923 // reset bold font to plain font 930 // reset bold font to plain font
924 if ( eDays.testBit(i)) { 931 if ( eDays.testBit(i)) {
925 QFont myFont = font(); 932 QFont myFont = font();
926 myFont.setBold(false); 933 myFont.setBold(false);
927 p.setFont(myFont); 934 p.setFont(myFont);
928 } 935 }
929 } 936 }
930 int off = 0;//xyOff; 937 } else {
931 bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); 938 //qDebug("NO redraw ");
932 //qDebug("ffffffffff %d ", off); 939 }
940 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
941 mRedrawNeeded = false;
933} 942}
934 943
935// ---------------------------------------------------------------------------- 944// ----------------------------------------------------------------------------
936// R E SI Z E E V E N T H A N D L I N G 945// R E SI Z E E V E N T H A N D L I N G
937// ---------------------------------------------------------------------------- 946// ----------------------------------------------------------------------------
938 947
939void KODayMatrix::resizeEvent(QResizeEvent *) 948void KODayMatrix::resizeEvent(QResizeEvent *)
940{ 949{
941 QRect sz = frameRect(); 950 QRect sz = frameRect();
942 daysize.setHeight(sz.height()*7 / NUMDAYS); 951 daysize.setHeight(sz.height()*7 / NUMDAYS);
943 daysize.setWidth(sz.width() / 7); 952 daysize.setWidth(sz.width() / 7);
944} 953}
945 954
946QSize KODayMatrix::sizeHint() const 955QSize KODayMatrix::sizeHint() const
947{ 956{
948 957
949 QFontMetrics fm ( font() ); 958 QFontMetrics fm ( font() );
950 int wid = fm.width( "30") *7+3; 959 int wid = fm.width( "30") *7+3;
951 int hei = fm.height() * 6+3; 960 int hei = fm.height() * 6+3;
952 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 961 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
953 return QSize ( wid, hei ); 962 return QSize ( wid, hei );
954 963
955} 964}
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index 38a7f92..731117c 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -134,192 +134,193 @@ public:
134 */ 134 */
135 void updateView(QDate actdate); 135 void updateView(QDate actdate);
136 void updateEvents(); 136 void updateEvents();
137 137
138 /** returns the QDate object associated with day indexed by the 138 /** returns the QDate object associated with day indexed by the
139 * supplied offset. 139 * supplied offset.
140 */ 140 */
141 const QDate& getDate(int offset); 141 const QDate& getDate(int offset);
142 void setCalendar( Calendar * ); 142 void setCalendar( Calendar * );
143 /** returns the official name of this holy day or 0 if there is no label 143 /** returns the official name of this holy day or 0 if there is no label
144 * for this day. 144 * for this day.
145 */ 145 */
146 QString getHolidayLabel(int offset); 146 QString getHolidayLabel(int offset);
147 147
148 /** adds all actual selected days from mSelStart to mSelEnd to the supplied 148 /** adds all actual selected days from mSelStart to mSelEnd to the supplied
149 * DateList. 149 * DateList.
150 */ 150 */
151 void addSelectedDaysTo(DateList&); 151 void addSelectedDaysTo(DateList&);
152 152
153 /** sets the actual to be displayed selection in the day matrix starting from 153 /** 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 154 * start and ending with end. Theview must be manually updated by calling
155 * repaint. (?) 155 * repaint. (?)
156 */ 156 */
157 bool setSelectedDaysFrom(const QDate& start, const QDate& end); 157 bool setSelectedDaysFrom(const QDate& start, const QDate& end);
158 void clearSelection(); 158 void clearSelection();
159 159
160 /** Is today visible in the view? Keep this in sync with 160 /** Is today visible in the view? Keep this in sync with
161 * the values today (below) can take. 161 * the values today (below) can take.
162 */ 162 */
163 bool isTodayVisible() const { return today>=0; } ; 163 bool isTodayVisible() const { return today>=0; } ;
164 164
165 /** If today is visible, then we can find out if today is 165 /** If today is visible, then we can find out if today is
166 * near the beginning or the end of the month. 166 * near the beginning or the end of the month.
167 * This is dependent on today remaining the index 167 * This is dependent on today remaining the index
168 * in the array of visible dates and going from 168 * in the array of visible dates and going from
169 * top left (0) to bottom right (41). 169 * top left (0) to bottom right (41).
170 */ 170 */
171 bool isBeginningOfMonth() const { return today<=8; } ; 171 bool isBeginningOfMonth() const { return today<=8; } ;
172 bool isEndOfMonth() const { return today>=27; } ; 172 bool isEndOfMonth() const { return today>=27; } ;
173 QString getWhatsThisText( QPoint ) ; 173 QString getWhatsThisText( QPoint ) ;
174 QSize sizeHint() const; 174 QSize sizeHint() const;
175 QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} 175 QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);}
176public slots: 176public slots:
177 /** Recalculates all the flags of the days in the matrix like holidays or events 177 /** 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). 178 * on a day (Actually calls above method with the actual startdate).
179 */ 179 */
180 void updateView(); 180 void updateView();
181 void updateViewTimed(); 181 void updateViewTimed();
182 void repaintViewTimed(); 182 void repaintViewTimed();
183 183
184 /** 184 /**
185 * Calculate which square in the matrix should be 185 * Calculate which square in the matrix should be
186 * hilighted to indicate it's today. 186 * hilighted to indicate it's today.
187 */ 187 */
188 void recalculateToday(); 188 void recalculateToday();
189 189
190/* 190/*
191 void setStartDate(QDate); 191 void setStartDate(QDate);
192*/ 192*/
193 193
194signals: 194signals:
195 195
196 /** emitted if the user selects a block of days with the mouse by dragging a rectangle 196 /** emitted if the user selects a block of days with the mouse by dragging a rectangle
197 * inside the matrix 197 * inside the matrix
198 * 198 *
199 * @param daylist list of days that have been selected by the user 199 * @param daylist list of days that have been selected by the user
200 */ 200 */
201 void selected( const KCal::DateList &daylist ); 201 void selected( const KCal::DateList &daylist );
202 202
203 /** emitted if the user has dropped an event inside the matrix 203 /** emitted if the user has dropped an event inside the matrix
204 * 204 *
205 * @param event the dropped calendar event 205 * @param event the dropped calendar event
206 */ 206 */
207 void eventDropped(Event *event); 207 void eventDropped(Event *event);
208 208
209protected: 209protected:
210 210
211 void paintEvent(QPaintEvent *ev); 211 void paintEvent(QPaintEvent *ev);
212 212
213 void mousePressEvent (QMouseEvent* e); 213 void mousePressEvent (QMouseEvent* e);
214 214
215 void mouseReleaseEvent (QMouseEvent* e); 215 void mouseReleaseEvent (QMouseEvent* e);
216 216
217 void mouseMoveEvent (QMouseEvent* e); 217 void mouseMoveEvent (QMouseEvent* e);
218 218
219 void dragEnterEvent(QDragEnterEvent *); 219 void dragEnterEvent(QDragEnterEvent *);
220 220
221 void dragMoveEvent(QDragMoveEvent *); 221 void dragMoveEvent(QDragMoveEvent *);
222 222
223 void dragLeaveEvent(QDragLeaveEvent *); 223 void dragLeaveEvent(QDragLeaveEvent *);
224 224
225 void dropEvent(QDropEvent *); 225 void dropEvent(QDropEvent *);
226 226
227 void resizeEvent(QResizeEvent *); 227 void resizeEvent(QResizeEvent *);
228 228
229private: 229private:
230 bool mRedrawNeeded;
230 KODaymatrixWhatsThis* mKODaymatrixWhatsThis; 231 KODaymatrixWhatsThis* mKODaymatrixWhatsThis;
231 bool mouseDown; 232 bool mouseDown;
232 QBitArray bDays; 233 QBitArray bDays;
233 QBitArray hDays; 234 QBitArray hDays;
234 QBitArray eDays; 235 QBitArray eDays;
235 QPixmap myPix; 236 QPixmap myPix;
236 QTimer* mUpdateTimer; 237 QTimer* mUpdateTimer;
237 QTimer* mRepaintTimer; 238 QTimer* mRepaintTimer;
238 bool mDayChanged; 239 bool mDayChanged;
239 bool mPendingUpdateBeforeRepaint; 240 bool mPendingUpdateBeforeRepaint;
240 241
241 /** returns the index of the day located at the matrix's widget (x,y) position. 242 /** returns the index of the day located at the matrix's widget (x,y) position.
242 * 243 *
243 * @param x horizontal coordinate 244 * @param x horizontal coordinate
244 * @param y vertical coordinate 245 * @param y vertical coordinate
245 */ 246 */
246 int getDayIndexFrom(int x, int y); 247 int getDayIndexFrom(int x, int y);
247 248
248 /** calculates a "shaded" color from the supplied color object. 249 /** calculates a "shaded" color from the supplied color object.
249 * (Copied from Cornelius's kdpdatebutton.cpp) 250 * (Copied from Cornelius's kdpdatebutton.cpp)
250 * 251 *
251 * @param color source based on which a shaded color should be calculated. 252 * @param color source based on which a shaded color should be calculated.
252 */ 253 */
253 QColor getShadedColor(QColor color); 254 QColor getShadedColor(QColor color);
254 255
255 /** number of days to be displayed. For now there is no support for any other number then 42. 256 /** number of days to be displayed. For now there is no support for any other number then 42.
256 so change it at your own risk :o) */ 257 so change it at your own risk :o) */
257 static const int NUMDAYS; 258 static const int NUMDAYS;
258 259
259 /** calendar instance to be queried for holidays, events, ... */ 260 /** calendar instance to be queried for holidays, events, ... */
260 Calendar *mCalendar; 261 Calendar *mCalendar;
261 262
262 /** starting date of the matrix */ 263 /** starting date of the matrix */
263 QDate startdate; 264 QDate startdate;
264 265
265 /** array of day labels to optimeize drawing performance. */ 266 /** array of day labels to optimeize drawing performance. */
266 QString *daylbls; 267 QString *daylbls;
267 268
268 /** array of days displayed to reduce memory consumption by 269 /** array of days displayed to reduce memory consumption by
269 subsequently calling QDate::addDays(). */ 270 subsequently calling QDate::addDays(). */
270 QDate *days; 271 QDate *days;
271 272
272 /** array of storing the number of events on a given day. 273 /** array of storing the number of events on a given day.
273 * used for drawing a bold font if there is at least one event on that day. 274 * used for drawing a bold font if there is at least one event on that day.
274 */ 275 */
275 //int *events; 276 //int *events;
276 277
277 /** stores holiday names of the days shown in the matrix. */ 278 /** stores holiday names of the days shown in the matrix. */
278 QMap<int,QString> mHolidays; 279 QMap<int,QString> mHolidays;
279 280
280 /** indey of today or -1 if today is not visible in the matrix. */ 281 /** indey of today or -1 if today is not visible in the matrix. */
281 int today; 282 int today;
282 283
283 /** index of day where dragged selection was initiated. 284 /** index of day where dragged selection was initiated.
284 used to detect "negative" timely selections */ 285 used to detect "negative" timely selections */
285 int mSelInit; 286 int mSelInit;
286 287
287 /** if mSelStart has this value it indicates that there is no 288 /** if mSelStart has this value it indicates that there is no
288 actual selection in the matrix. */ 289 actual selection in the matrix. */
289 static const int NOSELECTION; 290 static const int NOSELECTION;
290 291
291 /** index of first selected day. */ 292 /** index of first selected day. */
292 int mSelStart; 293 int mSelStart;
293 294
294 /** index of last selected day. */ 295 /** index of last selected day. */
295 int mSelEnd; 296 int mSelEnd;
296 297
297 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ 298 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */
298 DynamicTip* mToolTip; 299 DynamicTip* mToolTip;
299 300
300 301
301 /** default background colour of the matrix. */ 302 /** default background colour of the matrix. */
302 QColor mDefaultBackColor; 303 QColor mDefaultBackColor;
303 304
304 /** default text color of the matrix. */ 305 /** default text color of the matrix. */
305 QColor mDefaultTextColor; 306 QColor mDefaultTextColor;
306 307
307 /** default text color for days not in the actual month. */ 308 /** default text color for days not in the actual month. */
308 QColor mDefaultTextColorShaded; 309 QColor mDefaultTextColorShaded;
309 310
310 /** default text color for holidays not in the actual month. */ 311 /** default text color for holidays not in the actual month. */
311 QColor mHolidayColorShaded; 312 QColor mHolidayColorShaded;
312 313
313 /** text color for selected days. */ 314 /** text color for selected days. */
314 QColor mSelectedDaysColor; 315 QColor mSelectedDaysColor;
315 316
316 /** default width of the frame drawn around today if it is visible in the matrix. */ 317 /** default width of the frame drawn around today if it is visible in the matrix. */
317 int mTodayMarginWidth; 318 int mTodayMarginWidth;
318 319
319 /** stores actual size of each day in the widget so that I dont need to ask this data 320 /** stores actual size of each day in the widget so that I dont need to ask this data
320 * on every repaint. 321 * on every repaint.
321 */ 322 */
322 QRect daysize; 323 QRect daysize;
323 324
324}; 325};
325 326