summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 6d6ae8a..e66ddce 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1960 +1,1976 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,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 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 88 setHScrollBarMode(QScrollView::AlwaysOff);
89} 89}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
91{ 91{
92 92
93} 93}
94 94
95 95
96void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 96void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
97{ 97{
98 QListBox::focusInEvent ( e ); 98 QListBox::focusInEvent ( e );
99 QListBoxItem * i = item ( 0 ); 99 QListBoxItem * i = item ( 0 );
100 if ( i && resetOnFocusIn ) { 100 if ( i && resetOnFocusIn ) {
101 setCurrentItem( i ); 101 setCurrentItem( i );
102 setSelected ( 0, true ); 102 setSelected ( 0, true );
103 } 103 }
104 resetOnFocusIn = true; 104 resetOnFocusIn = true;
105 105
106 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 106 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
107 QListBoxItem *fi = firstItem (); 107 QListBoxItem *fi = firstItem ();
108 if (fi ) { 108 if (fi ) {
109 int ihei = fi->height( this ); 109 int ihei = fi->height( this );
110 int hei = numRows () * ihei; 110 int hei = numRows () * ihei;
111 if ( hei < height() - horizontalScrollBar()->height () ) { 111 if ( hei < height() - horizontalScrollBar()->height () ) {
112 setVScrollBarMode(QScrollView::AlwaysOff); 112 setVScrollBarMode(QScrollView::AlwaysOff);
113 } 113 }
114 else 114 else
115 setVScrollBarMode(QScrollView::Auto); 115 setVScrollBarMode(QScrollView::Auto);
116 if ( ihei *3 > height() ) { 116 if ( ihei *3 > height() ) {
117 setHScrollBarMode(QScrollView::AlwaysOff); 117 setHScrollBarMode(QScrollView::AlwaysOff);
118 } 118 }
119 else { 119 else {
120 setHScrollBarMode(QScrollView::Auto); 120 setHScrollBarMode(QScrollView::Auto);
121 } 121 }
122 } else { 122 } else {
123 setVScrollBarMode(QScrollView::Auto); 123 setVScrollBarMode(QScrollView::Auto);
124 setHScrollBarMode(QScrollView::Auto); 124 setHScrollBarMode(QScrollView::Auto);
125 } 125 }
126 } 126 }
127} 127}
128void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 128void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
129{ 129{
130 int i = currentItem (); 130 int i = currentItem ();
131 if ( i >= 0 ) { 131 if ( i >= 0 ) {
132 setSelected ( i, false ); 132 setSelected ( i, false );
133 } 133 }
134 QListBox::focusOutEvent ( e ); 134 QListBox::focusOutEvent ( e );
135 setVScrollBarMode(QScrollView::AlwaysOff); 135 setVScrollBarMode(QScrollView::AlwaysOff);
136 setHScrollBarMode(QScrollView::AlwaysOff); 136 setHScrollBarMode(QScrollView::AlwaysOff);
137} 137}
138 138
139QString KNoScrollListBox::getWhatsThisText(QPoint p) 139QString KNoScrollListBox::getWhatsThisText(QPoint p)
140{ 140{
141 QListBoxItem* item = itemAt ( p ); 141 QListBoxItem* item = itemAt ( p );
142 if ( ! item ) { 142 if ( ! item ) {
143 return i18n("Click in the cell\nto add an event!"); 143 return i18n("Click in the cell\nto add an event!");
144 } 144 }
145 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 145 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
146 KOPrefs::instance()->mWTshowDetails, 146 KOPrefs::instance()->mWTshowDetails,
147 KOPrefs::instance()->mWTshowCreated, 147 KOPrefs::instance()->mWTshowCreated,
148 KOPrefs::instance()->mWTshowChanged); 148 KOPrefs::instance()->mWTshowChanged);
149} 149}
150void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 150void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
151{ 151{
152 //qDebug("KNoScrollListBox::keyPressEvent "); 152 //qDebug("KNoScrollListBox::keyPressEvent ");
153 switch(e->key()) { 153 switch(e->key()) {
154 case Key_Right: 154 case Key_Right:
155 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 155 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
156 { 156 {
157 e->ignore(); 157 e->ignore();
158 return; 158 return;
159 } 159 }
160 scrollBy(10,0); 160 scrollBy(10,0);
161 break; 161 break;
162 case Key_Left: 162 case Key_Left:
163 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 163 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
164 { 164 {
165 e->ignore(); 165 e->ignore();
166 return; 166 return;
167 } 167 }
168 scrollBy(-10,0); 168 scrollBy(-10,0);
169 break; 169 break;
170 case Key_Up: 170 case Key_Up:
171 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 171 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
172 e->ignore(); 172 e->ignore();
173 break; 173 break;
174 } 174 }
175 if ( count() ) { 175 if ( count() ) {
176 setCurrentItem((currentItem()+count()-1)%count()); 176 setCurrentItem((currentItem()+count()-1)%count());
177 if(!itemVisible(currentItem())) { 177 if(!itemVisible(currentItem())) {
178 if((unsigned int) currentItem() == (count()-1)) { 178 if((unsigned int) currentItem() == (count()-1)) {
179 setTopItem(currentItem()-numItemsVisible()+1); 179 setTopItem(currentItem()-numItemsVisible()+1);
180 } else { 180 } else {
181 setTopItem(topItem()-1); 181 setTopItem(topItem()-1);
182 } 182 }
183 } 183 }
184 } 184 }
185 break; 185 break;
186 case Key_Down: 186 case Key_Down:
187 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 187 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
188 e->ignore(); 188 e->ignore();
189 break; 189 break;
190 } 190 }
191 if ( count () ) { 191 if ( count () ) {
192 setCurrentItem((currentItem()+1)%count()); 192 setCurrentItem((currentItem()+1)%count());
193 if(!itemVisible(currentItem())) { 193 if(!itemVisible(currentItem())) {
194 if(currentItem() == 0) { 194 if(currentItem() == 0) {
195 setTopItem(0); 195 setTopItem(0);
196 } else { 196 } else {
197 setTopItem(topItem()+1); 197 setTopItem(topItem()+1);
198 } 198 }
199 } 199 }
200 } 200 }
201 break; 201 break;
202 case Key_I: 202 case Key_I:
203 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 203 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
204 e->ignore(); 204 e->ignore();
205 break; 205 break;
206 case Key_Return: 206 case Key_Return:
207 case Key_Enter: 207 case Key_Enter:
208 { 208 {
209 if ( currentItem() >= 0 ) { 209 if ( currentItem() >= 0 ) {
210 emit doubleClicked( item( currentItem() ) ); 210 emit doubleClicked( item( currentItem() ) );
211 e->accept(); 211 e->accept();
212 } else { 212 } else {
213 e->ignore(); 213 e->ignore();
214 } 214 }
215 } 215 }
216 break; 216 break;
217 case Key_Shift: 217 case Key_Shift:
218 emit shiftDown(); 218 emit shiftDown();
219 break; 219 break;
220 default: 220 default:
221 e->ignore(); 221 e->ignore();
222 break; 222 break;
223 } 223 }
224} 224}
225 225
226void KNoScrollListBox::oneDown() 226void KNoScrollListBox::oneDown()
227{ 227{
228 if ( count () ) { 228 if ( count () ) {
229 resetOnFocusIn = false; 229 resetOnFocusIn = false;
230 setCurrentItem((currentItem()+1)%count()); 230 setCurrentItem((currentItem()+1)%count());
231 if(!itemVisible(currentItem())) { 231 if(!itemVisible(currentItem())) {
232 if(currentItem() == 0) { 232 if(currentItem() == 0) {
233 setTopItem(0); 233 setTopItem(0);
234 } else { 234 } else {
235 setTopItem(topItem()+1); 235 setTopItem(topItem()+1);
236 } 236 }
237 } 237 }
238 } 238 }
239} 239}
240void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 240void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
241{ 241{
242 switch(e->key()) { 242 switch(e->key()) {
243 case Key_Shift: 243 case Key_Shift:
244 emit shiftUp(); 244 emit shiftUp();
245 break; 245 break;
246 default: 246 default:
247 break; 247 break;
248 } 248 }
249} 249}
250 250
251void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 251void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
252{ 252{
253 QListBox::mousePressEvent(e); 253 QListBox::mousePressEvent(e);
254 254
255 if(e->button() == RightButton) { 255 if(e->button() == RightButton) {
256 emit rightClick(); 256 emit rightClick();
257 } 257 }
258} 258}
259 259
260MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 260MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
261 : QListBoxItem() 261 : QListBoxItem()
262{ 262{
263 mblockRepaint = true; 263 mblockRepaint = true;
264 setText( s ); 264 setText( s );
265 mMultiday = 0; 265 mMultiday = 0;
266 mIncidence = incidence; 266 mIncidence = incidence;
267 mDate = qd; 267 mDate = qd;
268 mRecur = false; 268 mRecur = false;
269 mAlarm = false; 269 mAlarm = false;
270 mReply = false; 270 mReply = false;
271 mInfo = false; 271 mInfo = false;
272 mdayPos = 0; 272 mdayPos = 0;
273 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 273 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
274 //qDebug("NEWWWWWWWWWWWWW "); 274 //qDebug("NEWWWWWWWWWWWWW ");
275} 275}
276void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 276void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
277{ 277{
278 setText( s ); 278 setText( s );
279 mMultiday = 0; 279 mMultiday = 0;
280 mIncidence = incidence; 280 mIncidence = incidence;
281 mDate = qd; 281 mDate = qd;
282 mRecur = false; 282 mRecur = false;
283 mAlarm = false; 283 mAlarm = false;
284 mReply = false; 284 mReply = false;
285 mInfo = false; 285 mInfo = false;
286 mdayPos = 0; 286 mdayPos = 0;
287 //qDebug("recucleeeeeeeeeeeeeeeee "); 287 //qDebug("recucleeeeeeeeeeeeeeeee ");
288} 288}
289 289
290void MonthViewItem::paint(QPainter *p) 290void MonthViewItem::paint(QPainter *p)
291{ 291{
292 if ( mblockRepaint ) { 292 if ( mblockRepaint ) {
293 //qDebug("block "); 293 //qDebug("block ");
294 return; 294 return;
295 } 295 }
296 //qDebug("NON block "); 296 //qDebug("NON block ");
297#if QT_VERSION >= 0x030000 297#if QT_VERSION >= 0x030000
298 bool sel = isSelected(); 298 bool sel = isSelected();
299#else 299#else
300 bool sel = selected(); 300 bool sel = selected();
301#endif 301#endif
302 302
303 303
304 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 304 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
305 { 305 {
306 p->setBackgroundColor( palette().color( QPalette::Normal, \ 306 p->setBackgroundColor( palette().color( QPalette::Normal, \
307 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 307 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
308 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 308 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
309 } 309 }
310 int x = 1; 310 int x = 1;
311 //int y = 3;//(height() - mRecurPixmap.height()) /2; 311 //int y = 3;//(height() - mRecurPixmap.height()) /2;
312 int size = PIXMAP_SIZE; 312 int size = PIXMAP_SIZE;
313 if ( QApplication::desktop()->width() < 300 ) 313 if ( QApplication::desktop()->width() < 300 )
314 size = 3; 314 size = 3;
315 int heihei = height( listBox () ); 315 int heihei = height( listBox () );
316 int y = (heihei - size -1 ) /2; 316 int y = (heihei - size -1 ) /2;
317 317
318 if ( KOPrefs::instance()->mMonthShowIcons ) { 318 if ( KOPrefs::instance()->mMonthShowIcons ) {
319 if ( mInfo ) { 319 if ( mInfo ) {
320 p->fillRect ( x, y,size,size, Qt::darkGreen ); 320 p->fillRect ( x, y,size,size, Qt::darkGreen );
321 x += size + 1; 321 x += size + 1;
322 } 322 }
323 if ( mRecur ) { 323 if ( mRecur ) {
324 p->fillRect ( x, y,size,size, Qt::blue ); 324 p->fillRect ( x, y,size,size, Qt::blue );
325 x += size + 1; 325 x += size + 1;
326 } 326 }
327 if ( mAlarm ) { 327 if ( mAlarm ) {
328 p->fillRect ( x, y,size,size, Qt::red ); 328 p->fillRect ( x, y,size,size, Qt::red );
329 x += size + 1; 329 x += size + 1;
330 } 330 }
331 if ( mReply ) { 331 if ( mReply ) {
332 p->fillRect ( x, y,size,size, Qt::yellow ); 332 p->fillRect ( x, y,size,size, Qt::yellow );
333 x += size + 1; 333 x += size + 1;
334 } 334 }
335 } 335 }
336 if ( mMultiday ) { 336 if ( mMultiday ) {
337 int yyy = y+(size/2); 337 int yyy = y+(size/2);
338 int sizeM = size+2; 338 int sizeM = size+2;
339 p->setBrush( QBrush::SolidPattern ); 339 p->setBrush( QBrush::SolidPattern );
340 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 340 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
341 if ( mMultiday == 2 || mMultiday == 3 ) { 341 if ( mMultiday == 2 || mMultiday == 3 ) {
342 QPointArray pa ( 3 ); 342 QPointArray pa ( 3 );
343 pa.setPoint (0, x, yyy ); 343 pa.setPoint (0, x, yyy );
344 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 344 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
345 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 345 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
346 p->drawPolygon( pa ); 346 p->drawPolygon( pa );
347 } 347 }
348 if ( mMultiday == 2 || mMultiday == 1 ) { 348 if ( mMultiday == 2 || mMultiday == 1 ) {
349 QPointArray pa ( 3 ); 349 QPointArray pa ( 3 );
350 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 350 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
351 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 351 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
352 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 352 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
353 p->drawPolygon( pa ); 353 p->drawPolygon( pa );
354 } 354 }
355 if ( mMultiday == 1 ) { 355 if ( mMultiday == 1 ) {
356 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 356 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
357 357
358 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 358 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
359 } 359 }
360 if ( mMultiday == 3 ) { 360 if ( mMultiday == 3 ) {
361 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 361 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
362 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 362 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
363 363
364 } 364 }
365 x += sizeM/2 + 1; 365 x += sizeM/2 + 1;
366 x += sizeM + 1; 366 x += sizeM + 1;
367 } 367 }
368 368
369 if ( mIncidence->type() == "Todo" ){ 369 if ( mIncidence->type() == "Todo" ){
370 Todo* td = ( Todo* ) mIncidence; 370 Todo* td = ( Todo* ) mIncidence;
371 if ( td->isCompleted() ) { 371 if ( td->isCompleted() ) {
372 int half = size/2; 372 int half = size/2;
373 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 373 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
374 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 374 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
375 x += half+half + 4; 375 x += half+half + 4;
376 376
377 } else { 377 } else {
378 int val = td->percentComplete()/20; 378 int val = td->percentComplete()/20;
379 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 379 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
380 p->drawRect ( x, y-2,7,size+4); 380 p->drawRect ( x, y-2,7,size+4);
381 x += size + 3; 381 x += size + 3;
382 } 382 }
383 } 383 }
384 QFontMetrics fm = p->fontMetrics(); 384 QFontMetrics fm = p->fontMetrics();
385 int yPos; 385 int yPos;
386 int pmheight = size; 386 int pmheight = size;
387 if( pmheight < fm.height() ) 387 if( pmheight < fm.height() )
388 yPos = fm.ascent() + fm.leading()/2; 388 yPos = fm.ascent() + fm.leading()/2;
389 else 389 else
390 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 390 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
391 p->setPen( palette().color( QPalette::Normal, sel ? \ 391 p->setPen( palette().color( QPalette::Normal, sel ? \
392 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 392 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
393 p->drawText( x, yPos, text() ); 393 p->drawText( x, yPos, text() );
394 if ( mIncidence->cancelled() ) { 394 if ( mIncidence->cancelled() ) {
395 int wid = fm.width( text() ); 395 int wid = fm.width( text() );
396 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 396 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
397 } 397 }
398 398
399} 399}
400 400
401int MonthViewItem::height(const QListBox *lb) const 401int MonthViewItem::height(const QListBox *lb) const
402{ 402{
403 int ret = 10; 403 int ret = 10;
404 if ( lb ) 404 if ( lb )
405 ret = lb->fontMetrics().lineSpacing()+1; 405 ret = lb->fontMetrics().lineSpacing()+1;
406 return ret; 406 return ret;
407} 407}
408 408
409int MonthViewItem::width(const QListBox *lb) const 409int MonthViewItem::width(const QListBox *lb) const
410{ 410{
411 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 411 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
412 int size = PIXMAP_SIZE; 412 int size = PIXMAP_SIZE;
413 if ( QApplication::desktop()->width() < 300 ) 413 if ( QApplication::desktop()->width() < 300 )
414 size = 3; 414 size = 3;
415 int x = 1; 415 int x = 1;
416 if ( KOPrefs::instance()->mMonthShowIcons ) { 416 if ( KOPrefs::instance()->mMonthShowIcons ) {
417 if ( mInfo ) { 417 if ( mInfo ) {
418 x += size + 1; 418 x += size + 1;
419 } 419 }
420 if( mRecur ) { 420 if( mRecur ) {
421 x += size+1; 421 x += size+1;
422 } 422 }
423 if( mAlarm ) { 423 if( mAlarm ) {
424 x += size+1; 424 x += size+1;
425 } 425 }
426 if( mReply ) { 426 if( mReply ) {
427 x += size+1; 427 x += size+1;
428 } 428 }
429 } 429 }
430 if( mMultiday ) { 430 if( mMultiday ) {
431 x += size+1+2+size/2; 431 x += size+1+2+size/2;
432 } 432 }
433 return( x + lb->fontMetrics().width( text() ) + 1 ); 433 return( x + lb->fontMetrics().width( text() ) + 1 );
434 } 434 }
435 if ( ! lb ) 435 if ( ! lb )
436 return 10; 436 return 10;
437 //qDebug("ret wid %d ", lb->width()); 437 //qDebug("ret wid %d ", lb->width());
438 return lb->width(); 438 return lb->width();
439} 439}
440 440
441 441
442MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 442MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
443 : KNoScrollListBox( par ), 443 : KNoScrollListBox( par ),
444 mMonthView( parent ) 444 mMonthView( parent )
445{ 445{
446 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 446 //QVBoxLayout *topLayout = new QVBoxLayout( this );
447 currentPalette = 0; 447 currentPalette = 0;
448 // mLabel = new QLabel( this );QPushButton 448 // mLabel = new QLabel( this );QPushButton
449 mLabel = new QPushButton( this ); 449 mLabel = new QPushButton( this );
450 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 450 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
451 //mLabel->setLineWidth( 1 ); 451 //mLabel->setLineWidth( 1 );
452 //mLabel->setAlignment( AlignCenter ); 452 //mLabel->setAlignment( AlignCenter );
453 mLabel->setFlat( true ); 453 mLabel->setFlat( true );
454 mLabel->setFocusPolicy(NoFocus); 454 mLabel->setFocusPolicy(NoFocus);
455 //mItemList = new KNoScrollListBox( this ); 455 //mItemList = new KNoScrollListBox( this );
456 setMinimumSize( 10, 10 ); 456 setMinimumSize( 10, 10 );
457 setFrameStyle( QFrame::Panel | QFrame::Plain ); 457 setFrameStyle( QFrame::Panel | QFrame::Plain );
458 setLineWidth( 1 ); 458 setLineWidth( 1 );
459 //topLayout->addWidget( mItemList ); 459 //topLayout->addWidget( mItemList );
460 mLabel->raise(); 460 mLabel->raise();
461 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 461 // QColor( 0,0,255 ) QColor( 160,1600,255 )
462 mStandardPalette = palette(); 462 mStandardPalette = palette();
463 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 463 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
464 464
465 enableScrollBars( false ); 465 enableScrollBars( false );
466 updateConfig(); 466 updateConfig();
467 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 467 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
468 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 468 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
469 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 469 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
470 SLOT( defaultAction( QListBoxItem * ) ) ); 470 SLOT( defaultAction( QListBoxItem * ) ) );
471 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 471 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
472 const QPoint &) ), 472 const QPoint &) ),
473 SLOT( contextMenu( QListBoxItem * ) ) ); 473 SLOT( contextMenu( QListBoxItem * ) ) );
474 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 474 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
475 SLOT( selection( QListBoxItem * ) ) ); 475 SLOT( selection( QListBoxItem * ) ) );
476 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 476 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
477 SLOT( cellClicked( QListBoxItem * ) ) ); 477 SLOT( cellClicked( QListBoxItem * ) ) );
478 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 478 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
479 SLOT( selection( QListBoxItem * ) ) ); 479 SLOT( selection( QListBoxItem * ) ) );
480} 480}
481#ifdef DESKTOP_VERSION 481#ifdef DESKTOP_VERSION
482QToolTipGroup *MonthViewCell::toolTipGroup() 482QToolTipGroup *MonthViewCell::toolTipGroup()
483{ 483{
484 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 484 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
485 return mToolTipGroup; 485 return mToolTipGroup;
486} 486}
487#endif 487#endif
488 488
489void MonthViewCell::setDate( const QDate &date ) 489void MonthViewCell::setDate( const QDate &date )
490{ 490{
491 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 491 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
492 mDate = date; 492 mDate = date;
493 493
494 494
495 495
496 //resizeEvent( 0 ); 496 //resizeEvent( 0 );
497} 497}
498 498
499QDate MonthViewCell::date() const 499QDate MonthViewCell::date() const
500{ 500{
501 return mDate; 501 return mDate;
502} 502}
503 503
504void MonthViewCell::setPrimary( bool primary ) 504void MonthViewCell::setPrimary( bool primary )
505{ 505{
506 mPrimary = primary; 506 mPrimary = primary;
507 //setMyPalette(); 507 //setMyPalette();
508} 508}
509void MonthViewCell::setMyPalette() 509void MonthViewCell::setMyPalette()
510{ 510{
511 511
512 if ( mHoliday) { 512 if ( mHoliday) {
513 if ( currentPalette == 1 ) return; 513 if ( currentPalette == 1 ) return;
514 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 514 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
515 setPalette( mHolidayPalette ); 515 setPalette( mHolidayPalette );
516 //mLabel->setPalette( mHolidayPalette ); 516 //mLabel->setPalette( mHolidayPalette );
517 currentPalette = 1; 517 currentPalette = 1;
518 518
519 } else { 519 } else {
520 if ( mPrimary ) { 520 if ( mPrimary ) {
521 if ( currentPalette == 2 ) return; 521 if ( currentPalette == 2 ) return;
522 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 522 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
523 //mLabel->setPalette( mPrimaryPalette ); 523 //mLabel->setPalette( mPrimaryPalette );
524 setPalette( mPrimaryPalette ); 524 setPalette( mPrimaryPalette );
525 currentPalette = 2; 525 currentPalette = 2;
526 526
527 } else { 527 } else {
528 if ( currentPalette == 3 ) return; 528 if ( currentPalette == 3 ) return;
529 setPalette( mNonPrimaryPalette ); 529 setPalette( mNonPrimaryPalette );
530 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 530 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
531 //mLabel->setPalette( mNonPrimaryPalette );; 531 //mLabel->setPalette( mNonPrimaryPalette );;
532 currentPalette = 3; 532 currentPalette = 3;
533 } 533 }
534 } 534 }
535 //QPalette pal = palette(); 535 //QPalette pal = palette();
536 536
537 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 537 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
538} 538}
539QPalette MonthViewCell::getPalette () 539QPalette MonthViewCell::getPalette ()
540{ 540{
541 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 541 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
542 return mStandardPalette; 542 return mStandardPalette;
543 if ( mHoliday) { 543 if ( mHoliday) {
544 return mHolidayPalette ; 544 return mHolidayPalette ;
545 } else { 545 } else {
546 if ( mPrimary ) { 546 if ( mPrimary ) {
547 return mPrimaryPalette ; 547 return mPrimaryPalette ;
548 } 548 }
549 } 549 }
550 return mNonPrimaryPalette; 550 return mNonPrimaryPalette;
551} 551}
552bool MonthViewCell::isPrimary() const 552bool MonthViewCell::isPrimary() const
553{ 553{
554 return mPrimary; 554 return mPrimary;
555} 555}
556 556
557void MonthViewCell::setHoliday( bool holiday ) 557void MonthViewCell::setHoliday( bool holiday )
558{ 558{
559 mHoliday = holiday; 559 mHoliday = holiday;
560 //setMyPalette(); 560 //setMyPalette();
561} 561}
562 562
563void MonthViewCell::setHoliday( const QString &holiday ) 563void MonthViewCell::setHoliday( const QString &holiday )
564{ 564{
565 mHolidayString = holiday; 565 mHolidayString = holiday;
566 566
567 if ( !holiday.isEmpty() ) { 567 if ( !holiday.isEmpty() ) {
568 setHoliday( true ); 568 setHoliday( true );
569 } 569 }
570} 570}
571 571
572void MonthViewCell::startUpdateCell() 572void MonthViewCell::startUpdateCell()
573{ 573{
574 mdayCount = 0; 574 mdayCount = 0;
575 setFocusPolicy(NoFocus); 575 setFocusPolicy(NoFocus);
576 if ( !mMonthView->isUpdatePossible() ) 576 if ( !mMonthView->isUpdatePossible() )
577 return; 577 return;
578 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 578 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
579 while ( mitem ) { 579 while ( mitem ) {
580 mitem->setBlockRepaint( true ); 580 mitem->setBlockRepaint( true );
581 mitem = (MonthViewItem *)mitem->next(); 581 mitem = (MonthViewItem *)mitem->next();
582 } 582 }
583 if ( mAvailItemList.count() > 20 ) { 583 if ( mAvailItemList.count() > 20 ) {
584 mAvailItemList.setAutoDelete( true ); 584 mAvailItemList.setAutoDelete( true );
585 mAvailItemList.clear(); 585 mAvailItemList.clear();
586 mAvailItemList.setAutoDelete( false ); 586 mAvailItemList.setAutoDelete( false );
587 } 587 }
588 /* 588 /*
589 if ( !isVisible() ){ 589 if ( !isVisible() ){
590 return; 590 return;
591 } 591 }
592 */ 592 */
593 // qDebug("MonthViewCell::updateCell() "); 593 // qDebug("MonthViewCell::updateCell() ");
594 setPrimary( mDate.month()%2 ); 594 setPrimary( mDate.month()%2 );
595 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 595 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
596 if ( mDate == QDate::currentDate() ) { 596 if ( mDate == QDate::currentDate() ) {
597 setLineWidth( 3 ); 597 setLineWidth( 3 );
598 } else { 598 } else {
599 setLineWidth( 1 ); 599 setLineWidth( 1 );
600 } 600 }
601 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 601 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
602 //clear(); 602 //clear();
603 while ( CurrentAvailItem ) { 603 while ( CurrentAvailItem ) {
604 MonthViewItem *item = CurrentAvailItem; 604 MonthViewItem *item = CurrentAvailItem;
605 CurrentAvailItem = (MonthViewItem *)item->next(); 605 CurrentAvailItem = (MonthViewItem *)item->next();
606 mAvailItemList.append( item ); 606 mAvailItemList.append( item );
607 takeItem ( item ); 607 takeItem ( item );
608 } 608 }
609 609
610#ifdef DESKTOP_VERSION 610#ifdef DESKTOP_VERSION
611 QToolTip::remove(this); 611 QToolTip::remove(this);
612#endif 612#endif
613 mToolTip.clear(); 613 mToolTip.clear();
614 //qApp->processEvents(); 614 //qApp->processEvents();
615#if 0 615#if 0
616 if ( !mHolidayString.isEmpty() ) { 616 if ( !mHolidayString.isEmpty() ) {
617 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 617 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
618 item->setPalette( mHolidayPalette ); 618 item->setPalette( mHolidayPalette );
619 insertItem( item ); 619 insertItem( item );
620 mToolTip.append ( mHolidayString ); 620 mToolTip.append ( mHolidayString );
621 } 621 }
622#endif 622#endif
623} 623}
624 624
625int MonthViewCell::insertEvent(Event *event) 625int MonthViewCell::insertEvent(Event *event)
626{ 626{
627 QString mToolTipText; 627 QString mToolTipText;
628 setFocusPolicy(WheelFocus); 628 setFocusPolicy(WheelFocus);
629 if ( !(event->doesRecur() == Recurrence::rNone) ) { 629 if ( !(event->doesRecur() == Recurrence::rNone) ) {
630 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 630 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
631 return mdayCount; 631 return mdayCount;
632 else 632 else
633 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 633 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
634 return mdayCount; 634 return mdayCount;
635 } 635 }
636 636
637 if ( event->isHoliday()) { 637 if ( event->isHoliday()) {
638 setHoliday( true ); 638 setHoliday( true );
639 if ( mDate.dayOfWeek() == 7 ) 639 if ( mDate.dayOfWeek() == 7 )
640 setLineWidth( 3 ); 640 setLineWidth( 3 );
641 } 641 }
642 QString text; 642 QString text;
643 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 643 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
644 if (event->isMultiDay()) { 644 if (event->isMultiDay()) {
645 QString prefix = "<->";multiday = 2; 645 QString prefix = "<->";multiday = 2;
646 QString time; 646 QString time;
647 if ( event->doesRecur() ) { 647 if ( event->doesRecur() ) {
648 if ( event->recursOn( mDate) ) { 648 if ( event->recursOn( mDate) ) {
649 prefix ="->" ;multiday = 1; 649 prefix ="->" ;multiday = 1;
650 } 650 }
651 else { 651 else {
652 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 652 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
653 if ( event->recursOn( mDate.addDays( -days)) ) { 653 if ( event->recursOn( mDate.addDays( -days)) ) {
654 prefix ="<-" ;multiday = 3; 654 prefix ="<-" ;multiday = 3;
655 } 655 }
656 } 656 }
657 657
658 } else { 658 } else {
659 if (mDate == event->dtStart().date()) { 659 if (mDate == event->dtStart().date()) {
660 prefix ="->" ;multiday = 1; 660 prefix ="->" ;multiday = 1;
661 } else if (mDate == event->dtEnd().date()) { 661 } else if (mDate == event->dtEnd().date()) {
662 prefix ="<-" ;multiday = 3; 662 prefix ="<-" ;multiday = 3;
663 } 663 }
664 } 664 }
665 if ( !event->doesFloat() ) { 665 if ( !event->doesFloat() ) {
666 if ( mDate == event->dtStart().date () ) 666 if ( mDate == event->dtStart().date () )
667 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 667 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
668 else if ( mDate == event->dtEnd().date () ) 668 else if ( mDate == event->dtEnd().date () )
669 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 669 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
670 670
671 } 671 }
672 text = time + event->summary(); 672 text = time + event->summary();
673 mToolTipText += prefix + text; 673 mToolTipText += prefix + text;
674 } else { 674 } else {
675 if (event->doesFloat()) { 675 if (event->doesFloat()) {
676 text = event->summary(); 676 text = event->summary();
677 mToolTipText += text; 677 mToolTipText += text;
678 } 678 }
679 else { 679 else {
680 text = KGlobal::locale()->formatTime(event->dtStart().time()); 680 text = KGlobal::locale()->formatTime(event->dtStart().time());
681 text += " " + event->summary(); 681 text += " " + event->summary();
682 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 682 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
683 } 683 }
684 } 684 }
685 MonthViewItem *item ; 685 MonthViewItem *item ;
686 686
687 if ( mAvailItemList.count() ) { 687 if ( mAvailItemList.count() ) {
688 item = mAvailItemList.first(); 688 item = mAvailItemList.first();
689 mAvailItemList.remove( item ); 689 mAvailItemList.remove( item );
690 item->recycle( event, mDate, text ); 690 item->recycle( event, mDate, text );
691 } else { 691 } else {
692 item = new MonthViewItem( event, mDate, text ); 692 item = new MonthViewItem( event, mDate, text );
693 } 693 }
694 694
695 QPalette pal; 695 QPalette pal;
696 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 696 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
697 QStringList categories = event->categories(); 697 QStringList categories = event->categories();
698 QString cat = categories.first(); 698 QString cat = categories.first();
699 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 699 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
700 pal = getPalette(); 700 pal = getPalette();
701 if (cat.isEmpty()) { 701 if (cat.isEmpty()) {
702 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 702 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
703 } else { 703 } else {
704 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 704 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
705 } 705 }
706 706
707 } else { 707 } else {
708 if (cat.isEmpty()) { 708 if (cat.isEmpty()) {
709 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 709 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
710 } else { 710 } else {
711 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 711 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
712 } 712 }
713 } 713 }
714 714
715 } else { 715 } else {
716 pal = mStandardPalette ; 716 pal = mStandardPalette ;
717 } 717 }
718 item->setPalette( pal ); 718 item->setPalette( pal );
719 item->setRecur( event->recurrence()->doesRecur() ); 719 item->setRecur( event->recurrence()->doesRecur() );
720 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 720 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
721 item->setMoreInfo( event->description().length() > 0 ); 721 item->setMoreInfo( event->description().length() > 0 );
722#ifdef DESKTOP_VERSION 722#ifdef DESKTOP_VERSION
723 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 723 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
724 KOPrefs::instance()->email()); 724 KOPrefs::instance()->email());
725 if ( me != 0 ) { 725 if ( me != 0 ) {
726 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 726 if ( me->status() == Attendee::NeedsAction && me->RSVP())
727 item->setReply(true && multiday < 2); 727 item->setReply(true && multiday < 2);
728 else 728 else
729 item->setReply(false); 729 item->setReply(false);
730 } else 730 } else
731 item->setReply(false); 731 item->setReply(false);
732#endif 732#endif
733 item->setMultiDay( multiday ); 733 item->setMultiDay( multiday );
734 if ( multiday ) { 734 if ( multiday ) {
735 insertItem( item ,mdayCount); 735 insertItem( item ,mdayCount);
736 ++mdayCount; 736 ++mdayCount;
737 } else { 737 } else {
738 uint i; 738 uint i;
739 int pos = mdayCount; 739 int pos = mdayCount;
740 for ( i = mdayCount; i < count();++i ) { 740 for ( i = mdayCount; i < count();++i ) {
741 QListBoxItem* it = this->item ( i ); 741 QListBoxItem* it = this->item ( i );
742 if ( text < it->text() ) { 742 if ( text < it->text() ) {
743 pos = i; 743 pos = i;
744 break; 744 break;
745 } 745 }
746 ++pos; 746 ++pos;
747 } 747 }
748 insertItem( item ,pos); 748 insertItem( item ,pos);
749 } 749 }
750 mToolTip.append( mToolTipText ); 750 mToolTip.append( mToolTipText );
751 return mdayCount; 751 return mdayCount;
752} 752}
753void MonthViewCell::insertTodo(Todo *todo) 753void MonthViewCell::insertTodo(Todo *todo)
754{ 754{
755 setFocusPolicy(WheelFocus); 755 setFocusPolicy(WheelFocus);
756 QString text; 756 QString text;
757 if (todo->hasDueDate()) { 757 if (todo->hasDueDate()) {
758 if (!todo->doesFloat()) { 758 if (!todo->doesFloat()) {
759 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 759 text += KGlobal::locale()->formatTime(todo->dtDue().time());
760 text += " "; 760 text += " ";
761 } 761 }
762 } 762 }
763 text += todo->summary(); 763 text += todo->summary();
764 MonthViewItem *item ; 764 MonthViewItem *item ;
765 if ( mAvailItemList.count() ) { 765 if ( mAvailItemList.count() ) {
766 item = mAvailItemList.first(); 766 item = mAvailItemList.first();
767 mAvailItemList.remove( item ); 767 mAvailItemList.remove( item );
768 item->recycle( todo, mDate, text ); 768 item->recycle( todo, mDate, text );
769 } else { 769 } else {
770 item = new MonthViewItem( todo, mDate, text ); 770 item = new MonthViewItem( todo, mDate, text );
771 } 771 }
772 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 772 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
773 //item->setPalette( mStandardPalette ); 773 //item->setPalette( mStandardPalette );
774 QPalette pal; 774 QPalette pal;
775 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 775 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
776 QStringList categories = todo->categories(); 776 QStringList categories = todo->categories();
777 QString cat = categories.first(); 777 QString cat = categories.first();
778 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 778 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
779 pal = getPalette(); 779 pal = getPalette();
780 if (cat.isEmpty()) { 780 if (cat.isEmpty()) {
781 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 781 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
782 } else { 782 } else {
783 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 783 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
784 } 784 }
785 785
786 } else { 786 } else {
787 if (cat.isEmpty()) { 787 if (cat.isEmpty()) {
788 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 788 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
789 } else { 789 } else {
790 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 790 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
791 } 791 }
792 } 792 }
793 793
794 } else { 794 } else {
795 pal = mStandardPalette ; 795 pal = mStandardPalette ;
796 } 796 }
797 item->setPalette( pal ); 797 item->setPalette( pal );
798 item->setRecur( todo->recurrence()->doesRecur() ); 798 item->setRecur( todo->recurrence()->doesRecur() );
799 item->setAlarm( todo->isAlarmEnabled() ); 799 item->setAlarm( todo->isAlarmEnabled() );
800 item->setMoreInfo( todo->description().length() > 0 ); 800 item->setMoreInfo( todo->description().length() > 0 );
801 insertItem( item , count()); 801 insertItem( item , count());
802 mToolTip.append( text ); 802 mToolTip.append( text );
803} 803}
804void MonthViewCell::repaintfinishUpdateCell() 804void MonthViewCell::repaintfinishUpdateCell()
805{ 805{
806 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 806 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
807 while ( mitem ) { 807 while ( mitem ) {
808 mitem->setBlockRepaint( false ); 808 mitem->setBlockRepaint( false );
809 updateItem ( mitem ); 809 updateItem ( mitem );
810 mitem = (MonthViewItem *)mitem->next(); 810 mitem = (MonthViewItem *)mitem->next();
811 } 811 }
812} 812}
813void MonthViewCell::finishUpdateCell() 813void MonthViewCell::finishUpdateCell()
814{ 814{
815 815
816 816
817 817
818#ifdef DESKTOP_VERSION 818#ifdef DESKTOP_VERSION
819 if (mToolTip.count() > 0 ) { 819 if (mToolTip.count() > 0 ) {
820 mToolTip.sort(); 820 mToolTip.sort();
821 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 821 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
822 } 822 }
823#endif 823#endif
824 //sort(); 824 //sort();
825 //setMyPalette(); 825 //setMyPalette();
826 setMyPalette(); 826 setMyPalette();
827 827
828 resizeEvent( 0 ); 828 resizeEvent( 0 );
829 829
830} 830}
831void MonthViewCell::updateCell() 831void MonthViewCell::updateCell()
832{ 832{
833 //qDebug("MonthViewCell::updateCell() "); 833 //qDebug("MonthViewCell::updateCell() ");
834 if ( !mMonthView->isUpdatePossible() ) 834 if ( !mMonthView->isUpdatePossible() )
835 return; 835 return;
836 startUpdateCell(); 836 startUpdateCell();
837 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 837 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
838 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 838 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
839 Event *event; 839 Event *event;
840 for( event = events.first(); event; event = events.next() ) { // for event 840 for( event = events.first(); event; event = events.next() ) { // for event
841 insertEvent(event); 841 insertEvent(event);
842 } 842 }
843 // insert due todos 843 // insert due todos
844 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 844 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
845 Todo *todo; 845 Todo *todo;
846 for(todo = todos.first(); todo; todo = todos.next()) { 846 for(todo = todos.first(); todo; todo = todos.next()) {
847 insertTodo( todo ); 847 insertTodo( todo );
848 } 848 }
849 finishUpdateCell(); 849 finishUpdateCell();
850 // if ( isVisible()) 850 // if ( isVisible())
851 //qApp->processEvents(); 851 //qApp->processEvents();
852} 852}
853 853
854void MonthViewCell::updateConfig( bool bigFont ) // = false 854void MonthViewCell::updateConfig( bool bigFont ) // = false
855{ 855{
856 856
857 if ( bigFont ) { 857 if ( bigFont ) {
858 QFont fo = KOPrefs::instance()->mMonthViewFont; 858 QFont fo = KOPrefs::instance()->mMonthViewFont;
859 int ps = fo.pointSize() + 2; 859 int ps = fo.pointSize() + 2;
860 if ( ps < 18 ) 860 if ( ps < 18 )
861 ps += 2; 861 ps += 2;
862 fo.setPointSize( ps ); 862 fo.setPointSize( ps );
863 setFont( fo ); 863 setFont( fo );
864 } else 864 } else
865 setFont( KOPrefs::instance()->mMonthViewFont ); 865 setFont( KOPrefs::instance()->mMonthViewFont );
866 866
867 QFontMetrics fm( font() ); 867 QFontMetrics fm( font() );
868 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 868 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
869 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 869 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
870 mHolidayPalette = mStandardPalette; 870 mHolidayPalette = mStandardPalette;
871 mPrimaryPalette = mStandardPalette; 871 mPrimaryPalette = mStandardPalette;
872 mNonPrimaryPalette = mStandardPalette; 872 mNonPrimaryPalette = mStandardPalette;
873 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 873 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
874 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 874 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
875 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 875 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
876 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 876 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
877 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 877 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
878 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 878 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
879 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 879 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
880 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 880 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
881 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 881 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
882 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 882 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
883 } 883 }
884 //updateCell(); 884 //updateCell();
885} 885}
886 886
887void MonthViewCell::enableScrollBars( bool enabled ) 887void MonthViewCell::enableScrollBars( bool enabled )
888{ 888{
889 889
890 return; 890 return;
891 if ( enabled ) { 891 if ( enabled ) {
892 QListBoxItem *fi = firstItem (); 892 QListBoxItem *fi = firstItem ();
893 if (fi ) { 893 if (fi ) {
894 int ihei = fi->height( this ); 894 int ihei = fi->height( this );
895 int hei = numRows () * ihei; 895 int hei = numRows () * ihei;
896 if ( hei < height() - horizontalScrollBar()->height () ) { 896 if ( hei < height() - horizontalScrollBar()->height () ) {
897 setVScrollBarMode(QScrollView::AlwaysOff); 897 setVScrollBarMode(QScrollView::AlwaysOff);
898 } 898 }
899 else 899 else
900 setVScrollBarMode(QScrollView::Auto); 900 setVScrollBarMode(QScrollView::Auto);
901 if ( ihei *3 > height() ) { 901 if ( ihei *3 > height() ) {
902 setHScrollBarMode(QScrollView::AlwaysOff); 902 setHScrollBarMode(QScrollView::AlwaysOff);
903 } 903 }
904 else { 904 else {
905 setHScrollBarMode(QScrollView::Auto); 905 setHScrollBarMode(QScrollView::Auto);
906 } 906 }
907 } else { 907 } else {
908 setVScrollBarMode(QScrollView::Auto); 908 setVScrollBarMode(QScrollView::Auto);
909 setHScrollBarMode(QScrollView::Auto); 909 setHScrollBarMode(QScrollView::Auto);
910 } 910 }
911 } else { 911 } else {
912 setVScrollBarMode(QScrollView::AlwaysOff); 912 setVScrollBarMode(QScrollView::AlwaysOff);
913 setHScrollBarMode(QScrollView::AlwaysOff); 913 setHScrollBarMode(QScrollView::AlwaysOff);
914 } 914 }
915} 915}
916 916
917Incidence *MonthViewCell::selectedIncidence() 917Incidence *MonthViewCell::selectedIncidence()
918{ 918{
919 int index = currentItem(); 919 int index = currentItem();
920 if ( index < 0 ) return 0; 920 if ( index < 0 ) return 0;
921 921
922 MonthViewItem *mitem = 922 MonthViewItem *mitem =
923 static_cast<MonthViewItem *>( item( index ) ); 923 static_cast<MonthViewItem *>( item( index ) );
924 924
925 if ( !mitem ) return 0; 925 if ( !mitem ) return 0;
926 926
927 return mitem->incidence(); 927 return mitem->incidence();
928} 928}
929 929
930QDate MonthViewCell::selectedIncidenceDate() 930QDate MonthViewCell::selectedIncidenceDate()
931{ 931{
932 QDate qd; 932 QDate qd;
933 int index = currentItem(); 933 int index = currentItem();
934 if ( index < 0 ) return qd; 934 if ( index < 0 ) return qd;
935 935
936 MonthViewItem *mitem = 936 MonthViewItem *mitem =
937 static_cast<MonthViewItem *>( item( index ) ); 937 static_cast<MonthViewItem *>( item( index ) );
938 938
939 if ( !mitem ) return qd; 939 if ( !mitem ) return qd;
940 940
941 return mitem->incidenceDate(); 941 return mitem->incidenceDate();
942} 942}
943 943
944void MonthViewCell::deselect() 944void MonthViewCell::deselect()
945{ 945{
946 clearSelection(); 946 clearSelection();
947 enableScrollBars( false ); 947 enableScrollBars( false );
948 // updateCell(); 948 // updateCell();
949} 949}
950void MonthViewCell::select() 950void MonthViewCell::select()
951{ 951{
952 ;// updateCell(); 952 ;// updateCell();
953} 953}
954 954
955void MonthViewCell::resizeEvent ( QResizeEvent * e ) 955void MonthViewCell::resizeEvent ( QResizeEvent * e )
956{ 956{
957 if ( !mMonthView->isUpdatePossible() ) 957 if ( !mMonthView->isUpdatePossible() )
958 return; 958 return;
959 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 959 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
960 deselect(); 960 deselect();
961 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 961 mLabel->setMaximumHeight( height() - lineWidth()*2 );
962 962
963 QString text; 963 QString text;
964 mLabel->setText( text ); 964 mLabel->setText( text );
965 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 965 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
966 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 966 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
967 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 967 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
968 mLabel->resize( mLabelBigSize ); 968 mLabel->resize( mLabelBigSize );
969 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 969 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
970 } else { 970 } else {
971 mLabel->resize( mLabelSize ); 971 mLabel->resize( mLabelSize );
972 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 972 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
973 } 973 }
974 mLabel->setText( text ); 974 mLabel->setText( text );
975 975
976 int size = height() - mLabel->height() - lineWidth()-1; 976 int size = height() - mLabel->height() - lineWidth()-1;
977 //qDebug("LW %d ", lineWidth()); 977 //qDebug("LW %d ", lineWidth());
978 if ( size > 0 ) 978 if ( size > 0 )
979 verticalScrollBar()->setMaximumHeight( size ); 979 verticalScrollBar()->setMaximumHeight( size );
980 size = width() - mLabel->width() -lineWidth()-1; 980 size = width() - mLabel->width() -lineWidth()-1;
981 if ( size > 0 ) 981 if ( size > 0 )
982 horizontalScrollBar()->setMaximumWidth( size ); 982 horizontalScrollBar()->setMaximumWidth( size );
983 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 983 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
984 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 984 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
985 // mItemList->resize ( width(), height () ); 985 // mItemList->resize ( width(), height () );
986 if ( e ) 986 if ( e )
987 KNoScrollListBox::resizeEvent ( e ); 987 KNoScrollListBox::resizeEvent ( e );
988} 988}
989 989
990void MonthViewCell::defaultAction( QListBoxItem *item ) 990void MonthViewCell::defaultAction( QListBoxItem *item )
991{ 991{
992 if ( !item ) { 992 if ( !item ) {
993 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 993 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
994 emit newEventSignal( dt ); 994 emit newEventSignal( dt );
995 return; 995 return;
996 } 996 }
997 997
998 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 998 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
999 Incidence *incidence = eventItem->incidence(); 999 Incidence *incidence = eventItem->incidence();
1000 if ( incidence ) mMonthView->defaultAction( incidence ); 1000 if ( incidence ) mMonthView->defaultAction( incidence );
1001} 1001}
1002void MonthViewCell::showDay() 1002void MonthViewCell::showDay()
1003{ 1003{
1004 emit showDaySignal( date() ); 1004 emit showDaySignal( date() );
1005} 1005}
1006void MonthViewCell::newEvent() 1006void MonthViewCell::newEvent()
1007{ 1007{
1008 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1008 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1009 emit newEventSignal( dt ); 1009 emit newEventSignal( dt );
1010} 1010}
1011void MonthViewCell::cellClicked( QListBoxItem *item ) 1011void MonthViewCell::cellClicked( QListBoxItem *item )
1012{ 1012{
1013 if ( item == 0 ) { 1013 if ( item == 0 ) {
1014 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1014 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1015 emit newEventSignal( dt ); 1015 emit newEventSignal( dt );
1016 return; 1016 return;
1017 } 1017 }
1018 /* 1018 /*
1019 if ( lastClicked ) 1019 if ( lastClicked )
1020 if ( ! item ) { 1020 if ( ! item ) {
1021 if ( lastClicked->listBox() != item->listBox() ) 1021 if ( lastClicked->listBox() != item->listBox() )
1022 lastClicked->listBox()->clearSelection(); 1022 lastClicked->listBox()->clearSelection();
1023 } 1023 }
1024 */ 1024 */
1025 1025
1026 mMonthView->setSelectedCell( this ); 1026 mMonthView->setSelectedCell( this );
1027 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 1027 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
1028 select(); 1028 select();
1029} 1029}
1030 1030
1031void MonthViewCell::contextMenu( QListBoxItem *item ) 1031void MonthViewCell::contextMenu( QListBoxItem *item )
1032{ 1032{
1033 if ( !item ) return; 1033 if ( !item ) return;
1034 1034
1035 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1035 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1036 Incidence *incidence = eventItem->incidence(); 1036 Incidence *incidence = eventItem->incidence();
1037 if ( incidence ) mMonthView->showContextMenu( incidence ); 1037 if ( incidence ) mMonthView->showContextMenu( incidence );
1038} 1038}
1039 1039
1040void MonthViewCell::selection( QListBoxItem *item ) 1040void MonthViewCell::selection( QListBoxItem *item )
1041{ 1041{
1042 if ( !item ) return; 1042 if ( !item ) return;
1043 1043
1044 mMonthView->setSelectedCell( this ); 1044 mMonthView->setSelectedCell( this );
1045} 1045}
1046 1046
1047 1047
1048// ******************************************************************************* 1048// *******************************************************************************
1049// ******************************************************************************* 1049// *******************************************************************************
1050// ******************************************************************************* 1050// *******************************************************************************
1051 1051
1052 1052
1053KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1053KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1054 : KOEventView( calendar, parent, name ), 1054 : KOEventView( calendar, parent, name ),
1055 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1055 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1056 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1056 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1057{ 1057{
1058 mFlagKeyPressed = false; 1058 mFlagKeyPressed = false;
1059 mShortDayLabelsM = false; 1059 mShortDayLabelsM = false;
1060 mShortDayLabelsW = false; 1060 mShortDayLabelsW = false;
1061 skipResize = false; 1061 skipResize = false;
1062 clPending = true; 1062 clPending = true;
1063 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1063 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1064 mWidStack = new QWidgetStack( this ); 1064 mWidStack = new QWidgetStack( this );
1065 QVBoxLayout* hb = new QVBoxLayout( this ); 1065 QVBoxLayout* hb = new QVBoxLayout( this );
1066 mMonthView = new QWidget( mWidStack ); 1066 mMonthView = new QWidget( mWidStack );
1067 mWeekView = new QWidget( mWidStack ); 1067 mWeekView = new QWidget( mWidStack );
1068#if QT_VERSION >= 0x030000 1068#if QT_VERSION >= 0x030000
1069 mWidStack->addWidget(mMonthView ); 1069 mWidStack->addWidget(mMonthView );
1070 mWidStack->addWidget(mWeekView ); 1070 mWidStack->addWidget(mWeekView );
1071#else 1071#else
1072 mWidStack->addWidget( mMonthView, 1 ); 1072 mWidStack->addWidget( mMonthView, 1 );
1073 mWidStack->addWidget( mWeekView , 1 ); 1073 mWidStack->addWidget( mWeekView , 1 );
1074#endif 1074#endif
1075 hb->addWidget( mNavigatorBar ); 1075 hb->addWidget( mNavigatorBar );
1076 hb->addWidget( mWidStack ); 1076 hb->addWidget( mWidStack );
1077 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1077 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1078 updatePossible = false; 1078 updatePossible = false;
1079 //updatePossible = true; 1079 //updatePossible = true;
1080 mCells.setAutoDelete( true ); 1080 mCells.setAutoDelete( true );
1081 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1081 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1082 mDayLabels.resize( mDaysPerWeek ); 1082 mDayLabels.resize( mDaysPerWeek );
1083 mDayLabelsW.resize( mDaysPerWeek ); 1083 mDayLabelsW.resize( mDaysPerWeek );
1084 QFont bfont = font(); 1084 QFont bfont = font();
1085 if ( QApplication::desktop()->width() < 650 ) { 1085 if ( QApplication::desktop()->width() < 650 ) {
1086 bfont.setPointSize( bfont.pointSize() - 2 ); 1086 bfont.setPointSize( bfont.pointSize() - 2 );
1087 } 1087 }
1088 bfont.setBold( true ); 1088 bfont.setBold( true );
1089 int i; 1089 int i;
1090 1090
1091 for( i = 0; i < mDaysPerWeek; i++ ) { 1091 for( i = 0; i < mDaysPerWeek; i++ ) {
1092 QLabel *label = new QLabel( mMonthView ); 1092 QLabel *label = new QLabel( mMonthView );
1093 label->setFont(bfont); 1093 label->setFont(bfont);
1094 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1094 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1095 label->setLineWidth(1); 1095 label->setLineWidth(1);
1096 label->setAlignment(AlignCenter); 1096 label->setAlignment(AlignCenter);
1097 mDayLabels.insert( i, label ); 1097 mDayLabels.insert( i, label );
1098 label = new QLabel( mWeekView ); 1098 label = new QLabel( mWeekView );
1099 label->setFont(bfont); 1099 label->setFont(bfont);
1100 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1100 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1101 label->setLineWidth(1); 1101 label->setLineWidth(1);
1102 label->setAlignment(AlignCenter); 1102 label->setAlignment(AlignCenter);
1103 mDayLabelsW.insert( i, label ); 1103 mDayLabelsW.insert( i, label );
1104 } 1104 }
1105 1105
1106 bfont.setBold( false ); 1106 bfont.setBold( false );
1107 mWeekLabels.resize( mNumWeeks+1 ); 1107 mWeekLabels.resize( mNumWeeks+1 );
1108 mWeekLabelsW.resize( 2 ); 1108 mWeekLabelsW.resize( 2 );
1109 for( i = 0; i < mNumWeeks+1; i++ ) { 1109 for( i = 0; i < mNumWeeks+1; i++ ) {
1110 KOWeekButton *label = new KOWeekButton( mMonthView ); 1110 KOWeekButton *label = new KOWeekButton( mMonthView );
1111 label->setFocusPolicy(NoFocus); 1111 label->setFocusPolicy(NoFocus);
1112 label->setFont(bfont); 1112 label->setFont(bfont);
1113 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1113 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1114 label->setFlat(true); 1114 label->setFlat(true);
1115 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1115 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1116 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1116 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1117 //label->setLineWidth(1); 1117 //label->setLineWidth(1);
1118 //label->setAlignment(AlignCenter); 1118 //label->setAlignment(AlignCenter);
1119 mWeekLabels.insert( i, label ); 1119 mWeekLabels.insert( i, label );
1120 } 1120 }
1121 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1121 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1122 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1122 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1123 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1123 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1124 1124
1125 for( i = 0; i < 1+1; i++ ) { 1125 for( i = 0; i < 1+1; i++ ) {
1126 KOWeekButton *label = new KOWeekButton( mWeekView ); 1126 KOWeekButton *label = new KOWeekButton( mWeekView );
1127 label->setFocusPolicy(NoFocus); 1127 label->setFocusPolicy(NoFocus);
1128 label->setFont(bfont); 1128 label->setFont(bfont);
1129 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1129 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1130 label->setFlat(true); 1130 label->setFlat(true);
1131 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1131 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1132 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1132 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1133 //label->setLineWidth(1); 1133 //label->setLineWidth(1);
1134 //label->setAlignment(AlignCenter); 1134 //label->setAlignment(AlignCenter);
1135 mWeekLabelsW.insert( i, label ); 1135 mWeekLabelsW.insert( i, label );
1136 } 1136 }
1137 mWeekLabelsW[1]->setText( i18n("W")); 1137 mWeekLabelsW[1]->setText( i18n("W"));
1138 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1138 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1139 1139
1140 1140
1141 int row, col; 1141 int row, col;
1142 mCells.resize( mNumCells ); 1142 mCells.resize( mNumCells );
1143 for( row = 0; row < mNumWeeks; ++row ) { 1143 for( row = 0; row < mNumWeeks; ++row ) {
1144 for( col = 0; col < mDaysPerWeek; ++col ) { 1144 for( col = 0; col < mDaysPerWeek; ++col ) {
1145 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1145 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1146 mCells.insert( row * mDaysPerWeek + col, cell ); 1146 mCells.insert( row * mDaysPerWeek + col, cell );
1147 1147
1148 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1148 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1149 SLOT( defaultAction( Incidence * ) ) ); 1149 SLOT( defaultAction( Incidence * ) ) );
1150 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1150 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1151 SIGNAL( newEventSignal( QDateTime ) ) ); 1151 SIGNAL( newEventSignal( QDateTime ) ) );
1152 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1152 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1153 SIGNAL( showDaySignal( QDate ) ) ); 1153 SIGNAL( showDaySignal( QDate ) ) );
1154 } 1154 }
1155 } 1155 }
1156 mCellsW.resize( mDaysPerWeek ); 1156 mCellsW.resize( mDaysPerWeek );
1157 for( col = 0; col < mDaysPerWeek; ++col ) { 1157 for( col = 0; col < mDaysPerWeek; ++col ) {
1158 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1158 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1159 mCellsW.insert( col, cell ); 1159 mCellsW.insert( col, cell );
1160 1160
1161 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1161 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1162 SLOT( defaultAction( Incidence * ) ) ); 1162 SLOT( defaultAction( Incidence * ) ) );
1163 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1163 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1164 SIGNAL( newEventSignal( QDateTime ) ) ); 1164 SIGNAL( newEventSignal( QDateTime ) ) );
1165 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1165 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1166 SIGNAL( showDaySignal( QDate ) ) ); 1166 SIGNAL( showDaySignal( QDate ) ) );
1167 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1167 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1168 } 1168 }
1169 1169
1170 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1170 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1171 mContextMenu = eventPopup(); 1171 mContextMenu = eventPopup();
1172 // updateConfig(); //useless here... 1172 // updateConfig(); //useless here...
1173 // ... but we need mWidthLongDayLabel computed 1173 // ... but we need mWidthLongDayLabel computed
1174 QFontMetrics fontmetric(mDayLabels[0]->font()); 1174 QFontMetrics fontmetric(mDayLabels[0]->font());
1175 mWidthLongDayLabel = 0; 1175 mWidthLongDayLabel = 0;
1176 for (int i = 0; i < 7; i++) { 1176 for (int i = 0; i < 7; i++) {
1177 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1177 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1178 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1178 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1179 } 1179 }
1180 1180
1181 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1181 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1182 1182
1183#if 0 1183#if 0
1184 if ( mShowWeekView ) 1184 if ( mShowWeekView )
1185 mWidStack->raiseWidget( mWeekView ); 1185 mWidStack->raiseWidget( mWeekView );
1186 else 1186 else
1187 mWidStack->raiseWidget( mMonthView ); 1187 mWidStack->raiseWidget( mMonthView );
1188#endif 1188#endif
1189 1189
1190 emit incidenceSelected( 0 ); 1190 emit incidenceSelected( 0 );
1191 1191
1192 mComputeLayoutTimer = new QTimer( this ); 1192 mComputeLayoutTimer = new QTimer( this );
1193 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1193 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1194 1194
1195 1195
1196#ifndef DESKTOP_VERSION 1196#ifndef DESKTOP_VERSION
1197 resize( QApplication::desktop()->size() ); 1197 resize( QApplication::desktop()->size() );
1198#else 1198#else
1199 resize(640, 480 ); 1199 resize(640, 480 );
1200 updatePossible = true; 1200 updatePossible = true;
1201#endif 1201#endif
1202 computeLayout(); 1202 computeLayout();
1203 1203
1204 if ( mShowWeekView ) 1204 if ( mShowWeekView )
1205 mWidStack->raiseWidget( mWeekView ); 1205 mWidStack->raiseWidget( mWeekView );
1206 else 1206 else
1207 mWidStack->raiseWidget( mMonthView ); 1207 mWidStack->raiseWidget( mMonthView );
1208} 1208}
1209 1209
1210KOMonthView::~KOMonthView() 1210KOMonthView::~KOMonthView()
1211{ 1211{
1212 delete mContextMenu; 1212 delete mContextMenu;
1213} 1213}
1214 1214
1215void KOMonthView::selectInternalWeekNum ( int n ) 1215void KOMonthView::selectInternalWeekNum ( int n )
1216{ 1216{
1217 switchView(); 1217 switchView();
1218 if ( !KOPrefs::instance()->mMonthViewWeek ) 1218 if ( !KOPrefs::instance()->mMonthViewWeek )
1219 emit selectMonth (); 1219 emit selectMonth ();
1220 else 1220 else
1221 emit selectWeekNum ( n ); 1221 emit selectWeekNum ( n );
1222} 1222}
1223 1223
1224int KOMonthView::currentWeek() 1224int KOMonthView::currentWeek()
1225{ 1225{
1226 if ( mShowWeekView ) 1226 if ( mShowWeekView )
1227 return mWeekLabelsW[0]->getWeekNum(); 1227 return mWeekLabelsW[0]->getWeekNum();
1228 return mWeekLabels[0]->getWeekNum(); 1228 return mWeekLabels[0]->getWeekNum();
1229} 1229}
1230void KOMonthView::switchView() 1230void KOMonthView::switchView()
1231{ 1231{
1232 if ( selectedCell( ) ) 1232 if ( selectedCell( ) )
1233 selectedCell()->deselect(); 1233 selectedCell()->deselect();
1234 mShowWeekView = !mShowWeekView; 1234 mShowWeekView = !mShowWeekView;
1235 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1235 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1236 if ( clPending ) { 1236 if ( clPending ) {
1237 computeLayout(); 1237 computeLayout();
1238 updateConfig(); 1238 updateConfig();
1239 } 1239 }
1240 if ( mShowWeekView ) 1240 if ( mShowWeekView )
1241 mWidStack->raiseWidget( mWeekView ); 1241 mWidStack->raiseWidget( mWeekView );
1242 else 1242 else
1243 mWidStack->raiseWidget( mMonthView ); 1243 mWidStack->raiseWidget( mMonthView );
1244 clPending = false; 1244 clPending = false;
1245} 1245}
1246 1246
1247int KOMonthView::maxDatesHint() 1247int KOMonthView::maxDatesHint()
1248{ 1248{
1249 return mNumCells; 1249 return mNumCells;
1250} 1250}
1251 1251
1252int KOMonthView::currentDateCount() 1252int KOMonthView::currentDateCount()
1253{ 1253{
1254 return mNumCells; 1254 return mNumCells;
1255} 1255}
1256 1256
1257QPtrList<Incidence> KOMonthView::selectedIncidences() 1257QPtrList<Incidence> KOMonthView::selectedIncidences()
1258{ 1258{
1259 QPtrList<Incidence> selected; 1259 QPtrList<Incidence> selected;
1260 1260
1261 if ( mSelectedCell ) { 1261 if ( mSelectedCell ) {
1262 Incidence *incidence = mSelectedCell->selectedIncidence(); 1262 Incidence *incidence = mSelectedCell->selectedIncidence();
1263 if ( incidence ) selected.append( incidence ); 1263 if ( incidence ) selected.append( incidence );
1264 } 1264 }
1265 1265
1266 return selected; 1266 return selected;
1267} 1267}
1268 1268
1269DateList KOMonthView::selectedDates() 1269DateList KOMonthView::selectedDates()
1270{ 1270{
1271 DateList selected; 1271 DateList selected;
1272 1272
1273 if ( mSelectedCell ) { 1273 if ( mSelectedCell ) {
1274 QDate qd = mSelectedCell->selectedIncidenceDate(); 1274 QDate qd = mSelectedCell->selectedIncidenceDate();
1275 if ( qd.isValid() ) selected.append( qd ); 1275 if ( qd.isValid() ) selected.append( qd );
1276 } 1276 }
1277 1277
1278 return selected; 1278 return selected;
1279} 1279}
1280 1280
1281void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1281void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1282 const QDate &td) 1282 const QDate &td)
1283{ 1283{
1284#ifndef KORG_NOPRINTER 1284#ifndef KORG_NOPRINTER
1285 calPrinter->preview(CalPrinter::Month, fd, td); 1285 calPrinter->preview(CalPrinter::Month, fd, td);
1286#endif 1286#endif
1287} 1287}
1288 1288
1289void KOMonthView::updateConfig() 1289void KOMonthView::updateConfig()
1290{ 1290{
1291 1291
1292 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1292 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1293 1293
1294 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1294 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1295 mWeekStartsMonday = true; 1295 mWeekStartsMonday = true;
1296 } 1296 }
1297 QFontMetrics fontmetric(mDayLabels[0]->font()); 1297 QFontMetrics fontmetric(mDayLabels[0]->font());
1298 mWidthLongDayLabel = 0; 1298 mWidthLongDayLabel = 0;
1299 1299
1300 for (int i = 0; i < 7; i++) { 1300 for (int i = 0; i < 7; i++) {
1301 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1301 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1302 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1302 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1303 } 1303 }
1304 bool temp = mShowSatSunComp ; 1304 bool temp = mShowSatSunComp ;
1305 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1305 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1306 if ( ! mShowWeekView ) { 1306 if ( ! mShowWeekView ) {
1307 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1307 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1308 computeLayout(); 1308 computeLayout();
1309 } 1309 }
1310 updateDayLabels(); 1310 updateDayLabels();
1311 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1311 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1312 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1312 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1313 //resizeEvent( 0 ); 1313 //resizeEvent( 0 );
1314 for (uint i = 0; i < mCells.count(); ++i) { 1314 for (uint i = 0; i < mCells.count(); ++i) {
1315 mCells[i]->updateConfig(); 1315 mCells[i]->updateConfig();
1316 } 1316 }
1317 1317
1318 for (uint i = 0; i < mCellsW.count(); ++i) { 1318 for (uint i = 0; i < mCellsW.count(); ++i) {
1319 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1319 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1320 } 1320 }
1321#ifdef DESKTOP_VERSION 1321#ifdef DESKTOP_VERSION
1322 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1322 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1323#endif 1323#endif
1324 updateView(); 1324 updateView();
1325} 1325}
1326 1326
1327void KOMonthView::updateDayLabels() 1327void KOMonthView::updateDayLabels()
1328{ 1328{
1329 1329
1330 QPtrVector<QLabel> *mDayLabelsT; 1330 QPtrVector<QLabel> *mDayLabelsT;
1331 1331
1332 mDayLabelsT = &mDayLabelsW; 1332 mDayLabelsT = &mDayLabelsW;
1333 for (int i = 0; i < 7; i++) { 1333 for (int i = 0; i < 7; i++) {
1334 { 1334 {
1335 bool show = mShortDayLabelsW; 1335 bool show = mShortDayLabelsW;
1336 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1336 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1337 show = true; 1337 show = true;
1338 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1338 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1339 } 1339 }
1340 } 1340 }
1341 mDayLabelsT = &mDayLabels; 1341 mDayLabelsT = &mDayLabels;
1342 for (int i = 0; i < 7; i++) { 1342 for (int i = 0; i < 7; i++) {
1343 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1343 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1344 bool show = mShortDayLabelsM; 1344 bool show = mShortDayLabelsM;
1345 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1345 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1346 show = true; 1346 show = true;
1347 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1347 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1348 } else { 1348 } else {
1349 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1349 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1350 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1350 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1351 1351
1352 } 1352 }
1353 } 1353 }
1354 1354
1355} 1355}
1356 1356
1357void KOMonthView::showDates(const QDate &start, const QDate &) 1357void KOMonthView::showDates(const QDate &start, const QDate &)
1358{ 1358{
1359 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1359 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1360 1360
1361 QPtrVector<MonthViewCell> *cells; 1361 QPtrVector<MonthViewCell> *cells;
1362 QPtrVector<QLabel> *dayLabels; 1362 QPtrVector<QLabel> *dayLabels;
1363 QPtrVector<KOWeekButton> *weekLabels; 1363 QPtrVector<KOWeekButton> *weekLabels;
1364 int weekNum = 6; 1364 int weekNum = 6;
1365 mStartDate = start; 1365 mStartDate = start;
1366 if ( mShowWeekView ) { 1366 if ( mShowWeekView ) {
1367 weekNum = 1; 1367 weekNum = 1;
1368 cells = &mCellsW; 1368 cells = &mCellsW;
1369 dayLabels = &mDayLabelsW; 1369 dayLabels = &mDayLabelsW;
1370 weekLabels = &mWeekLabelsW; 1370 weekLabels = &mWeekLabelsW;
1371 if ( !KGlobal::locale()->weekStartsMonday() ) { 1371 if ( !KGlobal::locale()->weekStartsMonday() ) {
1372 mStartDate = mStartDate.addDays( 1 ); 1372 mStartDate = mStartDate.addDays( 1 );
1373 } 1373 }
1374 } else { 1374 } else {
1375 cells = &mCells; 1375 cells = &mCells;
1376 dayLabels = &mDayLabels; 1376 dayLabels = &mDayLabels;
1377 weekLabels = &mWeekLabels; 1377 weekLabels = &mWeekLabels;
1378 } 1378 }
1379 1379
1380 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1380 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1381 1381
1382 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1382 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1383 mWeekStartsMonday = true; 1383 mWeekStartsMonday = true;
1384 } 1384 }
1385 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1385 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1386 1386
1387 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1387 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1388 mStartDate = mStartDate.addDays( -1 ); 1388 mStartDate = mStartDate.addDays( -1 );
1389 } 1389 }
1390 bool primary = false; 1390 bool primary = false;
1391 uint i; 1391 uint i;
1392 for( i = 0; i < (*cells).size(); ++i ) { 1392 for( i = 0; i < (*cells).size(); ++i ) {
1393 QDate date = mStartDate.addDays( i ); 1393 QDate date = mStartDate.addDays( i );
1394 (*cells)[i]->setDate( date ); 1394 (*cells)[i]->setDate( date );
1395 1395
1396#ifndef KORG_NOPLUGINS 1396#ifndef KORG_NOPLUGINS
1397 // add holiday, if present 1397 // add holiday, if present
1398 QString hstring(KOCore::self()->holiday(date)); 1398 QString hstring(KOCore::self()->holiday(date));
1399 (*cells)[i]->setHoliday( hstring ); 1399 (*cells)[i]->setHoliday( hstring );
1400#endif 1400#endif
1401 1401
1402 } 1402 }
1403 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1403 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1404 for( i = 0; i < weekNum; ++i ) { 1404 for( i = 0; i < weekNum; ++i ) {
1405 int wno; 1405 int wno;
1406 // remember, according to ISO 8601, the first week of the year is the 1406 // remember, according to ISO 8601, the first week of the year is the
1407 // first week that contains a thursday. Thus we must subtract off 4, 1407 // first week that contains a thursday. Thus we must subtract off 4,
1408 // not just 1. 1408 // not just 1.
1409 int dayOfYear = date.dayOfYear(); 1409 int dayOfYear = date.dayOfYear();
1410 if (dayOfYear % 7 != 0) 1410 if (dayOfYear % 7 != 0)
1411 wno = dayOfYear / 7 + 1; 1411 wno = dayOfYear / 7 + 1;
1412 else 1412 else
1413 wno =dayOfYear / 7; 1413 wno =dayOfYear / 7;
1414 (*weekLabels)[i]->setWeekNum( wno ); 1414 (*weekLabels)[i]->setWeekNum( wno );
1415 date = date.addDays( 7 ); 1415 date = date.addDays( 7 );
1416 } 1416 }
1417 updateView(); 1417 updateView();
1418} 1418}
1419 1419
1420void KOMonthView::showEvents(QPtrList<Event>) 1420void KOMonthView::showEvents(QPtrList<Event>)
1421{ 1421{
1422 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1422 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1423} 1423}
1424 1424
1425void KOMonthView::changeEventDisplay(Event *, int) 1425void KOMonthView::changeEventDisplay(Event *, int)
1426{ 1426{
1427 // this should be re-written to be much more efficient, but this 1427 // this should be re-written to be much more efficient, but this
1428 // quick-and-dirty-hack gets the job done for right now. 1428 // quick-and-dirty-hack gets the job done for right now.
1429 //qDebug("KOMonthView::changeEventDisplay "); 1429 //qDebug("KOMonthView::changeEventDisplay ");
1430 updateView(); 1430 updateView();
1431} 1431}
1432 1432
1433void KOMonthView::updateView() 1433void KOMonthView::updateView()
1434{ 1434{
1435 1435
1436 if ( !updatePossible ) 1436 if ( !updatePossible )
1437 return; 1437 return;
1438 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1438 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1439 //QTime ti; 1439 //QTime ti;
1440 //ti.start(); 1440 //ti.start();
1441 clearSelection(); 1441 clearSelection();
1442 QPtrVector<MonthViewCell> *cells; 1442 QPtrVector<MonthViewCell> *cells;
1443 if ( mShowWeekView ) { 1443 if ( mShowWeekView ) {
1444 cells = &mCellsW; 1444 cells = &mCellsW;
1445 } else { 1445 } else {
1446 cells = &mCells; 1446 cells = &mCells;
1447 } 1447 }
1448#if 1 1448#if 1
1449 int i; 1449 int i;
1450 int timeSpan = (*cells).size()-1; 1450 int timeSpan = (*cells).size()-1;
1451 if ( KOPrefs::instance()->mMonthViewWeek ) 1451 if ( KOPrefs::instance()->mMonthViewWeek )
1452 timeSpan = 6; 1452 timeSpan = 6;
1453 for( i = 0; i < timeSpan + 1; ++i ) { 1453 for( i = 0; i < timeSpan + 1; ++i ) {
1454 (*cells)[i]->startUpdateCell(); 1454 (*cells)[i]->startUpdateCell();
1455 } 1455 }
1456 1456
1457 QPtrList<Event> events = calendar()->events(); 1457 QPtrList<Event> events = calendar()->events();
1458 Event *event; 1458 Event *event;
1459 QDateTime dt; 1459 QDateTime dt;
1460 bool ok; 1460 bool ok;
1461 QDate endDate = mStartDate.addDays( timeSpan ); 1461 QDate endDate = mStartDate.addDays( timeSpan );
1462 for( event = events.first(); event; event = events.next() ) { // for event 1462 for( event = events.first(); event; event = events.next() ) { // for event
1463 if ( event->doesRecur() ) { 1463 if ( event->doesRecur() ) {
1464 bool last; 1464 bool last;
1465 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1465 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1466 QDateTime incidenceEnd; 1466 QDateTime incidenceEnd;
1467 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1467 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1468 bool invalid = false; 1468 bool invalid = false;
1469 while( true ) { 1469 while( true ) {
1470 if ( incidenceStart.isValid() ) { 1470 if ( incidenceStart.isValid() ) {
1471 incidenceEnd = incidenceStart.addDays( eventlen ); 1471 incidenceEnd = incidenceStart.addDays( eventlen );
1472 int st = incidenceStart.date().daysTo( endDate ); 1472 int st = incidenceStart.date().daysTo( endDate );
1473 if ( st >= 0 ) { // start before timeend 1473 if ( st >= 0 ) { // start before timeend
1474 int end = mStartDate.daysTo( incidenceEnd.date() ); 1474 int end = mStartDate.daysTo( incidenceEnd.date() );
1475 if ( end >= 0 ) { // end after timestart --- got one! 1475 if ( end >= 0 ) { // end after timestart --- got one!
1476 //normalize 1476 //normalize
1477 st = timeSpan - st; 1477 st = timeSpan - st;
1478 if ( st < 0 ) st = 0; 1478 if ( st < 0 ) st = 0;
1479 if ( end > timeSpan ) end = timeSpan; 1479 if ( end > timeSpan ) end = timeSpan;
1480 int iii; 1480 int iii;
1481 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1481 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1482 for ( iii = st;iii<= end;++iii) 1482 for ( iii = st;iii<= end;++iii)
1483 (*cells)[iii]->insertEvent( event ); 1483 (*cells)[iii]->insertEvent( event );
1484 } 1484 }
1485 } 1485 }
1486 } else { 1486 } else {
1487 if ( invalid ) 1487 if ( invalid )
1488 break; 1488 break;
1489 invalid = true; 1489 invalid = true;
1490 //qDebug("invalid %s", event->summary().latin1()); 1490 //qDebug("invalid %s", event->summary().latin1());
1491 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1491 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1492 } 1492 }
1493 if ( last ) 1493 if ( last )
1494 break; 1494 break;
1495 bool ok; 1495 bool ok;
1496 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1496 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1497 if ( ! ok ) 1497 if ( ! ok )
1498 break; 1498 break;
1499 if ( incidenceStart.date() > endDate ) 1499 if ( incidenceStart.date() > endDate )
1500 break; 1500 break;
1501 } 1501 }
1502 } else { // no recur 1502 } else { // no recur
1503 int st = event->dtStart().date().daysTo( endDate ); 1503 int st = event->dtStart().date().daysTo( endDate );
1504 if ( st >= 0 ) { // start before timeend 1504 if ( st >= 0 ) { // start before timeend
1505 int end = mStartDate.daysTo( event->dtEnd().date() ); 1505 int end = mStartDate.daysTo( event->dtEnd().date() );
1506 if ( end >= 0 ) { // end after timestart --- got one! 1506 if ( end >= 0 ) { // end after timestart --- got one!
1507 //normalize 1507 //normalize
1508 st = timeSpan - st; 1508 st = timeSpan - st;
1509 if ( st < 0 ) st = 0; 1509 if ( st < 0 ) st = 0;
1510 if ( end > timeSpan ) end = timeSpan; 1510 if ( end > timeSpan ) end = timeSpan;
1511 int iii; 1511 int iii;
1512 for ( iii = st;iii<= end;++iii) 1512 for ( iii = st;iii<= end;++iii)
1513 (*cells)[iii]->insertEvent( event ); 1513 (*cells)[iii]->insertEvent( event );
1514 } 1514 }
1515 } 1515 }
1516 } 1516 }
1517 } 1517 }
1518 // insert due todos 1518 // insert due todos
1519 QPtrList<Todo> todos = calendar()->todos( ); 1519 QPtrList<Todo> todos = calendar()->todos( );
1520 Todo *todo; 1520 Todo *todo;
1521 for(todo = todos.first(); todo; todo = todos.next()) { 1521 for(todo = todos.first(); todo; todo = todos.next()) {
1522 //insertTodo( todo ); 1522 //insertTodo( todo );
1523 if ( todo->hasDueDate() ) { 1523 if ( todo->hasDueDate() ) {
1524 int day = mStartDate.daysTo( todo->dtDue().date() ); 1524 int day = mStartDate.daysTo( todo->dtDue().date() );
1525 if ( day >= 0 && day < timeSpan + 1) { 1525 if ( day >= 0 && day < timeSpan + 1) {
1526 (*cells)[day]->insertTodo( todo ); 1526 (*cells)[day]->insertTodo( todo );
1527 } 1527 }
1528 } 1528 }
1529 } 1529 }
1530 1530
1531 for( i = 0; i < timeSpan+1; ++i ) { 1531 for( i = 0; i < timeSpan+1; ++i ) {
1532 (*cells)[i]->finishUpdateCell(); 1532 (*cells)[i]->finishUpdateCell();
1533 } 1533 }
1534 processSelectionChange(); 1534 processSelectionChange();
1535 //qApp->processEvents(); 1535 //qApp->processEvents();
1536 for( i = 0; i < timeSpan+1; ++i ) { 1536 for( i = 0; i < timeSpan+1; ++i ) {
1537 (*cells)[i]->repaintfinishUpdateCell(); 1537 (*cells)[i]->repaintfinishUpdateCell();
1538 } 1538 }
1539 setKeyBFocus(); 1539 setKeyBFocus();
1540#else 1540#else
1541 // old code 1541 // old code
1542 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1542 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1543 int i; 1543 int i;
1544 for( i = 0; i < (*cells).count(); ++i ) { 1544 for( i = 0; i < (*cells).count(); ++i ) {
1545 (*cells)[i]->updateCell(); 1545 (*cells)[i]->updateCell();
1546 } 1546 }
1547 1547
1548 //qDebug("KOMonthView::updateView() "); 1548 //qDebug("KOMonthView::updateView() ");
1549 processSelectionChange(); 1549 processSelectionChange();
1550 // qDebug("---------------------------------------------------------------------+ "); 1550 // qDebug("---------------------------------------------------------------------+ ");
1551 (*cells)[0]->setFocus(); 1551 (*cells)[0]->setFocus();
1552#endif 1552#endif
1553 1553
1554 //qDebug("update time %d ", ti.elapsed()); 1554 //qDebug("update time %d ", ti.elapsed());
1555} 1555}
1556 1556
1557void KOMonthView::setKeyBoardFocus() 1557void KOMonthView::setKeyBoardFocus()
1558{ 1558{
1559 //qDebug("KOMonthView::setKeyBoardFocus() "); 1559 //qDebug("KOMonthView::setKeyBoardFocus() ");
1560 bool shootAgain = false; 1560 bool shootAgain = false;
1561 if ( mShowWeekView ) { 1561 if ( mShowWeekView ) {
1562 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1562 shootAgain = !mWeekLabelsW[1]->hasFocus();
1563 mWeekLabelsW[1]->setFocus(); 1563 mWeekLabelsW[1]->setFocus();
1564 } 1564 }
1565 else { 1565 else {
1566 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1566 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1567 mWeekLabels[mNumWeeks]->setFocus(); 1567 mWeekLabels[mNumWeeks]->setFocus();
1568 } 1568 }
1569 if ( shootAgain ) { 1569 if ( shootAgain ) {
1570 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1570 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1571 } 1571 }
1572} 1572}
1573void KOMonthView::setKeyBFocus() 1573void KOMonthView::setKeyBFocus()
1574{ 1574{
1575 //qDebug("KOMonthView::setKeyBFocus() "); 1575 //qDebug("KOMonthView::setKeyBFocus() ");
1576 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1576 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1577} 1577}
1578void KOMonthView::resizeEvent(QResizeEvent * e) 1578void KOMonthView::resizeEvent(QResizeEvent * e)
1579{ 1579{
1580 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1580 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1581 if ( isVisible() ) { 1581 if ( isVisible() ) {
1582 //qDebug("KOMonthView::isVisible "); 1582 //qDebug("KOMonthView::isVisible ");
1583 slotComputeLayout(); 1583 slotComputeLayout();
1584 } else 1584 } else
1585 mComputeLayoutTimer->start( 100 ); 1585 mComputeLayoutTimer->start( 100 );
1586} 1586}
1587 1587
1588void KOMonthView::slotComputeLayout() 1588void KOMonthView::slotComputeLayout()
1589{ 1589{
1590 mComputeLayoutTimer->stop(); 1590 mComputeLayoutTimer->stop();
1591 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1591 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1592 computeLayout(); 1592 computeLayout();
1593 clPending = true; 1593 clPending = true;
1594 setKeyBFocus(); 1594 setKeyBFocus();
1595} 1595}
1596void KOMonthView::computeLayoutWeek() 1596void KOMonthView::computeLayoutWeek()
1597{ 1597{
1598 static int lastWid = 0; 1598 static int lastWid = 0;
1599 static int lastHei = 0; 1599 static int lastHei = 0;
1600 int daysToShow; 1600 int daysToShow;
1601 bool combinedSatSun = false; 1601 bool combinedSatSun = false;
1602 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1602 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1603 daysToShow = 6; 1603 daysToShow = 6;
1604 combinedSatSun = true; 1604 combinedSatSun = true;
1605 } 1605 }
1606 int tWid = topLevelWidget()->size().width(); 1606 int tWid = topLevelWidget()->size().width();
1607 int tHei = topLevelWidget()->size().height(); 1607 int tHei = topLevelWidget()->size().height();
1608 1608
1609 int wid = width();//e 1609 int wid = width();//e
1610 int hei = height()-1-mNavigatorBar->height(); 1610 int hei = height()-1-mNavigatorBar->height();
1611 1611
1612 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1612 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1613 return; 1613 return;
1614 1614
1615 if ( lastWid == width() && lastHei == height() ) { 1615 if ( lastWid == width() && lastHei == height() ) {
1616 //qDebug("KOListWeekView::No compute layout needed "); 1616 //qDebug("KOListWeekView::No compute layout needed ");
1617 return; 1617 return;
1618 } 1618 }
1619 lastWid = width(); 1619 lastWid = width();
1620 lastHei = height(); 1620 lastHei = height();
1621 1621
1622 1622
1623 if ( wid < hei ) 1623 if ( wid < hei )
1624 daysToShow = 2; 1624 daysToShow = 2;
1625 else 1625 else
1626 daysToShow = 3; 1626 daysToShow = 3;
1627 mShowSatSunComp = true; 1627 mShowSatSunComp = true;
1628 combinedSatSun = true; 1628 combinedSatSun = true;
1629 1629
1630 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1630 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1631 QFontMetrics fm ( mWeekLabels[0]->font() ); 1631 QFontMetrics fm ( mWeekLabels[0]->font() );
1632 int weeklabelwid = fm.width( "888" ); 1632 int weeklabelwid = fm.width( "888" );
1633 wid -= weeklabelwid; 1633 wid -= weeklabelwid;
1634 1634
1635 int colWid = wid / daysToShow; 1635 int colWid = wid / daysToShow;
1636 int lastCol = wid - ( colWid*6 ); 1636 int lastCol = wid - ( colWid*6 );
1637 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1637 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1638 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1638 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1639 int colModulo = wid % daysToShow; 1639 int colModulo = wid % daysToShow;
1640 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1640 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1641 //qDebug("rowmod %d ", rowModulo); 1641 //qDebug("rowmod %d ", rowModulo);
1642 int i; 1642 int i;
1643 int x,y,w,h; 1643 int x,y,w,h;
1644 x= 0; 1644 x= 0;
1645 y= 0; 1645 y= 0;
1646 w = colWid; 1646 w = colWid;
1647 h = dayLabelHei ; 1647 h = dayLabelHei ;
1648 for ( i = 0; i < 7; i++) { 1648 for ( i = 0; i < 7; i++) {
1649 if ( i && !( i % daysToShow) && i < 6) { 1649 if ( i && !( i % daysToShow) && i < 6) {
1650 y += hei/(5-daysToShow); 1650 y += hei/(5-daysToShow);
1651 x = 0; 1651 x = 0;
1652 w = colWid; 1652 w = colWid;
1653 } 1653 }
1654 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1654 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1655 ++w; 1655 ++w;
1656 } 1656 }
1657 if ( i >= 5 ) { 1657 if ( i >= 5 ) {
1658 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1658 int wi = width() - x - weeklabelwid;
1659 x -= (w/2 ); 1659 if ( i == 5 ) {
1660 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1661 } else {
1662 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1663 }
1664 x = x - w + wi - (wi/2 );
1665 }
1666 else {
1667 int wi = w;
1668 if ( !(( i+1) % daysToShow)) {
1669 wi = width() - x - weeklabelwid;
1670 }
1671 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1660 } 1672 }
1661 else
1662 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1663 x += w; 1673 x += w;
1664 } 1674 }
1665 x= 0; 1675 x= 0;
1666 y= dayLabelHei; 1676 y= dayLabelHei;
1667 w = colWid; 1677 w = colWid;
1668 h = cellHei; 1678 h = cellHei;
1669 int max = 0; 1679 int max = 0;
1670 for ( i = 0; i < mCellsW.count(); ++i) { 1680 for ( i = 0; i < mCellsW.count(); ++i) {
1671 if ( i > 6 ) { 1681 if ( i > 6 ) {
1672 mCellsW[i]->hide(); 1682 mCellsW[i]->hide();
1673 continue; 1683 continue;
1674 } 1684 }
1675 1685
1676 w = colWid; 1686 w = colWid;
1677 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1687 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1678 ++w; 1688 ++w;
1679 } 1689 }
1680 if ( i == (daysToShow-1-rowModulo)*7) 1690 if ( i == (daysToShow-1-rowModulo)*7)
1681 ++h; 1691 ++h;
1682 1692
1683 if ( i >= 5 ) { 1693 if ( i >= 5 ) {
1684 if ( i ==5 ) { 1694 if ( i ==5 ) {
1685 max = h/2; 1695 max = h/2;
1686 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1696 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1687 x -= w ;y += h/2; 1697 x -= w ;y += h/2;
1688 } else { 1698 } else {
1689 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1699 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1690 ++w; 1700 ++w;
1691 } 1701 }
1692 max = h-h/2; 1702 max = h-h/2;
1693 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1703 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1694 y -= h/2; 1704 y -= h/2;
1695 } 1705 }
1696 } else { 1706 } else {
1697 max = h; 1707 max = h;
1698 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1708 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1699 } 1709 }
1700 1710
1701 1711
1702 x += w; 1712 x += w;
1703 if ( x + w/2 > wid ) { 1713 if ( x + w/2 > wid ) {
1704 x = 0; 1714 x = 0;
1705 y += h+dayLabelHei ; 1715 y += h+dayLabelHei ;
1706 } 1716 }
1707 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1717 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1708 } 1718 }
1709 y= dayLabelHei; 1719 y= dayLabelHei;
1710 h = cellHei ; 1720 h = cellHei ;
1711 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1721 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1712 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1722 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1713 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1723 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1714 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1724 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1715 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1725 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1716 updateDayLabels(); 1726 updateDayLabels();
1717 //bool forceUpdate = !updatePossible; 1727 //bool forceUpdate = !updatePossible;
1718 updatePossible = true; 1728 updatePossible = true;
1719 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1729 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1720 //if ( forceUpdate ) 1730 //if ( forceUpdate )
1721 // updateView(); 1731 // updateView();
1722} 1732}
1723void KOMonthView::computeLayout() 1733void KOMonthView::computeLayout()
1724{ 1734{
1725 1735
1726 1736
1727 static int lastWid = 0; 1737 static int lastWid = 0;
1728 static int lastHei = 0; 1738 static int lastHei = 0;
1729 1739
1730 if ( mShowWeekView ){ 1740 if ( mShowWeekView ){
1731 computeLayoutWeek(); 1741 computeLayoutWeek();
1732 return; 1742 return;
1733 } 1743 }
1734 int daysToShow = 7; 1744 int daysToShow = 7;
1735 bool combinedSatSun = false; 1745 bool combinedSatSun = false;
1736 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1746 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1737 daysToShow = 6; 1747 daysToShow = 6;
1738 combinedSatSun = true; 1748 combinedSatSun = true;
1739 } 1749 }
1740 int tWid = topLevelWidget()->size().width(); 1750 int tWid = topLevelWidget()->size().width();
1741 int tHei = topLevelWidget()->size().height(); 1751 int tHei = topLevelWidget()->size().height();
1742 1752
1743 int wid = width();//e 1753 int wid = width();//e
1744 int hei = height()-1-mNavigatorBar->height(); 1754 int hei = height()-1-mNavigatorBar->height();
1745 1755
1746 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1756 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1747 return; 1757 return;
1748 } 1758 }
1749 if ( lastWid == width() && lastHei == height() ){ 1759 if ( lastWid == width() && lastHei == height() ){
1750 //qDebug("KOMonthview::No compute layout needed "); 1760 //qDebug("KOMonthview::No compute layout needed ");
1751 return; 1761 return;
1752 } 1762 }
1753 1763
1754 lastWid = width(); 1764 lastWid = width();
1755 lastHei = height(); 1765 lastHei = height();
1756 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1766 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1757 QFontMetrics fm ( mWeekLabels[0]->font() ); 1767 QFontMetrics fm ( mWeekLabels[0]->font() );
1758 int weeklabelwid = fm.width( "888" ); 1768 int weeklabelwid = fm.width( "888" );
1759 wid -= weeklabelwid; 1769 wid -= weeklabelwid;
1760 1770
1761 int colWid = wid / daysToShow; 1771 int colWid = wid / daysToShow;
1762 int lastCol = wid - ( colWid*6 ); 1772 int lastCol = wid - ( colWid*6 );
1763 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1773 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1764 int cellHei = (hei - dayLabelHei) /6; 1774 int cellHei = (hei - dayLabelHei) /6;
1765 int colModulo = wid % daysToShow; 1775 int colModulo = wid % daysToShow;
1766 int rowModulo = (hei- dayLabelHei) % 6; 1776 int rowModulo = (hei- dayLabelHei) % 6;
1767 //qDebug("rowmod %d ", rowModulo); 1777 //qDebug("rowmod %d ", rowModulo);
1768 int i; 1778 int i;
1769 int x,y,w,h; 1779 int x,y,w,h;
1770 x= 0; 1780 x= 0;
1771 y= 0; 1781 y= 0;
1772 w = colWid; 1782 w = colWid;
1773 h = dayLabelHei ; 1783 h = dayLabelHei ;
1774 for ( i = 0; i < 7; i++) { 1784 for ( i = 0; i < 7; i++) {
1775 if ( i == daysToShow-colModulo ) 1785 if ( i == daysToShow-colModulo )
1776 ++w; 1786 ++w;
1777 if ( combinedSatSun ) { 1787 if ( combinedSatSun ) {
1778 if ( i >= daysToShow-1 ) { 1788 if ( i >= daysToShow-1 ) {
1779 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1789
1790 if ( i == 6 )
1791 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
1792 else
1793 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1780 x -= w/2 ; 1794 x -= w/2 ;
1781 } 1795 }
1782 else 1796 else
1783 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1797 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1784 } else 1798 } else
1785 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1799 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1786 x += w; 1800 x += w;
1787 } 1801 }
1788 x= 0; 1802 x= 0;
1789 y= dayLabelHei; 1803 y= dayLabelHei;
1790 w = colWid; 1804 w = colWid;
1791 h = cellHei ; 1805 h = cellHei ;
1792 int max = 0; 1806 int max = 0;
1793 for ( i = 0; i < mCells.count(); ++i) { 1807 for ( i = 0; i < mCells.count(); ++i) {
1794 //qDebug("iii %d ", i); 1808 //qDebug("iii %d ", i);
1795 w = colWid; 1809 w = colWid;
1796 if ( ((i) % 7) >= 7-colModulo ) { 1810 if ( ((i) % 7) >= 7-colModulo ) {
1797 ++w; 1811 ++w;
1798 } 1812 }
1799 if ( i == (6-rowModulo)*7) 1813 if ( i == (6-rowModulo)*7)
1800 ++h; 1814 ++h;
1801 if ( combinedSatSun ) { 1815 if ( combinedSatSun ) {
1802 if ( (i)%7 >= daysToShow-1 ) { 1816 if ( (i)%7 >= daysToShow-1 ) {
1803 if ( (i)%7 == daysToShow-1 ) { 1817 if ( (i)%7 == daysToShow-1 ) {
1818 w = width()-x-weeklabelwid;
1804 max = h/2; 1819 max = h/2;
1805 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1820 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1806 x -= w ;y += h/2; 1821 x -= w ;y += h/2;
1807 } else { 1822 } else {
1823 w = width()-x-weeklabelwid;
1808 max = h-h/2; 1824 max = h-h/2;
1809 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1825 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1810 y -= h/2; 1826 y -= h/2;
1811 } 1827 }
1812 } else { 1828 } else {
1813 max = h; 1829 max = h;
1814 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1830 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1815 } 1831 }
1816 1832
1817 } 1833 }
1818 else { 1834 else {
1819 max = h; 1835 max = h;
1820 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1836 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1821 } 1837 }
1822 x += w; 1838 x += w;
1823 if ( x + w/2 > wid ) { 1839 if ( x + w/2 > wid ) {
1824 x = 0; 1840 x = 0;
1825 y += h; 1841 y += h;
1826 } 1842 }
1827 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 1843 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
1828 } 1844 }
1829 y= dayLabelHei; 1845 y= dayLabelHei;
1830 h = cellHei ; 1846 h = cellHei ;
1831 for ( i = 0; i < 6; i++) { 1847 for ( i = 0; i < 6; i++) {
1832 if ( i == (6-rowModulo)) 1848 if ( i == (6-rowModulo))
1833 ++h; 1849 ++h;
1834 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1850 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1835 y += h; 1851 y += h;
1836 } 1852 }
1837 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1853 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1838 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1854 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1839 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1855 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1840 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1856 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1841 updateDayLabels(); 1857 updateDayLabels();
1842 //bool forceUpdate = !updatePossible; 1858 //bool forceUpdate = !updatePossible;
1843 updatePossible = true; 1859 updatePossible = true;
1844 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1860 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1845} 1861}
1846 1862
1847void KOMonthView::showContextMenu( Incidence *incidence ) 1863void KOMonthView::showContextMenu( Incidence *incidence )
1848{ 1864{
1849 mContextMenu->showIncidencePopup(incidence); 1865 mContextMenu->showIncidencePopup(incidence);
1850 /* 1866 /*
1851 if( incidence && incidence->type() == "Event" ) { 1867 if( incidence && incidence->type() == "Event" ) {
1852 Event *event = static_cast<Event *>(incidence); 1868 Event *event = static_cast<Event *>(incidence);
1853 mContextMenu->showEventPopup(event); 1869 mContextMenu->showEventPopup(event);
1854 } else { 1870 } else {
1855 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1871 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1856 } 1872 }
1857 */ 1873 */
1858} 1874}
1859MonthViewCell * KOMonthView::selectedCell( ) 1875MonthViewCell * KOMonthView::selectedCell( )
1860{ 1876{
1861 return mSelectedCell; 1877 return mSelectedCell;
1862} 1878}
1863void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1879void KOMonthView::setSelectedCell( MonthViewCell *cell )
1864{ 1880{
1865 //qDebug("KOMonthView::setSelectedCell "); 1881 //qDebug("KOMonthView::setSelectedCell ");
1866 if ( mSelectedCell && mSelectedCell != cell ) { 1882 if ( mSelectedCell && mSelectedCell != cell ) {
1867 MonthViewCell * mvc = mSelectedCell; 1883 MonthViewCell * mvc = mSelectedCell;
1868 mSelectedCell = cell; 1884 mSelectedCell = cell;
1869 mvc->deselect(); 1885 mvc->deselect();
1870 } else 1886 } else
1871 mSelectedCell = cell; 1887 mSelectedCell = cell;
1872 // if ( mSelectedCell ) 1888 // if ( mSelectedCell )
1873 // mSelectedCell->select(); 1889 // mSelectedCell->select();
1874 if ( !mSelectedCell ) 1890 if ( !mSelectedCell )
1875 emit incidenceSelected( 0 ); 1891 emit incidenceSelected( 0 );
1876 else 1892 else
1877 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1893 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1878} 1894}
1879 1895
1880void KOMonthView::processSelectionChange() 1896void KOMonthView::processSelectionChange()
1881{ 1897{
1882 QPtrList<Incidence> incidences = selectedIncidences(); 1898 QPtrList<Incidence> incidences = selectedIncidences();
1883 if (incidences.count() > 0) { 1899 if (incidences.count() > 0) {
1884 emit incidenceSelected( incidences.first() ); 1900 emit incidenceSelected( incidences.first() );
1885 } else { 1901 } else {
1886 emit incidenceSelected( 0 ); 1902 emit incidenceSelected( 0 );
1887 clearSelection(); 1903 clearSelection();
1888 } 1904 }
1889} 1905}
1890 1906
1891void KOMonthView::clearSelection() 1907void KOMonthView::clearSelection()
1892{ 1908{
1893 if ( mSelectedCell ) { 1909 if ( mSelectedCell ) {
1894 mSelectedCell->deselect(); 1910 mSelectedCell->deselect();
1895 mSelectedCell = 0; 1911 mSelectedCell = 0;
1896 } 1912 }
1897} 1913}
1898 1914
1899void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 1915void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
1900{ 1916{
1901 if ( !e->isAutoRepeat() ) { 1917 if ( !e->isAutoRepeat() ) {
1902 mFlagKeyPressed = false; 1918 mFlagKeyPressed = false;
1903 } 1919 }
1904} 1920}
1905 1921
1906void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1922void KOMonthView::keyPressEvent ( QKeyEvent * e )
1907{ 1923{
1908 1924
1909 qApp->processEvents(); 1925 qApp->processEvents();
1910 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1926 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1911 //e->ignore(); 1927 //e->ignore();
1912 e->accept(); 1928 e->accept();
1913 return; 1929 return;
1914 } 1930 }
1915 if (! e->isAutoRepeat() ) 1931 if (! e->isAutoRepeat() )
1916 mFlagKeyPressed = true; 1932 mFlagKeyPressed = true;
1917 switch(e->key()) { 1933 switch(e->key()) {
1918 case Key_Up: 1934 case Key_Up:
1919 { 1935 {
1920 if ( mShowWeekView ) { 1936 if ( mShowWeekView ) {
1921 emit selectWeekNum ( currentWeek() - 1 ); 1937 emit selectWeekNum ( currentWeek() - 1 );
1922 } 1938 }
1923 else { 1939 else {
1924 emit prevMonth(); 1940 emit prevMonth();
1925 } 1941 }
1926 } 1942 }
1927 e->accept(); 1943 e->accept();
1928 break; 1944 break;
1929 case Key_Down: 1945 case Key_Down:
1930 { 1946 {
1931 if ( mShowWeekView ) { 1947 if ( mShowWeekView ) {
1932 emit selectWeekNum ( currentWeek() +1); 1948 emit selectWeekNum ( currentWeek() +1);
1933 } 1949 }
1934 else { 1950 else {
1935 emit nextMonth(); 1951 emit nextMonth();
1936 } 1952 }
1937 1953
1938 } 1954 }
1939 e->accept(); 1955 e->accept();
1940 break; 1956 break;
1941 case Key_Return: 1957 case Key_Return:
1942 case Key_Enter: 1958 case Key_Enter:
1943 { 1959 {
1944 selectInternalWeekNum ( currentWeek() ); 1960 selectInternalWeekNum ( currentWeek() );
1945 } 1961 }
1946 e->accept(); 1962 e->accept();
1947 break; 1963 break;
1948 case Key_D: 1964 case Key_D:
1949 if ( mSelectedCell ) { 1965 if ( mSelectedCell ) {
1950 mSelectedCell->showDay(); 1966 mSelectedCell->showDay();
1951 e->accept(); 1967 e->accept();
1952 } else { 1968 } else {
1953 e->ignore(); 1969 e->ignore();
1954 } 1970 }
1955 break; 1971 break;
1956 default: 1972 default:
1957 e->ignore(); 1973 e->ignore();
1958 break; 1974 break;
1959 } 1975 }
1960} 1976}