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