summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp14
-rw-r--r--korganizer/komonthview.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9b0389d..00e5a6f 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1425 +1,1439 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 88 setHScrollBarMode(QScrollView::AlwaysOff);
89} 89}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
91{ 91{
92#if QT_VERSION >= 0x030000 92#if QT_VERSION >= 0x030000
93 93
94#else 94#else
95 delete mWT; 95 delete mWT;
96#endif 96#endif
97} 97}
98 98
99 99
100void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 100void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
101{ 101{
102 QListBox::focusInEvent ( e ); 102 QListBox::focusInEvent ( e );
103 if ( count() ){ 103 if ( count() ){
104 int ci = currentItem(); 104 int ci = currentItem();
105 if ( ci < 0 ) ci = 0; 105 if ( ci < 0 ) ci = 0;
106 106
107 setCurrentItem( ci ); 107 setCurrentItem( ci );
108 setSelected ( ci, true ); 108 setSelected ( ci, true );
109 emit highlighted( item ( ci ) ); 109 emit highlighted( item ( ci ) );
110 110
111 resetOnFocusIn = true; 111 resetOnFocusIn = true;
112 112
113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
114 QListBoxItem *fi = firstItem (); 114 QListBoxItem *fi = firstItem ();
115 if (fi ) { 115 if (fi ) {
116 int ihei = fi->height( this ); 116 int ihei = fi->height( this );
117 int hei = numRows () * ihei; 117 int hei = numRows () * ihei;
118 if ( hei < height() - horizontalScrollBar()->height () ) { 118 if ( hei < height() - horizontalScrollBar()->height () ) {
119 setVScrollBarMode(QScrollView::AlwaysOff); 119 setVScrollBarMode(QScrollView::AlwaysOff);
120 } 120 }
121 else 121 else
122 setVScrollBarMode(QScrollView::Auto); 122 setVScrollBarMode(QScrollView::Auto);
123 if ( ihei *3 > height() ) { 123 if ( ihei *3 > height() ) {
124 setHScrollBarMode(QScrollView::AlwaysOff); 124 setHScrollBarMode(QScrollView::AlwaysOff);
125 } 125 }
126 else { 126 else {
127 setHScrollBarMode(QScrollView::Auto); 127 setHScrollBarMode(QScrollView::Auto);
128 } 128 }
129 } else { 129 } else {
130 setVScrollBarMode(QScrollView::Auto); 130 setVScrollBarMode(QScrollView::Auto);
131 setHScrollBarMode(QScrollView::Auto); 131 setHScrollBarMode(QScrollView::Auto);
132 } 132 }
133 } 133 }
134 } 134 }
135} 135}
136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
137{ 137{
138 int i = currentItem (); 138 int i = currentItem ();
139 if ( i >= 0 ) { 139 if ( i >= 0 ) {
140 setSelected ( i, false ); 140 setSelected ( i, false );
141 } 141 }
142 QListBox::focusOutEvent ( e ); 142 QListBox::focusOutEvent ( e );
143 setVScrollBarMode(QScrollView::AlwaysOff); 143 setVScrollBarMode(QScrollView::AlwaysOff);
144 setHScrollBarMode(QScrollView::AlwaysOff); 144 setHScrollBarMode(QScrollView::AlwaysOff);
145 emit highligtIncidence( 0, (MonthViewCell*)this, 0 ); 145 emit highligtIncidence( 0, (MonthViewCell*)this, 0 );
146} 146}
147 147
148QString KNoScrollListBox::getWhatsThisText(QPoint p) 148QString KNoScrollListBox::getWhatsThisText(QPoint p)
149{ 149{
150 QListBoxItem* item = itemAt ( p ); 150 QListBoxItem* item = itemAt ( p );
151 if ( ! item ) { 151 if ( ! item ) {
152 return i18n("Click in the cell\nto add an event!"); 152 return i18n("Click in the cell\nto add an event!");
153 } 153 }
154 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 154 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
155 KOPrefs::instance()->mWTshowDetails, 155 KOPrefs::instance()->mWTshowDetails,
156 KOPrefs::instance()->mWTshowCreated, 156 KOPrefs::instance()->mWTshowCreated,
157 KOPrefs::instance()->mWTshowChanged); 157 KOPrefs::instance()->mWTshowChanged);
158} 158}
159void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 159void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
160{ 160{
161 //qDebug("KNoScrollListBox::keyPressEvent "); 161 //qDebug("KNoScrollListBox::keyPressEvent ");
162 switch(e->key()) { 162 switch(e->key()) {
163 case Key_Right: 163 case Key_Right:
164 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 164 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
165 { 165 {
166 e->ignore(); 166 e->ignore();
167 return; 167 return;
168 } 168 }
169 scrollBy(10,0); 169 scrollBy(10,0);
170 break; 170 break;
171 case Key_Left: 171 case Key_Left:
172 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 172 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
173 { 173 {
174 e->ignore(); 174 e->ignore();
175 return; 175 return;
176 } 176 }
177 scrollBy(-10,0); 177 scrollBy(-10,0);
178 break; 178 break;
179 case Key_Up: 179 case Key_Up:
180 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 180 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
181 e->ignore(); 181 e->ignore();
182 break; 182 break;
183 } 183 }
184 if ( count() ) { 184 if ( count() ) {
185 if ( currentItem() == 0 ) { 185 if ( currentItem() == 0 ) {
186 emit prevCell(); 186 emit prevCell();
187 } else { 187 } else {
188 setCurrentItem((currentItem()+count()-1)%count()); 188 setCurrentItem((currentItem()+count()-1)%count());
189 if(!itemVisible(currentItem())) { 189 if(!itemVisible(currentItem())) {
190 if((unsigned int) currentItem() == (count()-1)) { 190 if((unsigned int) currentItem() == (count()-1)) {
191 setTopItem(currentItem()-numItemsVisible()+1); 191 setTopItem(currentItem()-numItemsVisible()+1);
192 } else { 192 } else {
193 setTopItem(topItem()-1); 193 setTopItem(topItem()-1);
194 } 194 }
195 } 195 }
196 } 196 }
197 } 197 }
198 break; 198 break;
199 case Key_Down: 199 case Key_Down:
200 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 200 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
201 e->ignore(); 201 e->ignore();
202 break; 202 break;
203 } 203 }
204 if ( count () ) { 204 if ( count () ) {
205 if ( currentItem()+1 == count () ) { 205 if ( currentItem()+1 == count () ) {
206 emit nextCell(); 206 emit nextCell();
207 } else { 207 } else {
208 setCurrentItem((currentItem()+1)%count()); 208 setCurrentItem((currentItem()+1)%count());
209 if(!itemVisible(currentItem())) { 209 if(!itemVisible(currentItem())) {
210 if(currentItem() == 0) { 210 if(currentItem() == 0) {
211 setTopItem(0); 211 setTopItem(0);
212 } else { 212 } else {
213 setTopItem(topItem()+1); 213 setTopItem(topItem()+1);
214 } 214 }
215 } 215 }
216 } 216 }
217 } 217 }
218 break; 218 break;
219 case Key_I: 219 case Key_I:
220 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 220 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
221 e->ignore(); 221 e->ignore();
222 break; 222 break;
223 case Key_Return: 223 case Key_Return:
224 case Key_Enter: 224 case Key_Enter:
225 { 225 {
226 if ( currentItem() >= 0 ) { 226 if ( currentItem() >= 0 ) {
227 emit doubleClicked( item( currentItem() ) ); 227 emit doubleClicked( item( currentItem() ) );
228 e->accept(); 228 e->accept();
229 } else { 229 } else {
230 e->ignore(); 230 e->ignore();
231 } 231 }
232 } 232 }
233 break; 233 break;
234 case Key_Shift: 234 case Key_Shift:
235 emit shiftDown(); 235 emit shiftDown();
236 break; 236 break;
237 default: 237 default:
238 e->ignore(); 238 e->ignore();
239 break; 239 break;
240 } 240 }
241} 241}
242 242
243void KNoScrollListBox::oneDown() 243void KNoScrollListBox::oneDown()
244{ 244{
245 if ( count () ) { 245 if ( count () ) {
246 if ( currentItem()+1 == count () ) { 246 if ( currentItem()+1 == count () ) {
247 emit nextCell(); 247 emit nextCell();
248 } else { 248 } else {
249 resetOnFocusIn = false; 249 resetOnFocusIn = false;
250 setCurrentItem((currentItem()+1)%count()); 250 setCurrentItem((currentItem()+1)%count());
251 if(!itemVisible(currentItem())) { 251 if(!itemVisible(currentItem())) {
252 if(currentItem() == 0) { 252 if(currentItem() == 0) {
253 setTopItem(0); 253 setTopItem(0);
254 } else { 254 } else {
255 setTopItem(topItem()+1); 255 setTopItem(topItem()+1);
256 } 256 }
257 } 257 }
258 } 258 }
259 } 259 }
260} 260}
261void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 261void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
262{ 262{
263 switch(e->key()) { 263 switch(e->key()) {
264 case Key_Shift: 264 case Key_Shift:
265 emit shiftUp(); 265 emit shiftUp();
266 break; 266 break;
267 default: 267 default:
268 break; 268 break;
269 } 269 }
270} 270}
271 271
272void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 272void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
273{ 273{
274 QListBox::mousePressEvent(e); 274 QListBox::mousePressEvent(e);
275 275
276 if(e->button() == RightButton) { 276 if(e->button() == RightButton) {
277 emit rightClick(); 277 emit rightClick();
278 } 278 }
279} 279}
280 280
281MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 281MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
282 : QListBoxItem() 282 : QListBoxItem()
283{ 283{
284 mDisplayHightlighted = false; 284 mDisplayHightlighted = false;
285 mblockRepaint = true; 285 mblockRepaint = true;
286 setText( s ); 286 setText( s );
287 mMultiday = 0; 287 mMultiday = 0;
288 mIncidence = incidence; 288 mIncidence = incidence;
289 mDate = qd; 289 mDate = qd;
290 mRecur = false; 290 mRecur = false;
291 mAlarm = false; 291 mAlarm = false;
292 mReply = false; 292 mReply = false;
293 mInfo = false; 293 mInfo = false;
294 mdayPos = 0; 294 mdayPos = 0;
295 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 295 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
296} 296}
297void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 297void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
298{ 298{
299 mDisplayHightlighted = false; 299 mDisplayHightlighted = false;
300 setText( s ); 300 setText( s );
301 mMultiday = 0; 301 mMultiday = 0;
302 mIncidence = incidence; 302 mIncidence = incidence;
303 mDate = qd; 303 mDate = qd;
304 mRecur = false; 304 mRecur = false;
305 mAlarm = false; 305 mAlarm = false;
306 mReply = false; 306 mReply = false;
307 mInfo = false; 307 mInfo = false;
308 mdayPos = 0; 308 mdayPos = 0;
309} 309}
310void MonthViewItem::clearData()
311{
312 mDisplayHightlighted = false;
313 setText( "" );
314 mMultiday = 0;
315 mIncidence = 0;
316 mRecur = false;
317 mAlarm = false;
318 mReply = false;
319 mInfo = false;
320 mdayPos = 0;
321}
310bool MonthViewItem::setHighlightedFalse() 322bool MonthViewItem::setHighlightedFalse()
311{ 323{
312 if ( !mDisplayHightlighted ) 324 if ( !mDisplayHightlighted )
313 return false; 325 return false;
314 mDisplayHightlighted = false; 326 mDisplayHightlighted = false;
315 return true; 327 return true;
316} 328}
317 329
318bool MonthViewItem::setHighlighted( Incidence * inc ) 330bool MonthViewItem::setHighlighted( Incidence * inc )
319{ 331{
320 if ( inc == mIncidence ) { 332 if ( inc == mIncidence ) {
321 if ( mDisplayHightlighted ) 333 if ( mDisplayHightlighted )
322 return false; 334 return false;
323 mDisplayHightlighted = true; 335 mDisplayHightlighted = true;
324 return true; 336 return true;
325 } else { 337 } else {
326 if ( !mDisplayHightlighted ) 338 if ( !mDisplayHightlighted )
327 return false; 339 return false;
328 mDisplayHightlighted = false; 340 mDisplayHightlighted = false;
329 return true; 341 return true;
330 } 342 }
331 return false; 343 return false;
332} 344}
333void MonthViewItem::paint(QPainter *p) 345void MonthViewItem::paint(QPainter *p)
334{ 346{
335 if ( mblockRepaint ) { 347 if ( mblockRepaint ) {
336 return; 348 return;
337 } 349 }
338#if QT_VERSION >= 0x030000 350#if QT_VERSION >= 0x030000
339 bool sel = isSelected(); 351 bool sel = isSelected();
340#else 352#else
341 bool sel = selected(); 353 bool sel = selected();
342#endif 354#endif
343 int heihei = height( listBox () ); 355 int heihei = height( listBox () );
344 int x = 1; 356 int x = 1;
345 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted ) 357 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted )
346 { 358 {
347 if ( mDisplayHightlighted ) 359 if ( mDisplayHightlighted )
348 sel = true; 360 sel = true;
349 p->setBackgroundColor( palette().color( QPalette::Normal, \ 361 p->setBackgroundColor( palette().color( QPalette::Normal, \
350 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 362 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
351 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); 363 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
352 } 364 }
353 365
354 //int y = 3;//(height() - mRecurPixmap.height()) /2; 366 //int y = 3;//(height() - mRecurPixmap.height()) /2;
355 int size = PIXMAP_SIZE; 367 int size = PIXMAP_SIZE;
356 if ( QApplication::desktop()->width() < 300 ) 368 if ( QApplication::desktop()->width() < 300 )
357 size = 3; 369 size = 3;
358 int y = (heihei - size -1 ) /2; 370 int y = (heihei - size -1 ) /2;
359 371
360 if ( mIncidence->calID() > 1 ) { 372 if ( mIncidence->calID() > 1 ) {
361 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 373 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
362 p->drawRect ( x, y-2,size,size+4); 374 p->drawRect ( x, y-2,size,size+4);
363 x += size + 1; 375 x += size + 1;
364 } 376 }
365 if ( KOPrefs::instance()->mMonthShowIcons ) { 377 if ( KOPrefs::instance()->mMonthShowIcons ) {
366 if ( mInfo ) { 378 if ( mInfo ) {
367 p->fillRect ( x, y,size,size, Qt::darkGreen ); 379 p->fillRect ( x, y,size,size, Qt::darkGreen );
368 x += size + 1; 380 x += size + 1;
369 } 381 }
370 if ( mRecur ) { 382 if ( mRecur ) {
371 p->fillRect ( x, y,size,size, Qt::blue ); 383 p->fillRect ( x, y,size,size, Qt::blue );
372 x += size + 1; 384 x += size + 1;
373 } 385 }
374 if ( mAlarm ) { 386 if ( mAlarm ) {
375 p->fillRect ( x, y,size,size, Qt::red ); 387 p->fillRect ( x, y,size,size, Qt::red );
376 x += size + 1; 388 x += size + 1;
377 } 389 }
378 if ( mReply ) { 390 if ( mReply ) {
379 p->fillRect ( x, y,size,size, Qt::yellow ); 391 p->fillRect ( x, y,size,size, Qt::yellow );
380 x += size + 1; 392 x += size + 1;
381 } 393 }
382 } 394 }
383 if ( mMultiday ) { 395 if ( mMultiday ) {
384 int yyy = y+(size/2); 396 int yyy = y+(size/2);
385 int sizeM = size+2; 397 int sizeM = size+2;
386 p->setBrush( QBrush::SolidPattern ); 398 p->setBrush( QBrush::SolidPattern );
387 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 399 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
388 if ( mMultiday == 2 || mMultiday == 3 ) { 400 if ( mMultiday == 2 || mMultiday == 3 ) {
389 QPointArray pa ( 3 ); 401 QPointArray pa ( 3 );
390 pa.setPoint (0, x, yyy ); 402 pa.setPoint (0, x, yyy );
391 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 403 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
392 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 404 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
393 p->drawPolygon( pa ); 405 p->drawPolygon( pa );
394 } 406 }
395 if ( mMultiday == 2 || mMultiday == 1 ) { 407 if ( mMultiday == 2 || mMultiday == 1 ) {
396 QPointArray pa ( 3 ); 408 QPointArray pa ( 3 );
397 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 409 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
398 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 410 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
399 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 411 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
400 p->drawPolygon( pa ); 412 p->drawPolygon( pa );
401 } 413 }
402 if ( mMultiday == 1 ) { 414 if ( mMultiday == 1 ) {
403 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 415 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
404 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 416 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
405 } 417 }
406 if ( mMultiday == 3 ) { 418 if ( mMultiday == 3 ) {
407 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 419 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
408 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 420 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
409 421
410 } 422 }
411 x += sizeM/2 + 1; 423 x += sizeM/2 + 1;
412 x += sizeM + 1; 424 x += sizeM + 1;
413 } 425 }
414 426
415 if ( mIncidence->typeID() == todoID ){ 427 if ( mIncidence->typeID() == todoID ){
416 Todo* td = ( Todo* ) mIncidence; 428 Todo* td = ( Todo* ) mIncidence;
417 if ( td->isCompleted() ) { 429 if ( td->isCompleted() ) {
418 int half = size/2; 430 int half = size/2;
419 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 431 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
420 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 432 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
421 x += half+half + 4; 433 x += half+half + 4;
422 434
423 } else { 435 } else {
424 int val = td->percentComplete()/20; 436 int val = td->percentComplete()/20;
425 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 437 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
426 p->drawRect ( x, y-2,7,size+4); 438 p->drawRect ( x, y-2,7,size+4);
427 x += size + 3; 439 x += size + 3;
428 } 440 }
429 } 441 }
430 QFontMetrics fm = p->fontMetrics(); 442 QFontMetrics fm = p->fontMetrics();
431 int yPos; 443 int yPos;
432 int pmheight = size; 444 int pmheight = size;
433 if( pmheight < fm.height() ) 445 if( pmheight < fm.height() )
434 yPos = fm.ascent() + fm.leading()/2; 446 yPos = fm.ascent() + fm.leading()/2;
435 else 447 else
436 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 448 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
437 p->setPen( palette().color( QPalette::Normal, sel ? \ 449 p->setPen( palette().color( QPalette::Normal, sel ? \
438 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 450 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
439 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 451 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
440 p->drawText( x, yPos, text() ); 452 p->drawText( x, yPos, text() );
441 if ( mIncidence->cancelled() ) { 453 if ( mIncidence->cancelled() ) {
442 int wid = fm.width( text() ); 454 int wid = fm.width( text() );
443 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 455 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
444 } 456 }
445 } else { 457 } else {
446 QString pText = text(); 458 QString pText = text();
447 if( pText.mid(2,1) == ":" ) 459 if( pText.mid(2,1) == ":" )
448 pText = pText.mid( 6 ); 460 pText = pText.mid( 6 );
449 p->drawText( x, yPos, pText ); 461 p->drawText( x, yPos, pText );
450 if ( mIncidence->cancelled() ) { 462 if ( mIncidence->cancelled() ) {
451 int wid = fm.width( pText ); 463 int wid = fm.width( pText );
452 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 464 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
453 } 465 }
454 } 466 }
455} 467}
456 468
457int MonthViewItem::height(const QListBox *lb) const 469int MonthViewItem::height(const QListBox *lb) const
458{ 470{
459 int ret = 10; 471 int ret = 10;
460 if ( lb ) 472 if ( lb )
461 ret = lb->fontMetrics().lineSpacing()+1; 473 ret = lb->fontMetrics().lineSpacing()+1;
462 return ret; 474 return ret;
463} 475}
464 476
465int MonthViewItem::width(const QListBox *lb) const 477int MonthViewItem::width(const QListBox *lb) const
466{ 478{
467 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 479 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
468 int size = PIXMAP_SIZE; 480 int size = PIXMAP_SIZE;
469 if ( QApplication::desktop()->width() < 300 ) 481 if ( QApplication::desktop()->width() < 300 )
470 size = 3; 482 size = 3;
471 int x = 1; 483 int x = 1;
472 if ( KOPrefs::instance()->mMonthShowIcons ) { 484 if ( KOPrefs::instance()->mMonthShowIcons ) {
473 if ( mInfo ) { 485 if ( mInfo ) {
474 x += size + 1; 486 x += size + 1;
475 } 487 }
476 if( mRecur ) { 488 if( mRecur ) {
477 x += size+1; 489 x += size+1;
478 } 490 }
479 if( mAlarm ) { 491 if( mAlarm ) {
480 x += size+1; 492 x += size+1;
481 } 493 }
482 if( mReply ) { 494 if( mReply ) {
483 x += size+1; 495 x += size+1;
484 } 496 }
485 } 497 }
486 if( mMultiday ) { 498 if( mMultiday ) {
487 x += size+1+2+size/2; 499 x += size+1+2+size/2;
488 } 500 }
489 return( x + lb->fontMetrics().width( text() ) + 1 ); 501 return( x + lb->fontMetrics().width( text() ) + 1 );
490 } 502 }
491 if ( ! lb ) 503 if ( ! lb )
492 return 10; 504 return 10;
493 return lb->width(); 505 return lb->width();
494} 506}
495 507
496 508
497MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 509MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
498 : KNoScrollListBox( par ), 510 : KNoScrollListBox( par ),
499 mMonthView( parent ) 511 mMonthView( parent )
500{ 512{
501 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 513 //QVBoxLayout *topLayout = new QVBoxLayout( this );
502 currentPalette = 0; 514 currentPalette = 0;
503 // mLabel = new QLabel( this );QPushButton 515 // mLabel = new QLabel( this );QPushButton
504 mLabel = new QPushButton( this ); 516 mLabel = new QPushButton( this );
505 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 517 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
506 //mLabel->setLineWidth( 1 ); 518 //mLabel->setLineWidth( 1 );
507 //mLabel->setAlignment( AlignCenter ); 519 //mLabel->setAlignment( AlignCenter );
508 mLabel->setFlat( true ); 520 mLabel->setFlat( true );
509 mLabel->setFocusPolicy(NoFocus); 521 mLabel->setFocusPolicy(NoFocus);
510 //mItemList = new KNoScrollListBox( this ); 522 //mItemList = new KNoScrollListBox( this );
511 setMinimumSize( 10, 10 ); 523 setMinimumSize( 10, 10 );
512 setFrameStyle( QFrame::Panel | QFrame::Plain ); 524 setFrameStyle( QFrame::Panel | QFrame::Plain );
513 setLineWidth( 1 ); 525 setLineWidth( 1 );
514 //topLayout->addWidget( mItemList ); 526 //topLayout->addWidget( mItemList );
515 mLabel->raise(); 527 mLabel->raise();
516 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 528 // QColor( 0,0,255 ) QColor( 160,1600,255 )
517 mStandardPalette = palette(); 529 mStandardPalette = palette();
518 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 530 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
519 531
520 enableScrollBars( false ); 532 enableScrollBars( false );
521 updateConfig(); 533 updateConfig();
522 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 534 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
523 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 535 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
524 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 536 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
525 SLOT( defaultAction( QListBoxItem * ) ) ); 537 SLOT( defaultAction( QListBoxItem * ) ) );
526 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 538 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
527 const QPoint &) ), 539 const QPoint &) ),
528 SLOT( contextMenu( QListBoxItem * ) ) ); 540 SLOT( contextMenu( QListBoxItem * ) ) );
529 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 541 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
530 SLOT( selection( QListBoxItem * ) ) ); 542 SLOT( selection( QListBoxItem * ) ) );
531 543
532 /* 544 /*
533 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 545 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
534 SLOT( selection( QListBoxItem * ) ) ); 546 SLOT( selection( QListBoxItem * ) ) );
535 */ 547 */
536} 548}
537#ifdef DESKTOP_VERSION 549#ifdef DESKTOP_VERSION
538QToolTipGroup *MonthViewCell::toolTipGroup() 550QToolTipGroup *MonthViewCell::toolTipGroup()
539{ 551{
540 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 552 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
541 return mToolTipGroup; 553 return mToolTipGroup;
542} 554}
543#endif 555#endif
544 556
545void MonthViewCell::setDate( const QDate &date ) 557void MonthViewCell::setDate( const QDate &date )
546{ 558{
547 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 559 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
548 mDate = date; 560 mDate = date;
549 561
550 562
551 563
552 //resizeEvent( 0 ); 564 //resizeEvent( 0 );
553} 565}
554 566
555QDate MonthViewCell::date() const 567QDate MonthViewCell::date() const
556{ 568{
557 return mDate; 569 return mDate;
558} 570}
559 571
560void MonthViewCell::setPrimary( bool primary ) 572void MonthViewCell::setPrimary( bool primary )
561{ 573{
562 mPrimary = primary; 574 mPrimary = primary;
563 //setMyPalette(); 575 //setMyPalette();
564} 576}
565void MonthViewCell::setMyPalette() 577void MonthViewCell::setMyPalette()
566{ 578{
567 579
568 if ( mHoliday) { 580 if ( mHoliday) {
569 if ( currentPalette == 1 ) return; 581 if ( currentPalette == 1 ) return;
570 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 582 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
571 setPalette( mHolidayPalette ); 583 setPalette( mHolidayPalette );
572 //mLabel->setPalette( mHolidayPalette ); 584 //mLabel->setPalette( mHolidayPalette );
573 currentPalette = 1; 585 currentPalette = 1;
574 586
575 } else { 587 } else {
576 if ( mPrimary ) { 588 if ( mPrimary ) {
577 if ( currentPalette == 2 ) return; 589 if ( currentPalette == 2 ) return;
578 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 590 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
579 //mLabel->setPalette( mPrimaryPalette ); 591 //mLabel->setPalette( mPrimaryPalette );
580 setPalette( mPrimaryPalette ); 592 setPalette( mPrimaryPalette );
581 currentPalette = 2; 593 currentPalette = 2;
582 594
583 } else { 595 } else {
584 if ( currentPalette == 3 ) return; 596 if ( currentPalette == 3 ) return;
585 setPalette( mNonPrimaryPalette ); 597 setPalette( mNonPrimaryPalette );
586 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 598 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
587 //mLabel->setPalette( mNonPrimaryPalette );; 599 //mLabel->setPalette( mNonPrimaryPalette );;
588 currentPalette = 3; 600 currentPalette = 3;
589 } 601 }
590 } 602 }
591 //QPalette pal = palette(); 603 //QPalette pal = palette();
592 604
593 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 605 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
594} 606}
595QPalette MonthViewCell::getPalette () 607QPalette MonthViewCell::getPalette ()
596{ 608{
597 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 609 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
598 return mStandardPalette; 610 return mStandardPalette;
599 if ( mHoliday) { 611 if ( mHoliday) {
600 return mHolidayPalette ; 612 return mHolidayPalette ;
601 } else { 613 } else {
602 if ( mPrimary ) { 614 if ( mPrimary ) {
603 return mPrimaryPalette ; 615 return mPrimaryPalette ;
604 } 616 }
605 } 617 }
606 return mNonPrimaryPalette; 618 return mNonPrimaryPalette;
607} 619}
608bool MonthViewCell::isPrimary() const 620bool MonthViewCell::isPrimary() const
609{ 621{
610 return mPrimary; 622 return mPrimary;
611} 623}
612 624
613void MonthViewCell::setHoliday( bool holiday ) 625void MonthViewCell::setHoliday( bool holiday )
614{ 626{
615 mHoliday = holiday; 627 mHoliday = holiday;
616 //setMyPalette(); 628 //setMyPalette();
617} 629}
618 630
619void MonthViewCell::setHoliday( const QString &holiday ) 631void MonthViewCell::setHoliday( const QString &holiday )
620{ 632{
621 mHolidayString = holiday; 633 mHolidayString = holiday;
622 634
623 if ( !holiday.isEmpty() ) { 635 if ( !holiday.isEmpty() ) {
624 setHoliday( true ); 636 setHoliday( true );
625 } 637 }
626} 638}
627 639
628void MonthViewCell::startUpdateCell() 640void MonthViewCell::startUpdateCell()
629{ 641{
630 642
631 mdayCount = 0; 643 mdayCount = 0;
632 setFocusPolicy(NoFocus); 644 setFocusPolicy(NoFocus);
633 if ( !mMonthView->isUpdatePossible() ) 645 if ( !mMonthView->isUpdatePossible() )
634 return; 646 return;
635 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 647 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
636 while ( mitem ) { 648 while ( mitem ) {
637 mitem->setBlockRepaint( true ); 649 mitem->setBlockRepaint( true );
638 mitem = (MonthViewItem *)mitem->next(); 650 mitem = (MonthViewItem *)mitem->next();
639 } 651 }
640 if ( mAvailItemList.count() > 20 ) { 652 if ( mAvailItemList.count() > 20 ) {
641 mAvailItemList.setAutoDelete( true ); 653 mAvailItemList.setAutoDelete( true );
642 mAvailItemList.clear(); 654 mAvailItemList.clear();
643 mAvailItemList.setAutoDelete( false ); 655 mAvailItemList.setAutoDelete( false );
644 clear(); 656 clear();
645 } 657 }
646 658
647 setPrimary( mDate.month()%2 ); 659 setPrimary( mDate.month()%2 );
648 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 660 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
649 if ( mDate == QDate::currentDate() ) { 661 if ( mDate == QDate::currentDate() ) {
650 setLineWidth( 3 ); 662 setLineWidth( 3 );
651 } else { 663 } else {
652 setLineWidth( 1 ); 664 setLineWidth( 1 );
653 } 665 }
654 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 666 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
655 //clear(); 667 //clear();
656 while ( CurrentAvailItem ) { 668 while ( CurrentAvailItem ) {
657 MonthViewItem *item = CurrentAvailItem; 669 MonthViewItem *item = CurrentAvailItem;
670 //item->setHighlightedFalse();
671 item->clearData();
658 CurrentAvailItem = (MonthViewItem *)item->next(); 672 CurrentAvailItem = (MonthViewItem *)item->next();
659 mAvailItemList.append( item ); 673 mAvailItemList.append( item );
660 takeItem ( item ); 674 takeItem ( item );
661 } 675 }
662 676
663#ifdef DESKTOP_VERSION 677#ifdef DESKTOP_VERSION
664 QToolTip::remove(this); 678 QToolTip::remove(this);
665#endif 679#endif
666 mToolTip.clear(); 680 mToolTip.clear();
667 //qApp->processEvents(); 681 //qApp->processEvents();
668#if 0 682#if 0
669 if ( !mHolidayString.isEmpty() ) { 683 if ( !mHolidayString.isEmpty() ) {
670 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 684 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
671 item->setPalette( mHolidayPalette ); 685 item->setPalette( mHolidayPalette );
672 insertItem( item ); 686 insertItem( item );
673 mToolTip.append ( mHolidayString ); 687 mToolTip.append ( mHolidayString );
674 } 688 }
675#endif 689#endif
676} 690}
677 691
678int MonthViewCell::insertEvent(Event *event) 692int MonthViewCell::insertEvent(Event *event)
679{ 693{
680 bool useToolTips = true; 694 bool useToolTips = true;
681#ifndef DESKTOP_VERSION 695#ifndef DESKTOP_VERSION
682 useToolTips = false; 696 useToolTips = false;
683#endif 697#endif
684 QString mToolTipText; 698 QString mToolTipText;
685 setFocusPolicy(WheelFocus); 699 setFocusPolicy(WheelFocus);
686 if ( !(event->doesRecur() == Recurrence::rNone) ) { 700 if ( !(event->doesRecur() == Recurrence::rNone) ) {
687 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 701 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
688 return mdayCount; 702 return mdayCount;
689 else 703 else
690 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 704 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
691 return mdayCount; 705 return mdayCount;
692 } 706 }
693 707
694 if ( event->isHoliday()) { 708 if ( event->isHoliday()) {
695 setHoliday( true ); 709 setHoliday( true );
696 if ( mDate.dayOfWeek() == 7 ) 710 if ( mDate.dayOfWeek() == 7 )
697 setLineWidth( 3 ); 711 setLineWidth( 3 );
698 } 712 }
699 QString text; 713 QString text;
700 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 714 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
701 if (event->isMultiDay()) { 715 if (event->isMultiDay()) {
702 QString prefix = "<->";multiday = 2; 716 QString prefix = "<->";multiday = 2;
703 QString time; 717 QString time;
704 if ( event->doesRecur() ) { 718 if ( event->doesRecur() ) {
705 if ( event->recursOn( mDate) ) { 719 if ( event->recursOn( mDate) ) {
706 prefix ="->" ;multiday = 1; 720 prefix ="->" ;multiday = 1;
707 } 721 }
708 else { 722 else {
709 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 723 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
710 if ( event->recursOn( mDate.addDays( -days)) ) { 724 if ( event->recursOn( mDate.addDays( -days)) ) {
711 prefix ="<-" ;multiday = 3; 725 prefix ="<-" ;multiday = 3;
712 } 726 }
713 } 727 }
714 728
715 } else { 729 } else {
716 if (mDate == event->dtStart().date()) { 730 if (mDate == event->dtStart().date()) {
717 prefix ="->" ;multiday = 1; 731 prefix ="->" ;multiday = 1;
718 } else if (mDate == event->dtEnd().date()) { 732 } else if (mDate == event->dtEnd().date()) {
719 prefix ="<-" ;multiday = 3; 733 prefix ="<-" ;multiday = 3;
720 } 734 }
721 } 735 }
722 if ( !event->doesFloat() ) { 736 if ( !event->doesFloat() ) {
723 if ( mDate == event->dtStart().date () ) 737 if ( mDate == event->dtStart().date () )
724 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 738 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
725 else if ( mDate == event->dtEnd().date () ) 739 else if ( mDate == event->dtEnd().date () )
726 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 740 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
727 741
728 } 742 }
729 text = time + event->summary(); 743 text = time + event->summary();
730 if ( useToolTips ) 744 if ( useToolTips )
731 mToolTipText += prefix + text; 745 mToolTipText += prefix + text;
732 } else { 746 } else {
733 if (event->doesFloat()) { 747 if (event->doesFloat()) {
734 text = event->summary(); 748 text = event->summary();
735 if ( useToolTips ) 749 if ( useToolTips )
736 mToolTipText += text; 750 mToolTipText += text;
737 } 751 }
738 else { 752 else {
739 text = KGlobal::locale()->formatTime(event->dtStart().time()); 753 text = KGlobal::locale()->formatTime(event->dtStart().time());
740 text += " " + event->summary(); 754 text += " " + event->summary();
741 if ( useToolTips ) 755 if ( useToolTips )
742 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 756 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
743 } 757 }
744 } 758 }
745 if ( useToolTips && ! event->location().isEmpty() ) { 759 if ( useToolTips && ! event->location().isEmpty() ) {
746 mToolTipText += " (" + event->location() +")"; 760 mToolTipText += " (" + event->location() +")";
747 } 761 }
748 MonthViewItem *item ; 762 MonthViewItem *item ;
749 763
750 if ( mAvailItemList.count() ) { 764 if ( mAvailItemList.count() ) {
751 item = mAvailItemList.first(); 765 item = mAvailItemList.first();
752 mAvailItemList.remove( item ); 766 mAvailItemList.remove( item );
753 item->recycle( event, mDate, text ); 767 item->recycle( event, mDate, text );
754 } else { 768 } else {
755 item = new MonthViewItem( event, mDate, text ); 769 item = new MonthViewItem( event, mDate, text );
756 } 770 }
757 771
758 QPalette pal; 772 QPalette pal;
759 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 773 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
760 QStringList categories = event->categories(); 774 QStringList categories = event->categories();
761 QString cat = categories.first(); 775 QString cat = categories.first();
762 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 776 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
763 pal = getPalette(); 777 pal = getPalette();
764 if (cat.isEmpty()) { 778 if (cat.isEmpty()) {
765 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 779 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
766 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); 780 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() ));
767 } else { 781 } else {
768 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 782 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
769 } 783 }
770 784
771 } else { 785 } else {
772 if (cat.isEmpty()) { 786 if (cat.isEmpty()) {
773 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 787 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
774 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); 788 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() ));
775 } else { 789 } else {
776 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 790 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
777 } 791 }
778 } 792 }
779 793
780 } else { 794 } else {
781 pal = mStandardPalette ; 795 pal = mStandardPalette ;
782 } 796 }
783 item->setPalette( pal ); 797 item->setPalette( pal );
784 item->setRecur( event->recurrence()->doesRecur() ); 798 item->setRecur( event->recurrence()->doesRecur() );
785 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); 799 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
786 item->setMoreInfo( event->description().length() > 0 ); 800 item->setMoreInfo( event->description().length() > 0 );
787#ifdef DESKTOP_VERSION 801#ifdef DESKTOP_VERSION
788 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 802 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
789 KOPrefs::instance()->email()); 803 KOPrefs::instance()->email());
790 if ( me != 0 ) { 804 if ( me != 0 ) {
791 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 805 if ( me->status() == Attendee::NeedsAction && me->RSVP())
792 item->setReply(true && multiday < 2); 806 item->setReply(true && multiday < 2);
793 else 807 else
794 item->setReply(false); 808 item->setReply(false);
795 } else 809 } else
796 item->setReply(false); 810 item->setReply(false);
797#endif 811#endif
798 812
799 item->setMultiDay( multiday ); 813 item->setMultiDay( multiday );
800 if ( multiday ) { 814 if ( multiday ) {
801 insertItem( item ,mdayCount); 815 insertItem( item ,mdayCount);
802 ++mdayCount; 816 ++mdayCount;
803 } else { 817 } else {
804 uint i = mdayCount; 818 uint i = mdayCount;
805 uint pos = mdayCount; 819 uint pos = mdayCount;
806 uint itcount = count(); 820 uint itcount = count();
807 if ( itcount > 1000 ) { 821 if ( itcount > 1000 ) {
808 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); 822 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount);
809 itcount = 0; 823 itcount = 0;
810 } 824 }
811 for ( i = pos; i < itcount;++i ) { 825 for ( i = pos; i < itcount;++i ) {
812 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); 826 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount );
813 QListBoxItem* it = this->item ( i ); 827 QListBoxItem* it = this->item ( i );
814 if ( it && text < it->text() ) { 828 if ( it && text < it->text() ) {
815 pos = i; 829 pos = i;
816 break; 830 break;
817 } 831 }
818 ++pos; 832 ++pos;
819 } 833 }
820 insertItem( item ,pos); 834 insertItem( item ,pos);
821 } 835 }
822 if ( useToolTips ) { 836 if ( useToolTips ) {
823 mToolTip.append( mToolTipText ); 837 mToolTip.append( mToolTipText );
824 } 838 }
825 return mdayCount; 839 return mdayCount;
826} 840}
827void MonthViewCell::insertTodo(Todo *todo) 841void MonthViewCell::insertTodo(Todo *todo)
828{ 842{
829 setFocusPolicy(WheelFocus); 843 setFocusPolicy(WheelFocus);
830 QString text; 844 QString text;
831 if (todo->hasDueDate()) { 845 if (todo->hasDueDate()) {
832 if (!todo->doesFloat()) { 846 if (!todo->doesFloat()) {
833 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 847 text += KGlobal::locale()->formatTime(todo->dtDue().time());
834 text += " "; 848 text += " ";
835 } 849 }
836 } 850 }
837 text += todo->summary(); 851 text += todo->summary();
838 MonthViewItem *item ; 852 MonthViewItem *item ;
839 if ( mAvailItemList.count() ) { 853 if ( mAvailItemList.count() ) {
840 item = mAvailItemList.first(); 854 item = mAvailItemList.first();
841 mAvailItemList.remove( item ); 855 mAvailItemList.remove( item );
842 item->recycle( todo, mDate, text ); 856 item->recycle( todo, mDate, text );
843 } else { 857 } else {
844 item = new MonthViewItem( todo, mDate, text ); 858 item = new MonthViewItem( todo, mDate, text );
845 } 859 }
846 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 860 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
847 //item->setPalette( mStandardPalette ); 861 //item->setPalette( mStandardPalette );
848 QPalette pal; 862 QPalette pal;
849 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 863 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
850 QStringList categories = todo->categories(); 864 QStringList categories = todo->categories();
851 QString cat = categories.first(); 865 QString cat = categories.first();
852 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 866 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
853 pal = getPalette(); 867 pal = getPalette();
854 if (cat.isEmpty()) { 868 if (cat.isEmpty()) {
855 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 869 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
856 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); 870 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
857 } else { 871 } else {
858 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 872 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
859 } 873 }
860 874
861 } else { 875 } else {
862 if (cat.isEmpty()) { 876 if (cat.isEmpty()) {
863 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 877 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
864 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); 878 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() ));
865 } else { 879 } else {
866 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 880 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
867 } 881 }
868 } 882 }
869 883
870 } else { 884 } else {
871 pal = mStandardPalette ; 885 pal = mStandardPalette ;
872 } 886 }
873 item->setPalette( pal ); 887 item->setPalette( pal );
874 item->setRecur( todo->recurrence()->doesRecur() ); 888 item->setRecur( todo->recurrence()->doesRecur() );
875 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 889 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
876 item->setMoreInfo( todo->description().length() > 0 ); 890 item->setMoreInfo( todo->description().length() > 0 );
877 insertItem( item , count()); 891 insertItem( item , count());
878#ifdef DESKTOP_VERSION 892#ifdef DESKTOP_VERSION
879 mToolTip.append( text ); 893 mToolTip.append( text );
880#endif 894#endif
881} 895}
882void MonthViewCell::repaintfinishUpdateCell() 896void MonthViewCell::repaintfinishUpdateCell()
883{ 897{
884 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 898 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
885 while ( mitem ) { 899 while ( mitem ) {
886 mitem->setBlockRepaint( false ); 900 mitem->setBlockRepaint( false );
887 updateItem ( mitem ); 901 updateItem ( mitem );
888 mitem = (MonthViewItem *)mitem->next(); 902 mitem = (MonthViewItem *)mitem->next();
889 } 903 }
890} 904}
891void MonthViewCell::finishUpdateCell() 905void MonthViewCell::finishUpdateCell()
892{ 906{
893 907
894 908
895 909
896#ifdef DESKTOP_VERSION 910#ifdef DESKTOP_VERSION
897 if (mToolTip.count() > 0 ) { 911 if (mToolTip.count() > 0 ) {
898 mToolTip.sort(); 912 mToolTip.sort();
899 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 913 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
900 } 914 }
901#endif 915#endif
902 //sort(); 916 //sort();
903 //setMyPalette(); 917 //setMyPalette();
904 setMyPalette(); 918 setMyPalette();
905 919
906 resizeEvent( 0 ); 920 resizeEvent( 0 );
907 921
908} 922}
909void MonthViewCell::updateCell() 923void MonthViewCell::updateCell()
910{ 924{
911 if ( !mMonthView->isUpdatePossible() ) 925 if ( !mMonthView->isUpdatePossible() )
912 return; 926 return;
913 startUpdateCell(); 927 startUpdateCell();
914 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 928 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
915 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 929 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
916 Event *event; 930 Event *event;
917 for( event = events.first(); event; event = events.next() ) { // for event 931 for( event = events.first(); event; event = events.next() ) { // for event
918 insertEvent(event); 932 insertEvent(event);
919 } 933 }
920 // insert due todos 934 // insert due todos
921 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 935 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
922 Todo *todo; 936 Todo *todo;
923 for(todo = todos.first(); todo; todo = todos.next()) { 937 for(todo = todos.first(); todo; todo = todos.next()) {
924 insertTodo( todo ); 938 insertTodo( todo );
925 } 939 }
926 finishUpdateCell(); 940 finishUpdateCell();
927 // if ( isVisible()) 941 // if ( isVisible())
928 //qApp->processEvents(); 942 //qApp->processEvents();
929} 943}
930 944
931void MonthViewCell::updateConfig( bool bigFont ) // = false 945void MonthViewCell::updateConfig( bool bigFont ) // = false
932{ 946{
933 947
934 if ( bigFont ) { 948 if ( bigFont ) {
935 QFont fo = KOPrefs::instance()->mMonthViewFont; 949 QFont fo = KOPrefs::instance()->mMonthViewFont;
936 int ps = fo.pointSize() + 2; 950 int ps = fo.pointSize() + 2;
937 if ( ps < 18 ) 951 if ( ps < 18 )
938 ps += 2; 952 ps += 2;
939 fo.setPointSize( ps ); 953 fo.setPointSize( ps );
940 setFont( fo ); 954 setFont( fo );
941 } else 955 } else
942 setFont( KOPrefs::instance()->mMonthViewFont ); 956 setFont( KOPrefs::instance()->mMonthViewFont );
943 957
944 QFontMetrics fm( font() ); 958 QFontMetrics fm( font() );
945 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 959 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
946 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 960 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
947 mHolidayPalette = mStandardPalette; 961 mHolidayPalette = mStandardPalette;
948 mPrimaryPalette = mStandardPalette; 962 mPrimaryPalette = mStandardPalette;
949 mNonPrimaryPalette = mStandardPalette; 963 mNonPrimaryPalette = mStandardPalette;
950 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 964 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
951 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 965 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
952 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 966 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
953 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 967 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
954 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 968 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
955 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 969 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
956 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 970 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
957 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 971 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
958 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 972 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
959 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 973 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
960 } 974 }
961 //updateCell(); 975 //updateCell();
962} 976}
963 977
964void MonthViewCell::enableScrollBars( bool enabled ) 978void MonthViewCell::enableScrollBars( bool enabled )
965{ 979{
966 980
967 return; 981 return;
968 if ( enabled ) { 982 if ( enabled ) {
969 QListBoxItem *fi = firstItem (); 983 QListBoxItem *fi = firstItem ();
970 if (fi ) { 984 if (fi ) {
971 int ihei = fi->height( this ); 985 int ihei = fi->height( this );
972 int hei = numRows () * ihei; 986 int hei = numRows () * ihei;
973 if ( hei < height() - horizontalScrollBar()->height () ) { 987 if ( hei < height() - horizontalScrollBar()->height () ) {
974 setVScrollBarMode(QScrollView::AlwaysOff); 988 setVScrollBarMode(QScrollView::AlwaysOff);
975 } 989 }
976 else 990 else
977 setVScrollBarMode(QScrollView::Auto); 991 setVScrollBarMode(QScrollView::Auto);
978 if ( ihei *3 > height() ) { 992 if ( ihei *3 > height() ) {
979 setHScrollBarMode(QScrollView::AlwaysOff); 993 setHScrollBarMode(QScrollView::AlwaysOff);
980 } 994 }
981 else { 995 else {
982 setHScrollBarMode(QScrollView::Auto); 996 setHScrollBarMode(QScrollView::Auto);
983 } 997 }
984 } else { 998 } else {
985 setVScrollBarMode(QScrollView::Auto); 999 setVScrollBarMode(QScrollView::Auto);
986 setHScrollBarMode(QScrollView::Auto); 1000 setHScrollBarMode(QScrollView::Auto);
987 } 1001 }
988 } else { 1002 } else {
989 setVScrollBarMode(QScrollView::AlwaysOff); 1003 setVScrollBarMode(QScrollView::AlwaysOff);
990 setHScrollBarMode(QScrollView::AlwaysOff); 1004 setHScrollBarMode(QScrollView::AlwaysOff);
991 } 1005 }
992} 1006}
993 1007
994Incidence *MonthViewCell::selectedIncidence() 1008Incidence *MonthViewCell::selectedIncidence()
995{ 1009{
996 int index = currentItem(); 1010 int index = currentItem();
997 if ( index < 0 ) return 0; 1011 if ( index < 0 ) return 0;
998 1012
999 MonthViewItem *mitem = 1013 MonthViewItem *mitem =
1000 static_cast<MonthViewItem *>( item( index ) ); 1014 static_cast<MonthViewItem *>( item( index ) );
1001 1015
1002 if ( !mitem ) return 0; 1016 if ( !mitem ) return 0;
1003 1017
1004 return mitem->incidence(); 1018 return mitem->incidence();
1005} 1019}
1006 1020
1007QDate MonthViewCell::selectedIncidenceDate() 1021QDate MonthViewCell::selectedIncidenceDate()
1008{ 1022{
1009 QDate qd; 1023 QDate qd;
1010 int index = currentItem(); 1024 int index = currentItem();
1011 if ( index < 0 ) return qd; 1025 if ( index < 0 ) return qd;
1012 1026
1013 MonthViewItem *mitem = 1027 MonthViewItem *mitem =
1014 static_cast<MonthViewItem *>( item( index ) ); 1028 static_cast<MonthViewItem *>( item( index ) );
1015 1029
1016 if ( !mitem ) return qd; 1030 if ( !mitem ) return qd;
1017 1031
1018 return mitem->incidenceDate(); 1032 return mitem->incidenceDate();
1019} 1033}
1020 1034
1021void MonthViewCell::deselect() 1035void MonthViewCell::deselect()
1022{ 1036{
1023 clearSelection(); 1037 clearSelection();
1024 enableScrollBars( false ); 1038 enableScrollBars( false );
1025 // updateCell(); 1039 // updateCell();
1026} 1040}
1027void MonthViewCell::select() 1041void MonthViewCell::select()
1028{ 1042{
1029 ;// updateCell(); 1043 ;// updateCell();
1030} 1044}
1031 1045
1032void MonthViewCell::resizeEvent ( QResizeEvent * e ) 1046void MonthViewCell::resizeEvent ( QResizeEvent * e )
1033{ 1047{
1034 if ( !mMonthView->isUpdatePossible() ) 1048 if ( !mMonthView->isUpdatePossible() )
1035 return; 1049 return;
1036 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 1050 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
1037 deselect(); 1051 deselect();
1038 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 1052 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1039 1053
1040 QString text; 1054 QString text;
1041 mLabel->setText( text ); 1055 mLabel->setText( text );
1042 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1056 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1043 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1057 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1044 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1058 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1045 mLabel->resize( mLabelBigSize ); 1059 mLabel->resize( mLabelBigSize );
1046 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1060 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1047 } else { 1061 } else {
1048 mLabel->resize( mLabelSize ); 1062 mLabel->resize( mLabelSize );
1049 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1063 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1050 } 1064 }
1051 mLabel->setText( text ); 1065 mLabel->setText( text );
1052 1066
1053 int size = height() - mLabel->height() - lineWidth()-1; 1067 int size = height() - mLabel->height() - lineWidth()-1;
1054 //qDebug("LW %d ", lineWidth()); 1068 //qDebug("LW %d ", lineWidth());
1055 if ( size > 0 ) 1069 if ( size > 0 )
1056 verticalScrollBar()->setMaximumHeight( size ); 1070 verticalScrollBar()->setMaximumHeight( size );
1057 size = width() - mLabel->width() -lineWidth()-1; 1071 size = width() - mLabel->width() -lineWidth()-1;
1058 if ( size > 0 ) 1072 if ( size > 0 )
1059 horizontalScrollBar()->setMaximumWidth( size ); 1073 horizontalScrollBar()->setMaximumWidth( size );
1060 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1074 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1061 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1075 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1062 // mItemList->resize ( width(), height () ); 1076 // mItemList->resize ( width(), height () );
1063 if ( e ) 1077 if ( e )
1064 KNoScrollListBox::resizeEvent ( e ); 1078 KNoScrollListBox::resizeEvent ( e );
1065} 1079}
1066 1080
1067void MonthViewCell::defaultAction( QListBoxItem *item ) 1081void MonthViewCell::defaultAction( QListBoxItem *item )
1068{ 1082{
1069 1083
1070 if ( !item ) { 1084 if ( !item ) {
1071 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1085 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1072 emit newEventSignal( dt ); 1086 emit newEventSignal( dt );
1073 return; 1087 return;
1074 } 1088 }
1075 1089
1076 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1090 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1077 Incidence *incidence = eventItem->incidence(); 1091 Incidence *incidence = eventItem->incidence();
1078 if ( incidence ) mMonthView->defaultAction( incidence ); 1092 if ( incidence ) mMonthView->defaultAction( incidence );
1079} 1093}
1080void MonthViewCell::showDay() 1094void MonthViewCell::showDay()
1081{ 1095{
1082 emit showDaySignal( date() ); 1096 emit showDaySignal( date() );
1083} 1097}
1084void MonthViewCell::newEvent() 1098void MonthViewCell::newEvent()
1085{ 1099{
1086 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1100 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1087 emit newEventSignal( dt ); 1101 emit newEventSignal( dt );
1088} 1102}
1089void MonthViewCell::cellClicked( QListBoxItem *item ) 1103void MonthViewCell::cellClicked( QListBoxItem *item )
1090{ 1104{
1091 mMonthView->setSelectedCell( this ); 1105 mMonthView->setSelectedCell( this );
1092 if ( item == 0 ) { 1106 if ( item == 0 ) {
1093 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1107 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1094 emit newEventSignal( dt ); 1108 emit newEventSignal( dt );
1095 return; 1109 return;
1096 } 1110 }
1097 1111
1098} 1112}
1099 1113
1100void MonthViewCell::contextMenu( QListBoxItem *item ) 1114void MonthViewCell::contextMenu( QListBoxItem *item )
1101{ 1115{
1102 mMonthView->setPopupCell( this ); 1116 mMonthView->setPopupCell( this );
1103 if ( !item ) { 1117 if ( !item ) {
1104 mMonthView->showContextMenu( 0 ); 1118 mMonthView->showContextMenu( 0 );
1105 return; 1119 return;
1106 } 1120 }
1107 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1121 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1108 Incidence *incidence = eventItem->incidence(); 1122 Incidence *incidence = eventItem->incidence();
1109 if ( incidence ) mMonthView->showContextMenu( incidence ); 1123 if ( incidence ) mMonthView->showContextMenu( incidence );
1110} 1124}
1111 1125
1112void MonthViewCell::selection( QListBoxItem *item ) 1126void MonthViewCell::selection( QListBoxItem *item )
1113{ 1127{
1114 if ( !item ) { 1128 if ( !item ) {
1115 emit highligtIncidence( 0 , this, 0 ); 1129 emit highligtIncidence( 0 , this, 0 );
1116 return; 1130 return;
1117 } 1131 }
1118 MonthViewItem * it = (static_cast<MonthViewItem *>( item )); 1132 MonthViewItem * it = (static_cast<MonthViewItem *>( item ));
1119 emit highligtIncidence( it->incidence(), this, it->multiDay() ); 1133 emit highligtIncidence( it->incidence(), this, it->multiDay() );
1120 mMonthView->setSelectedCell( this ); 1134 mMonthView->setSelectedCell( this );
1121} 1135}
1122 1136
1123void MonthViewCell::deHightLight() 1137void MonthViewCell::deHightLight()
1124{ 1138{
1125 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 1139 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
1126 while ( mitem ) { 1140 while ( mitem ) {
1127 if ( mitem->setHighlightedFalse() ) 1141 if ( mitem->setHighlightedFalse() )
1128 updateItem ( mitem ); 1142 updateItem ( mitem );
1129 mitem = (MonthViewItem *)mitem->next(); 1143 mitem = (MonthViewItem *)mitem->next();
1130 } 1144 }
1131} 1145}
1132// returns true if no inc found 1146// returns true if no inc found
1133bool MonthViewCell::doHightLight( Incidence * inc ) 1147bool MonthViewCell::doHightLight( Incidence * inc )
1134{ 1148{
1135 1149
1136 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 1150 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
1137 while ( mitem ) { 1151 while ( mitem ) {
1138 if ( mitem->incidence() == inc ) { 1152 if ( mitem->incidence() == inc ) {
1139 if ( mitem->setHighlighted( inc ) ) 1153 if ( mitem->setHighlighted( inc ) )
1140 updateItem ( mitem ); 1154 updateItem ( mitem );
1141 return false; 1155 return false;
1142 } 1156 }
1143 mitem = (MonthViewItem *)mitem->next(); 1157 mitem = (MonthViewItem *)mitem->next();
1144 } 1158 }
1145 return true; 1159 return true;
1146} 1160}
1147// ******************************************************************************* 1161// *******************************************************************************
1148// ******************************************************************************* 1162// *******************************************************************************
1149// ******************************************************************************* 1163// *******************************************************************************
1150 1164
1151 1165
1152KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1166KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1153 : KOEventView( calendar, parent, name ), 1167 : KOEventView( calendar, parent, name ),
1154 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1168 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1155 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1169 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1156{ 1170{
1157 mFlagKeyPressed = false; 1171 mFlagKeyPressed = false;
1158 mShortDayLabelsM = false; 1172 mShortDayLabelsM = false;
1159 mShortDayLabelsW = false; 1173 mShortDayLabelsW = false;
1160 skipResize = false; 1174 skipResize = false;
1161 clPending = true; 1175 clPending = true;
1162 mPopupCell = 0; 1176 mPopupCell = 0;
1163 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1177 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1164 mWidStack = new QWidgetStack( this ); 1178 mWidStack = new QWidgetStack( this );
1165 QVBoxLayout* hb = new QVBoxLayout( this ); 1179 QVBoxLayout* hb = new QVBoxLayout( this );
1166 mMonthView = new QWidget( mWidStack ); 1180 mMonthView = new QWidget( mWidStack );
1167 mWeekView = new QWidget( mWidStack ); 1181 mWeekView = new QWidget( mWidStack );
1168#if QT_VERSION >= 0x030000 1182#if QT_VERSION >= 0x030000
1169 mWidStack->addWidget(mMonthView ); 1183 mWidStack->addWidget(mMonthView );
1170 mWidStack->addWidget(mWeekView ); 1184 mWidStack->addWidget(mWeekView );
1171#else 1185#else
1172 mWidStack->addWidget( mMonthView, 1 ); 1186 mWidStack->addWidget( mMonthView, 1 );
1173 mWidStack->addWidget( mWeekView , 1 ); 1187 mWidStack->addWidget( mWeekView , 1 );
1174#endif 1188#endif
1175 hb->addWidget( mNavigatorBar ); 1189 hb->addWidget( mNavigatorBar );
1176 hb->addWidget( mWidStack ); 1190 hb->addWidget( mWidStack );
1177 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1191 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1178 updatePossible = false; 1192 updatePossible = false;
1179 //updatePossible = true; 1193 //updatePossible = true;
1180 mCells.setAutoDelete( true ); 1194 mCells.setAutoDelete( true );
1181 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1195 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1182 mDayLabels.resize( mDaysPerWeek ); 1196 mDayLabels.resize( mDaysPerWeek );
1183 mDayLabelsW.resize( mDaysPerWeek ); 1197 mDayLabelsW.resize( mDaysPerWeek );
1184 QFont bfont = font(); 1198 QFont bfont = font();
1185 if ( QApplication::desktop()->width() < 650 ) { 1199 if ( QApplication::desktop()->width() < 650 ) {
1186 bfont.setPointSize( bfont.pointSize() - 2 ); 1200 bfont.setPointSize( bfont.pointSize() - 2 );
1187 } 1201 }
1188 bfont.setBold( true ); 1202 bfont.setBold( true );
1189 int i; 1203 int i;
1190 1204
1191 for( i = 0; i < mDaysPerWeek; i++ ) { 1205 for( i = 0; i < mDaysPerWeek; i++ ) {
1192 QLabel *label = new QLabel( mMonthView ); 1206 QLabel *label = new QLabel( mMonthView );
1193 label->setFont(bfont); 1207 label->setFont(bfont);
1194 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1208 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1195 label->setLineWidth(1); 1209 label->setLineWidth(1);
1196 label->setAlignment(AlignCenter); 1210 label->setAlignment(AlignCenter);
1197 mDayLabels.insert( i, label ); 1211 mDayLabels.insert( i, label );
1198 label = new QLabel( mWeekView ); 1212 label = new QLabel( mWeekView );
1199 label->setFont(bfont); 1213 label->setFont(bfont);
1200 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1214 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1201 label->setLineWidth(1); 1215 label->setLineWidth(1);
1202 label->setAlignment(AlignCenter); 1216 label->setAlignment(AlignCenter);
1203 mDayLabelsW.insert( i, label ); 1217 mDayLabelsW.insert( i, label );
1204 } 1218 }
1205 1219
1206 bfont.setBold( false ); 1220 bfont.setBold( false );
1207 mWeekLabels.resize( mNumWeeks+1 ); 1221 mWeekLabels.resize( mNumWeeks+1 );
1208 mWeekLabelsW.resize( 2 ); 1222 mWeekLabelsW.resize( 2 );
1209 for( i = 0; i < mNumWeeks+1; i++ ) { 1223 for( i = 0; i < mNumWeeks+1; i++ ) {
1210 KOWeekButton *label = new KOWeekButton( mMonthView ); 1224 KOWeekButton *label = new KOWeekButton( mMonthView );
1211 label->setFocusPolicy(NoFocus); 1225 label->setFocusPolicy(NoFocus);
1212 label->setFont(bfont); 1226 label->setFont(bfont);
1213 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1227 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1214 label->setFlat(true); 1228 label->setFlat(true);
1215 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1229 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1216 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1230 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1217 //label->setLineWidth(1); 1231 //label->setLineWidth(1);
1218 //label->setAlignment(AlignCenter); 1232 //label->setAlignment(AlignCenter);
1219 mWeekLabels.insert( i, label ); 1233 mWeekLabels.insert( i, label );
1220 } 1234 }
1221 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1235 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1222 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1236 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1223 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1237 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1224 1238
1225 for( i = 0; i < 1+1; i++ ) { 1239 for( i = 0; i < 1+1; i++ ) {
1226 KOWeekButton *label = new KOWeekButton( mWeekView ); 1240 KOWeekButton *label = new KOWeekButton( mWeekView );
1227 label->setFocusPolicy(NoFocus); 1241 label->setFocusPolicy(NoFocus);
1228 label->setFont(bfont); 1242 label->setFont(bfont);
1229 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1243 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1230 label->setFlat(true); 1244 label->setFlat(true);
1231 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1245 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1232 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1246 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1233 //label->setLineWidth(1); 1247 //label->setLineWidth(1);
1234 //label->setAlignment(AlignCenter); 1248 //label->setAlignment(AlignCenter);
1235 mWeekLabelsW.insert( i, label ); 1249 mWeekLabelsW.insert( i, label );
1236 } 1250 }
1237 mWeekLabelsW[1]->setText( i18n("W")); 1251 mWeekLabelsW[1]->setText( i18n("W"));
1238 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1252 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1239 1253
1240 1254
1241 int row, col; 1255 int row, col;
1242 mCells.resize( mNumCells ); 1256 mCells.resize( mNumCells );
1243 for( row = 0; row < mNumWeeks; ++row ) { 1257 for( row = 0; row < mNumWeeks; ++row ) {
1244 for( col = 0; col < mDaysPerWeek; ++col ) { 1258 for( col = 0; col < mDaysPerWeek; ++col ) {
1245 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1259 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1246 mCells.insert( row * mDaysPerWeek + col, cell ); 1260 mCells.insert( row * mDaysPerWeek + col, cell );
1247 1261
1248 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1262 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1249 SLOT( defaultAction( Incidence * ) ) ); 1263 SLOT( defaultAction( Incidence * ) ) );
1250 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1264 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1251 SIGNAL( newEventSignal( QDateTime ) ) ); 1265 SIGNAL( newEventSignal( QDateTime ) ) );
1252 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1266 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1253 SIGNAL( showDaySignal( QDate ) ) ); 1267 SIGNAL( showDaySignal( QDate ) ) );
1254 connect( cell, SIGNAL( nextCell() ), 1268 connect( cell, SIGNAL( nextCell() ),
1255 SLOT( nextCell() ) ); 1269 SLOT( nextCell() ) );
1256 connect( cell, SIGNAL( prevCell() ), 1270 connect( cell, SIGNAL( prevCell() ),
1257 SLOT( prevCell() ) ); 1271 SLOT( prevCell() ) );
1258 connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), 1272 connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ),
1259 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); 1273 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
1260 } 1274 }
1261 } 1275 }
1262 mCellsW.resize( mDaysPerWeek ); 1276 mCellsW.resize( mDaysPerWeek );
1263 for( col = 0; col < mDaysPerWeek; ++col ) { 1277 for( col = 0; col < mDaysPerWeek; ++col ) {
1264 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1278 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1265 mCellsW.insert( col, cell ); 1279 mCellsW.insert( col, cell );
1266 1280
1267 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1281 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1268 SLOT( defaultAction( Incidence * ) ) ); 1282 SLOT( defaultAction( Incidence * ) ) );
1269 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1283 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1270 SIGNAL( newEventSignal( QDateTime ) ) ); 1284 SIGNAL( newEventSignal( QDateTime ) ) );
1271 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1285 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1272 SIGNAL( showDaySignal( QDate ) ) ); 1286 SIGNAL( showDaySignal( QDate ) ) );
1273 connect( cell, SIGNAL( nextCell() ), 1287 connect( cell, SIGNAL( nextCell() ),
1274 SLOT( nextCell() ) ); 1288 SLOT( nextCell() ) );
1275 connect( cell, SIGNAL( prevCell() ), 1289 connect( cell, SIGNAL( prevCell() ),
1276 SLOT( prevCell() ) ); 1290 SLOT( prevCell() ) );
1277 connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), 1291 connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ),
1278 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); 1292 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
1279 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1293 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1280 } 1294 }
1281 1295
1282 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1296 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1283 mContextMenu = eventPopup(); 1297 mContextMenu = eventPopup();
1284 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1298 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1285 i18n("New Event..."),this, 1299 i18n("New Event..."),this,
1286 SLOT(slotNewEvent()),false); 1300 SLOT(slotNewEvent()),false);
1287 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1301 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1288 i18n("New Todo..."),this, 1302 i18n("New Todo..."),this,
1289 SLOT(slotNewTodo()),false); 1303 SLOT(slotNewTodo()),false);
1290 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1304 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1291 i18n("Journal"),this, 1305 i18n("Journal"),this,
1292 SLOT(slotEditJournal()),false); 1306 SLOT(slotEditJournal()),false);
1293 1307
1294 1308
1295 1309
1296 QString pathString = ""; 1310 QString pathString = "";
1297 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1311 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1298 if ( QApplication::desktop()->width() < 480 ) 1312 if ( QApplication::desktop()->width() < 480 )
1299 pathString += "icons16/"; 1313 pathString += "icons16/";
1300 } else 1314 } else
1301 pathString += "iconsmini/"; 1315 pathString += "iconsmini/";
1302 mNewItemMenu = new QPopupMenu( this ); 1316 mNewItemMenu = new QPopupMenu( this );
1303 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1317 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1304 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1318 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1305 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1319 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1306 1320
1307 // updateConfig(); //useless here... 1321 // updateConfig(); //useless here...
1308 // ... but we need mWidthLongDayLabel computed 1322 // ... but we need mWidthLongDayLabel computed
1309 QFontMetrics fontmetric(mDayLabels[0]->font()); 1323 QFontMetrics fontmetric(mDayLabels[0]->font());
1310 mWidthLongDayLabel = 0; 1324 mWidthLongDayLabel = 0;
1311 for (int i = 0; i < 7; i++) { 1325 for (int i = 0; i < 7; i++) {
1312 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1326 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1313 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1327 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1314 } 1328 }
1315 1329
1316 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1330 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1317 1331
1318#if 0 1332#if 0
1319 if ( mShowWeekView ) 1333 if ( mShowWeekView )
1320 mWidStack->raiseWidget( mWeekView ); 1334 mWidStack->raiseWidget( mWeekView );
1321 else 1335 else
1322 mWidStack->raiseWidget( mMonthView ); 1336 mWidStack->raiseWidget( mMonthView );
1323#endif 1337#endif
1324 1338
1325 emit incidenceSelected( 0 ); 1339 emit incidenceSelected( 0 );
1326 1340
1327 mComputeLayoutTimer = new QTimer( this ); 1341 mComputeLayoutTimer = new QTimer( this );
1328 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1342 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1329 1343
1330 1344
1331#ifndef DESKTOP_VERSION 1345#ifndef DESKTOP_VERSION
1332 resize( QApplication::desktop()->size() ); 1346 resize( QApplication::desktop()->size() );
1333#else 1347#else
1334 resize(640, 480 ); 1348 resize(640, 480 );
1335 updatePossible = true; 1349 updatePossible = true;
1336#endif 1350#endif
1337 computeLayout(); 1351 computeLayout();
1338 1352
1339 if ( mShowWeekView ) 1353 if ( mShowWeekView )
1340 mWidStack->raiseWidget( mWeekView ); 1354 mWidStack->raiseWidget( mWeekView );
1341 else 1355 else
1342 mWidStack->raiseWidget( mMonthView ); 1356 mWidStack->raiseWidget( mMonthView );
1343} 1357}
1344 1358
1345KOMonthView::~KOMonthView() 1359KOMonthView::~KOMonthView()
1346{ 1360{
1347 delete mContextMenu; 1361 delete mContextMenu;
1348} 1362}
1349 1363
1350void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) 1364void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday )
1351{ 1365{
1352 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); 1366 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1353 static Incidence * lastInc = 0; 1367 static Incidence * lastInc = 0;
1354 static MonthViewCell * lastCell = 0; 1368 static MonthViewCell * lastCell = 0;
1355 1369
1356 if ( lastInc == inc && lastCell == mc ) 1370 if ( lastInc == inc && lastCell == mc )
1357 return; 1371 return;
1358 lastInc = inc; 1372 lastInc = inc;
1359 lastCell = mc; 1373 lastCell = mc;
1360 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); 1374 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1361 1375
1362 bool weekview = false; 1376 bool weekview = false;
1363 int index = 0; 1377 int index = 0;
1364 for (uint i = 0; i < mCellsW.count(); ++i) { 1378 for (uint i = 0; i < mCellsW.count(); ++i) {
1365 if ( mCellsW[i] == mc ) { 1379 if ( mCellsW[i] == mc ) {
1366 weekview = true; 1380 weekview = true;
1367 index = i; 1381 index = i;
1368 break; 1382 break;
1369 } 1383 }
1370 } 1384 }
1371 QPtrVector<MonthViewCell> *cells; 1385 QPtrVector<MonthViewCell> *cells;
1372 if ( weekview ) 1386 if ( weekview )
1373 cells = &mCellsW; 1387 cells = &mCellsW;
1374 else { 1388 else {
1375 for (uint i = 0; i < mCells.count(); ++i) { 1389 for (uint i = 0; i < mCells.count(); ++i) {
1376 if ( mCells[i] == mc ) { 1390 if ( mCells[i] == mc ) {
1377 index = i; 1391 index = i;
1378 break; 1392 break;
1379 } 1393 }
1380 } 1394 }
1381 cells = &mCells; 1395 cells = &mCells;
1382 } 1396 }
1383 for (uint i = 0; i < (*cells).count(); ++i) { 1397 for (uint i = 0; i < (*cells).count(); ++i) {
1384 (*cells)[i]->deHightLight(); 1398 (*cells)[i]->deHightLight();
1385 } 1399 }
1386 if ( ! inc ) 1400 if ( ! inc )
1387 return; 1401 return;
1388 if ( mday > 1 && index > 0 ) 1402 if ( mday > 1 && index > 0 )
1389 for (int i = index-1; i >= 0; --i) { 1403 for (int i = index-1; i >= 0; --i) {
1390 //qDebug("index %d iii %d ", index, i); 1404 //qDebug("index %d iii %d ", index, i);
1391 if ( (*cells)[(uint)i]->doHightLight(inc) ) 1405 if ( (*cells)[(uint)i]->doHightLight(inc) )
1392 break; 1406 break;
1393 } 1407 }
1394 if ( mday < 3 && mday > 0 && index < (*cells).count()-1) 1408 if ( mday < 3 && mday > 0 && index < (*cells).count()-1)
1395 for (uint i = index+1; i < (*cells).count(); ++i) { 1409 for (uint i = index+1; i < (*cells).count(); ++i) {
1396 if ( (*cells)[i]->doHightLight(inc) ) 1410 if ( (*cells)[i]->doHightLight(inc) )
1397 break; 1411 break;
1398 } 1412 }
1399 1413
1400} 1414}
1401void KOMonthView::selectInternalWeekNum ( int n ) 1415void KOMonthView::selectInternalWeekNum ( int n )
1402{ 1416{
1403 switchView(); 1417 switchView();
1404 if ( !KOPrefs::instance()->mMonthViewWeek ) 1418 if ( !KOPrefs::instance()->mMonthViewWeek )
1405 emit selectMonth (); 1419 emit selectMonth ();
1406 else 1420 else
1407 emit selectWeekNum ( n ); 1421 emit selectWeekNum ( n );
1408} 1422}
1409 1423
1410int KOMonthView::currentWeek() 1424int KOMonthView::currentWeek()
1411{ 1425{
1412 if ( mShowWeekView ) 1426 if ( mShowWeekView )
1413 return mWeekLabelsW[0]->getWeekNum(); 1427 return mWeekLabelsW[0]->getWeekNum();
1414 return mWeekLabels[0]->getWeekNum(); 1428 return mWeekLabels[0]->getWeekNum();
1415} 1429}
1416void KOMonthView::switchView() 1430void KOMonthView::switchView()
1417{ 1431{
1418 if ( selectedCell( ) ) 1432 if ( selectedCell( ) )
1419 selectedCell()->deselect(); 1433 selectedCell()->deselect();
1420 mShowWeekView = !mShowWeekView; 1434 mShowWeekView = !mShowWeekView;
1421 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1435 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1422 if ( clPending ) { 1436 if ( clPending ) {
1423 computeLayout(); 1437 computeLayout();
1424 updateConfig(); 1438 updateConfig();
1425 } 1439 }
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 159af16..ac97860 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,346 +1,347 @@
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#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qintdict.h> 31#include <qintdict.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34#include <qptrvector.h> 34#include <qptrvector.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37#include <libkcal/event.h> 37#include <libkcal/event.h>
38 38
39#include "koeventview.h" 39#include "koeventview.h"
40#include "navigatorbar.h" 40#include "navigatorbar.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43class QToolTipGroup; 43class QToolTipGroup;
44#endif 44#endif
45 45
46class KNOWhatsThis; 46class KNOWhatsThis;
47class MonthViewCell; 47class MonthViewCell;
48class KOWeekButton : public QPushButton 48class KOWeekButton : public QPushButton
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 public: 51 public:
52 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 52 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
53 QPushButton( parent, name) 53 QPushButton( parent, name)
54 { 54 {
55 connect( this, SIGNAL( clicked() ), 55 connect( this, SIGNAL( clicked() ),
56 SLOT( bottonClicked() )); 56 SLOT( bottonClicked() ));
57 mNumber = -1; 57 mNumber = -1;
58 } 58 }
59 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 59 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
60 int getWeekNum() { return mNumber;} 60 int getWeekNum() { return mNumber;}
61 signals: 61 signals:
62 void selectWeekNum ( int ); 62 void selectWeekNum ( int );
63private: 63private:
64 void focusInEvent ( QFocusEvent * ){;} 64 void focusInEvent ( QFocusEvent * ){;}
65 int mNumber; 65 int mNumber;
66 void keyPressEvent ( QKeyEvent * e ) 66 void keyPressEvent ( QKeyEvent * e )
67 { 67 {
68 e->ignore(); 68 e->ignore();
69 } 69 }
70 70
71private slots : 71private slots :
72 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 72 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
73}; 73};
74 74
75class KNoScrollListBox: public QListBox 75class KNoScrollListBox: public QListBox
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 public: 78 public:
79 KNoScrollListBox(QWidget *parent=0, const char *name=0); 79 KNoScrollListBox(QWidget *parent=0, const char *name=0);
80 ~KNoScrollListBox(); 80 ~KNoScrollListBox();
81 QString getWhatsThisText(QPoint p) ; 81 QString getWhatsThisText(QPoint p) ;
82 82
83 signals: 83 signals:
84 void shiftDown(); 84 void shiftDown();
85 void shiftUp(); 85 void shiftUp();
86 void rightClick(); 86 void rightClick();
87 void nextCell(); 87 void nextCell();
88 void prevCell(); 88 void prevCell();
89 void highligtIncidence( Incidence * , MonthViewCell*, int ); 89 void highligtIncidence( Incidence * , MonthViewCell*, int );
90 90
91 protected slots: 91 protected slots:
92 void oneDown(); 92 void oneDown();
93 void keyPressEvent(QKeyEvent *); 93 void keyPressEvent(QKeyEvent *);
94 void keyReleaseEvent(QKeyEvent *); 94 void keyReleaseEvent(QKeyEvent *);
95 void mousePressEvent(QMouseEvent *); 95 void mousePressEvent(QMouseEvent *);
96 void focusInEvent ( QFocusEvent * ); 96 void focusInEvent ( QFocusEvent * );
97 void focusOutEvent ( QFocusEvent * ); 97 void focusOutEvent ( QFocusEvent * );
98 98
99 private: 99 private:
100 bool resetOnFocusIn; 100 bool resetOnFocusIn;
101 KNOWhatsThis * mWT; 101 KNOWhatsThis * mWT;
102}; 102};
103 103
104 104
105class MonthViewItem: public QListBoxItem 105class MonthViewItem: public QListBoxItem
106{ 106{
107 public: 107 public:
108 MonthViewItem( Incidence *, QDate qd, const QString & title ); 108 MonthViewItem( Incidence *, QDate qd, const QString & title );
109 void recycle( Incidence *incidence, QDate qd, const QString & s); 109 void recycle( Incidence *incidence, QDate qd, const QString & s);
110 void clearData();
110 void setRecur(bool on) { mRecur = on; } 111 void setRecur(bool on) { mRecur = on; }
111 void setAlarm(bool on) { mAlarm = on; } 112 void setAlarm(bool on) { mAlarm = on; }
112 void setReply(bool on) { mReply = on; } 113 void setReply(bool on) { mReply = on; }
113 void setMoreInfo(bool on) { mInfo = on; } 114 void setMoreInfo(bool on) { mInfo = on; }
114 void setMultiDay(int type) { mMultiday = type; } 115 void setMultiDay(int type) { mMultiday = type; }
115 int multiDay() { return mMultiday; } 116 int multiDay() { return mMultiday; }
116 void setMultiDayPos(int type) { mdayPos = type; } 117 void setMultiDayPos(int type) { mdayPos = type; }
117 int gettMultiDayPos() { return mdayPos; } 118 int gettMultiDayPos() { return mdayPos; }
118 void setBlockRepaint(bool on) { mblockRepaint = on; } 119 void setBlockRepaint(bool on) { mblockRepaint = on; }
119 bool setHighlighted( Incidence * ); 120 bool setHighlighted( Incidence * );
120 121
121 void setPalette(const QPalette &p) { mPalette = p; } 122 void setPalette(const QPalette &p) { mPalette = p; }
122 QPalette palette() const { return mPalette; } 123 QPalette palette() const { return mPalette; }
123 bool setHighlightedFalse(); 124 bool setHighlightedFalse();
124 Incidence *incidence() const { return mIncidence; } 125 Incidence *incidence() const { return mIncidence; }
125 QDate incidenceDate() { return mDate; } 126 QDate incidenceDate() { return mDate; }
126 127
127 protected: 128 protected:
128 virtual void paint(QPainter *); 129 virtual void paint(QPainter *);
129 virtual int height(const QListBox *) const; 130 virtual int height(const QListBox *) const;
130 virtual int width(const QListBox *) const; 131 virtual int width(const QListBox *) const;
131 132
132 private: 133 private:
133 int mdayPos; 134 int mdayPos;
134 bool isWeekItem; 135 bool isWeekItem;
135 bool mblockRepaint; 136 bool mblockRepaint;
136 int mMultiday; 137 int mMultiday;
137 bool mRecur; 138 bool mRecur;
138 bool mAlarm; 139 bool mAlarm;
139 bool mReply; 140 bool mReply;
140 bool mInfo; 141 bool mInfo;
141 bool mDisplayHightlighted; 142 bool mDisplayHightlighted;
142 143
143 QPalette mPalette; 144 QPalette mPalette;
144 QDate mDate; 145 QDate mDate;
145 146
146 Incidence *mIncidence; 147 Incidence *mIncidence;
147}; 148};
148 149
149 150
150class KOMonthView; 151class KOMonthView;
151 152
152class MonthViewCell : public KNoScrollListBox 153class MonthViewCell : public KNoScrollListBox
153{ 154{
154 Q_OBJECT 155 Q_OBJECT
155 public: 156 public:
156 MonthViewCell(KOMonthView *,QWidget* ); 157 MonthViewCell(KOMonthView *,QWidget* );
157 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 158 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
158 159
159 void setDate( const QDate & ); 160 void setDate( const QDate & );
160 QDate date() const; 161 QDate date() const;
161 162
162 void setPrimary( bool ); 163 void setPrimary( bool );
163 bool isPrimary() const; 164 bool isPrimary() const;
164 165
165 void setHoliday( bool ); 166 void setHoliday( bool );
166 void setHoliday( const QString & ); 167 void setHoliday( const QString & );
167 168
168 void updateCell(); 169 void updateCell();
169 void startUpdateCell(); 170 void startUpdateCell();
170 void finishUpdateCell(); 171 void finishUpdateCell();
171 void repaintfinishUpdateCell(); 172 void repaintfinishUpdateCell();
172 int insertEvent(Event *); 173 int insertEvent(Event *);
173 void insertTodo(Todo *); 174 void insertTodo(Todo *);
174 175
175 void updateConfig( bool bigFont = false ); 176 void updateConfig( bool bigFont = false );
176 177
177 void enableScrollBars( bool ); 178 void enableScrollBars( bool );
178 179
179 Incidence *selectedIncidence(); 180 Incidence *selectedIncidence();
180 QDate selectedIncidenceDate(); 181 QDate selectedIncidenceDate();
181 QPushButton * dateLabel() { return mLabel; } 182 QPushButton * dateLabel() { return mLabel; }
182 void deHightLight(); 183 void deHightLight();
183 bool doHightLight( Incidence *); 184 bool doHightLight( Incidence *);
184 void deselect(); 185 void deselect();
185 void select(); 186 void select();
186#ifdef DESKTOP_VERSION 187#ifdef DESKTOP_VERSION
187 static QToolTipGroup *toolTipGroup(); 188 static QToolTipGroup *toolTipGroup();
188#endif 189#endif
189 signals: 190 signals:
190 void defaultAction( Incidence * ); 191 void defaultAction( Incidence * );
191 void newEventSignal( QDateTime ); 192 void newEventSignal( QDateTime );
192 void showDaySignal( QDate ); 193 void showDaySignal( QDate );
193 194
194 protected: 195 protected:
195 QStringList mToolTip; 196 QStringList mToolTip;
196 void resizeEvent( QResizeEvent * ); 197 void resizeEvent( QResizeEvent * );
197 198
198public slots: 199public slots:
199 void showDay(); 200 void showDay();
200 protected slots: 201 protected slots:
201 void defaultAction( QListBoxItem * ); 202 void defaultAction( QListBoxItem * );
202 void contextMenu( QListBoxItem * ); 203 void contextMenu( QListBoxItem * );
203 void selection( QListBoxItem * ); 204 void selection( QListBoxItem * );
204 void cellClicked( QListBoxItem * ); 205 void cellClicked( QListBoxItem * );
205 void newEvent(); 206 void newEvent();
206 207
207 private: 208 private:
208 int mdayCount; 209 int mdayCount;
209 QPtrList <MonthViewItem> mAvailItemList; 210 QPtrList <MonthViewItem> mAvailItemList;
210 KOMonthView *mMonthView; 211 KOMonthView *mMonthView;
211 int currentPalette; 212 int currentPalette;
212 213
213 QDate mDate; 214 QDate mDate;
214 bool mPrimary; 215 bool mPrimary;
215 bool mHoliday; 216 bool mHoliday;
216 QString mHolidayString; 217 QString mHolidayString;
217 218
218 //QLabel *mLabel; 219 //QLabel *mLabel;
219 QPushButton *mLabel; 220 QPushButton *mLabel;
220 //QListBox *mItemList; 221 //QListBox *mItemList;
221#ifdef DESKTOP_VERSION 222#ifdef DESKTOP_VERSION
222 static QToolTipGroup *mToolTipGroup; 223 static QToolTipGroup *mToolTipGroup;
223#endif 224#endif
224 QSize mLabelSize; 225 QSize mLabelSize;
225 QSize mLabelBigSize; 226 QSize mLabelBigSize;
226 QPalette mHolidayPalette; 227 QPalette mHolidayPalette;
227 QPalette mStandardPalette; 228 QPalette mStandardPalette;
228 QPalette mPrimaryPalette; 229 QPalette mPrimaryPalette;
229 QPalette mNonPrimaryPalette; 230 QPalette mNonPrimaryPalette;
230 void setMyPalette(); 231 void setMyPalette();
231 QPalette getPalette (); 232 QPalette getPalette ();
232 233
233}; 234};
234 235
235 236
236class KOMonthView: public KOEventView 237class KOMonthView: public KOEventView
237{ 238{
238 Q_OBJECT 239 Q_OBJECT
239 public: 240 public:
240 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 241 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
241 ~KOMonthView(); 242 ~KOMonthView();
242 243
243 /** Returns maximum number of days supported by the komonthview */ 244 /** Returns maximum number of days supported by the komonthview */
244 virtual int maxDatesHint(); 245 virtual int maxDatesHint();
245 246
246 /** Returns number of currently shown dates. */ 247 /** Returns number of currently shown dates. */
247 virtual int currentDateCount(); 248 virtual int currentDateCount();
248 249
249 /** returns the currently selected events */ 250 /** returns the currently selected events */
250 virtual QPtrList<Incidence> selectedIncidences(); 251 virtual QPtrList<Incidence> selectedIncidences();
251 252
252 /** returns dates of the currently selected events */ 253 /** returns dates of the currently selected events */
253 virtual DateList selectedDates(); 254 virtual DateList selectedDates();
254 255
255 virtual void printPreview(CalPrinter *calPrinter, 256 virtual void printPreview(CalPrinter *calPrinter,
256 const QDate &, const QDate &); 257 const QDate &, const QDate &);
257 bool isMonthView() { return !mShowWeekView; } 258 bool isMonthView() { return !mShowWeekView; }
258 bool isUpdatePossible() { return updatePossible; } 259 bool isUpdatePossible() { return updatePossible; }
259 260
260 MonthViewCell * selectedCell(); 261 MonthViewCell * selectedCell();
261 bool skipResize; 262 bool skipResize;
262 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 263 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
263 void clearList(); 264 void clearList();
264 public slots: 265 public slots:
265 void incidenceHighlighted( Incidence *, MonthViewCell*, int ); 266 void incidenceHighlighted( Incidence *, MonthViewCell*, int );
266 void nextCell(); 267 void nextCell();
267 void prevCell(); 268 void prevCell();
268 virtual void updateView(); 269 virtual void updateView();
269 virtual void updateConfig(); 270 virtual void updateConfig();
270 virtual void showDates(const QDate &start, const QDate &end); 271 virtual void showDates(const QDate &start, const QDate &end);
271 virtual void showEvents(QPtrList<Event> eventList); 272 virtual void showEvents(QPtrList<Event> eventList);
272 273
273 void changeEventDisplay(Event *, int); 274 void changeEventDisplay(Event *, int);
274 275
275 void clearSelection(); 276 void clearSelection();
276 277
277 void showContextMenu( Incidence * ); 278 void showContextMenu( Incidence * );
278 279
279 void setSelectedCell( MonthViewCell * ); 280 void setSelectedCell( MonthViewCell * );
280 void setPopupCell( MonthViewCell * ); 281 void setPopupCell( MonthViewCell * );
281 void switchView(); 282 void switchView();
282 void setKeyBoardFocus(); 283 void setKeyBoardFocus();
283 void setKeyBFocus(); 284 void setKeyBFocus();
284 285
285 protected slots: 286 protected slots:
286 void slotNewTodo(); 287 void slotNewTodo();
287 void slotNewEvent(); 288 void slotNewEvent();
288 void slotEditJournal(); 289 void slotEditJournal();
289 void slotComputeLayout(); 290 void slotComputeLayout();
290 void selectInternalWeekNum ( int ); 291 void selectInternalWeekNum ( int );
291 void processSelectionChange(); 292 void processSelectionChange();
292 signals: 293 signals:
293 void nextMonth(); 294 void nextMonth();
294 void prevMonth(); 295 void prevMonth();
295 void selectWeekNum ( int ); 296 void selectWeekNum ( int );
296 void selectMonth (); 297 void selectMonth ();
297 void showDaySignal( QDate ); 298 void showDaySignal( QDate );
298 void newTodoSignal( QDateTime, bool ); 299 void newTodoSignal( QDateTime, bool );
299 void showJournalSignal( int,QDate ); 300 void showJournalSignal( int,QDate );
300 protected: 301 protected:
301 void resizeEvent(QResizeEvent *); 302 void resizeEvent(QResizeEvent *);
302 void viewChanged(); 303 void viewChanged();
303 void updateDayLabels(); 304 void updateDayLabels();
304 305
305 private: 306 private:
306 QTimer* mComputeLayoutTimer; 307 QTimer* mComputeLayoutTimer;
307 NavigatorBar* mNavigatorBar; 308 NavigatorBar* mNavigatorBar;
308 int currentWeek(); 309 int currentWeek();
309 bool clPending; 310 bool clPending;
310 QWidgetStack * mWidStack; 311 QWidgetStack * mWidStack;
311 QWidget* mMonthView; 312 QWidget* mMonthView;
312 QWidget* mWeekView; 313 QWidget* mWeekView;
313 bool mShowWeekView; 314 bool mShowWeekView;
314 bool updatePossible; 315 bool updatePossible;
315 int mDaysPerWeek; 316 int mDaysPerWeek;
316 int mNumWeeks; 317 int mNumWeeks;
317 int mNumCells; 318 int mNumCells;
318 //bool mWeekStartsMonday; 319 //bool mWeekStartsMonday;
319 bool mShowSatSunComp; 320 bool mShowSatSunComp;
320 void computeLayout(); 321 void computeLayout();
321 void computeLayoutWeek(); 322 void computeLayoutWeek();
322 323
323 QPtrVector<MonthViewCell> mCells; 324 QPtrVector<MonthViewCell> mCells;
324 QPtrVector<QLabel> mDayLabels; 325 QPtrVector<QLabel> mDayLabels;
325 QPtrVector<KOWeekButton> mWeekLabels; 326 QPtrVector<KOWeekButton> mWeekLabels;
326 QPtrVector<MonthViewCell> mCellsW; 327 QPtrVector<MonthViewCell> mCellsW;
327 QPtrVector<QLabel> mDayLabelsW; 328 QPtrVector<QLabel> mDayLabelsW;
328 QPtrVector<KOWeekButton> mWeekLabelsW; 329 QPtrVector<KOWeekButton> mWeekLabelsW;
329 330
330 bool mShortDayLabelsM; 331 bool mShortDayLabelsM;
331 bool mShortDayLabelsW; 332 bool mShortDayLabelsW;
332 int mWidthLongDayLabel; 333 int mWidthLongDayLabel;
333 334
334 QDate mStartDate; 335 QDate mStartDate;
335 336
336 MonthViewCell *mSelectedCell; 337 MonthViewCell *mSelectedCell;
337 MonthViewCell *mPopupCell; 338 MonthViewCell *mPopupCell;
338 bool mFlagKeyPressed; 339 bool mFlagKeyPressed;
339 KOEventPopupMenu *mContextMenu; 340 KOEventPopupMenu *mContextMenu;
340 QPopupMenu *mNewItemMenu; 341 QPopupMenu *mNewItemMenu;
341 void keyPressEvent ( QKeyEvent * ) ; 342 void keyPressEvent ( QKeyEvent * ) ;
342 void keyReleaseEvent ( QKeyEvent * ) ; 343 void keyReleaseEvent ( QKeyEvent * ) ;
343 344
344}; 345};
345 346
346#endif 347#endif