summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-05 09:30:00 (UTC)
committer zautrix <zautrix>2005-04-05 09:30:00 (UTC)
commit53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216 (patch) (unidiff)
tree8dfcb059271cbfd4e28425d85dea747aa998594d
parent768858848f466a726e2f50b777345976828cc2ff (diff)
downloadkdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.zip
kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.tar.gz
kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp144
-rw-r--r--korganizer/kodaymatrix.h2
-rw-r--r--korganizer/komonthview.cpp34
-rw-r--r--korganizer/komonthview.h6
4 files changed, 173 insertions, 13 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index c7e1b45..322131f 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -98,48 +98,49 @@ void DynamicTip::maybeTip( const QPoint &pos )
98// ============================================================================ 98// ============================================================================
99// K O D A Y M A T R I X 99// K O D A Y M A T R I X
100// ============================================================================ 100// ============================================================================
101 101
102const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
103const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
104 104
105KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) 106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 )
107 107
108#if 0 108#if 0
109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
110 QFrame(parent, name) 110 QFrame(parent, name)
111#endif 111#endif
112{ 112{
113 oldW = 0; 113 oldW = 0;
114 oldH = 0; 114 oldH = 0;
115 myPix.resize( 150, 120 ); 115 myPix.resize( 150, 120 );
116 mRedrawNeeded = true; 116 mRedrawNeeded = true;
117 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 117 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
118 mPendingUpdateBeforeRepaint = false; 118 mPendingUpdateBeforeRepaint = false;
119 mouseDown = false; 119 mouseDown = false;
120 // initialize dynamic arrays 120 // initialize dynamic arrays
121 bDays.resize ( NUMDAYS ); 121 bDays.resize ( NUMDAYS );
122 pDays.resize ( NUMDAYS );
122 hDays.resize ( NUMDAYS ); 123 hDays.resize ( NUMDAYS );
123 eDays.resize ( NUMDAYS ); 124 eDays.resize ( NUMDAYS );
124 days = new QDate[NUMDAYS]; 125 days = new QDate[NUMDAYS];
125 daylbls = new QString[NUMDAYS]; 126 daylbls = new QString[NUMDAYS];
126 //events = new int[NUMDAYS]; 127 //events = new int[NUMDAYS];
127 mToolTip = new DynamicTip(this); 128 mToolTip = new DynamicTip(this);
128 129
129 // set default values used for drawing the matrix 130 // set default values used for drawing the matrix
130 mDefaultBackColor = palette().active().base(); 131 mDefaultBackColor = palette().active().base();
131 mDefaultTextColor = palette().active().foreground(); 132 mDefaultTextColor = palette().active().foreground();
132 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 133 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
133 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 134 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
134 mSelectedDaysColor = QColor("white"); 135 mSelectedDaysColor = QColor("white");
135 mTodayMarginWidth = 2; 136 mTodayMarginWidth = 2;
136 mSelEnd = mSelStart = NOSELECTION; 137 mSelEnd = mSelStart = NOSELECTION;
137 138
138 setAcceptDrops(true); 139 setAcceptDrops(true);
139 //setFont( QFont("Arial", 10) ); 140 //setFont( QFont("Arial", 10) );
140 141
141 mUpdateTimer = new QTimer( this ); 142 mUpdateTimer = new QTimer( this );
142 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 143 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
143 mRepaintTimer = new QTimer( this ); 144 mRepaintTimer = new QTimer( this );
144 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 145 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
145 mDayChanged = false; 146 mDayChanged = false;
@@ -319,151 +320,286 @@ void KODayMatrix::recalculateToday()
319 today = -1; 320 today = -1;
320 for (int i=0; i<NUMDAYS; i++) { 321 for (int i=0; i<NUMDAYS; i++) {
321 //events[i] = 0; 322 //events[i] = 0;
322 days[i] = startdate.addDays(i); 323 days[i] = startdate.addDays(i);
323 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 324 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
324 325
325 // if today is in the currently displayed month, hilight today 326 // if today is in the currently displayed month, hilight today
326 if (days[i].year() == QDate::currentDate().year() && 327 if (days[i].year() == QDate::currentDate().year() &&
327 days[i].month() == QDate::currentDate().month() && 328 days[i].month() == QDate::currentDate().month() &&
328 days[i].day() == QDate::currentDate().day()) { 329 days[i].day() == QDate::currentDate().day()) {
329 today = i; 330 today = i;
330 } 331 }
331 } 332 }
332 // qDebug(QString("Today is visible at %1.").arg(today)); 333 // qDebug(QString("Today is visible at %1.").arg(today));
333} 334}
334 335
335void KODayMatrix::updateView() 336void KODayMatrix::updateView()
336{ 337{
337 updateView(startdate); 338 updateView(startdate);
338} 339}
339void KODayMatrix::repaintViewTimed() 340void KODayMatrix::repaintViewTimed()
340{ 341{
341 mRedrawNeeded = true; 342 mRedrawNeeded = true;
342 bDays.fill( false); 343 bDays.fill( false);
344 pDays.fill( false);
343 hDays.fill( false); 345 hDays.fill( false);
344 eDays.fill( false); 346 eDays.fill( false);
345 mRepaintTimer->stop(); 347 mRepaintTimer->stop();
348 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
349 int i;
350 for(i = 0; i < NUMDAYS; i++) {
351 if ( ( (i+startDay) % 7 == 0 ) ) {
352 pDays.setBit(i);
353 }
354 }
346 repaint(false); 355 repaint(false);
347} 356}
357void KODayMatrix::computeEvent(Event *event, int i )
358{
359 QString holiStr = mHolidays[i];
360 if ( event->isHoliday()) {
361 pDays.setBit(i);
362 hDays.setBit(i);
363 if ( !holiStr.isEmpty() )
364 holiStr += "\n";
365 holiStr += event->summary();
366 if ( !event->location().isEmpty() )
367 holiStr += " (" + event->location() + ")";
368 mHolidays[i] =holiStr ;
369 }
370 if ( event->isBirthday()) {
371 pDays.setBit(i);
372 if ( !holiStr.isEmpty() )
373 holiStr += "\n";
374 holiStr += i18n("Birthday") + ": "+event->summary();
375 if ( !event->location().isEmpty() )
376 holiStr += " (" + event->location() + ")";
377 bDays.setBit(i);
378 mHolidays[i] =holiStr ;
379 }
380 eDays.setBit(i);
381}
348void KODayMatrix::updateViewTimed() 382void KODayMatrix::updateViewTimed()
349{ 383{
350 mUpdateTimer->stop(); 384 mUpdateTimer->stop();
351 if ( !mCalendar ) { 385 if ( !mCalendar ) {
352 qDebug("NOT CAL "); 386 qDebug("NOT CAL ");
353 return; 387 return;
354 } 388 }
389#if 1
390
391 int i;
392 int timeSpan = NUMDAYS-1;
393 QPtrList<Event> events = mCalendar->events();
394 Event *event;
395 QDateTime dt;
396 bool ok;
397 bDays.fill( false);
398 pDays.fill( false);
399 hDays.fill( false);
400 eDays.fill( false);
401 mHolidays.clear();
402 QDate mStartDate = days[0];
403 QDate endDate = mStartDate.addDays( timeSpan );
404 for( event = events.first(); event; event = events.next() ) { // for event
405 ushort recurType = event->recurrence()->doesRecur();
406 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
407 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
408 continue;
409 }
410 if ( event->doesRecur() ) {
411 bool last;
412 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
413 QDateTime incidenceEnd;
414 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
415 bool invalid = false;
416 while( true ) {
417 if ( incidenceStart.isValid() ) {
418 incidenceEnd = incidenceStart.addDays( eventlen );
419 int st = incidenceStart.date().daysTo( endDate );
420 if ( st >= 0 ) { // start before timeend
421 int end = mStartDate.daysTo( incidenceEnd.date() );
422 if ( end >= 0 ) { // end after timestart --- got one!
423 //normalize
424 st = timeSpan - st;
425 if ( st < 0 ) st = 0;
426 if ( end > timeSpan ) end = timeSpan;
427 int iii;
428 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
429 for ( iii = st;iii<= end;++iii) {
430 computeEvent( event, iii );
431 }
432 }
433 }
434 } else {
435 if ( invalid )
436 break;
437 invalid = true;
438 //qDebug("invalid %s", event->summary().latin1());
439 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
440 }
441 if ( last )
442 break;
443 bool ok;
444 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
445 if ( ! ok )
446 break;
447 if ( incidenceStart.date() > endDate )
448 break;
449 }
450 } else { // no recur
451 int st = event->dtStart().date().daysTo( endDate );
452 if ( st >= 0 ) { // start before timeend
453 int end = mStartDate.daysTo( event->dtEnd().date() );
454 if ( end >= 0 ) { // end after timestart --- got one!
455 //normalize
456 st = timeSpan - st;
457 if ( st < 0 ) st = 0;
458 if ( end > timeSpan ) end = timeSpan;
459 int iii;
460 for ( iii = st;iii<= end;++iii)
461 computeEvent( event, iii );
462 }
463 }
464 }
465 }
466 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
467 for(i = 0; i < NUMDAYS; i++) {
468 if ( ( (i+startDay) % 7 == 0 ) ) {
469 pDays.setBit(i);
470 }
471 }
472
473#if 0
474 // insert due todos
475 QPtrList<Todo> todos = calendar()->todos( );
476 Todo *todo;
477 for(todo = todos.first(); todo; todo = todos.next()) {
478 //insertTodo( todo );
479 if ( todo->hasDueDate() ) {
480 int day = mStartDate.daysTo( todo->dtDue().date() );
481 if ( day >= 0 && day < timeSpan + 1) {
482 (*cells)[day]->insertTodo( todo );
483 }
484 }
485 }
486#endif
487
488#else
355 //qDebug("KODayMatrix::updateViewTimed "); 489 //qDebug("KODayMatrix::updateViewTimed ");
356 for(int i = 0; i < NUMDAYS; i++) { 490 for(int i = 0; i < NUMDAYS; i++) {
357 // if events are set for the day then remember to draw it bold 491 // if events are set for the day then remember to draw it bold
358 QPtrList<Event> eventlist = mCalendar->events(days[i]); 492 QPtrList<Event> eventlist = mCalendar->events(days[i]);
359 Event *event; 493 Event *event;
360 int numEvents = eventlist.count(); 494 int numEvents = eventlist.count();
361 QString holiStr = ""; 495 QString holiStr = "";
362 bDays.clearBit(i); 496 bDays.clearBit(i);
363 hDays.clearBit(i); 497 hDays.clearBit(i);
364 eDays.clearBit(i); 498 eDays.clearBit(i);
365 for(event=eventlist.first();event != 0;event=eventlist.next()) { 499 for(event=eventlist.first();event != 0;event=eventlist.next()) {
500 qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF ");
366 ushort recurType = event->recurrence()->doesRecur(); 501 ushort recurType = event->recurrence()->doesRecur();
367 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 502 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
368 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 503 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
369 numEvents--; 504 numEvents--;
370 } 505 }
371 if ( event->isHoliday()) { 506 if ( event->isHoliday()) {
372 hDays.setBit(i); 507 hDays.setBit(i);
373 if ( !holiStr.isEmpty() ) 508 if ( !holiStr.isEmpty() )
374 holiStr += "\n"; 509 holiStr += "\n";
375 holiStr += event->summary(); 510 holiStr += event->summary();
376 if ( !event->location().isEmpty() ) 511 if ( !event->location().isEmpty() )
377 holiStr += " (" + event->location() + ")"; 512 holiStr += " (" + event->location() + ")";
378 } 513 }
379 if ( event->isBirthday()) { 514 if ( event->isBirthday()) {
380 if ( !holiStr.isEmpty() ) 515 if ( !holiStr.isEmpty() )
381 holiStr += "\n"; 516 holiStr += "\n";
382 holiStr += i18n("Birthday") + ": "+event->summary(); 517 holiStr += i18n("Birthday") + ": "+event->summary();
383 if ( !event->location().isEmpty() ) 518 if ( !event->location().isEmpty() )
384 holiStr += " (" + event->location() + ")"; 519 holiStr += " (" + event->location() + ")";
385 bDays.setBit(i); 520 bDays.setBit(i);
386 } 521 }
387 } 522 }
388 if ( numEvents ) 523 if ( numEvents )
389 eDays.setBit(i); 524 eDays.setBit(i);
390 //if it is a holy day then draw it red. Sundays are consider holidays, too 525 //if it is a holy day then draw it red. Sundays are consider holidays, too
391 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 526 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
392 !holiStr.isEmpty()) { 527 !holiStr.isEmpty()) {
393 mHolidays[i] = holiStr; 528 mHolidays[i] = holiStr;
394 } else { 529 } else {
395 mHolidays[i] = QString::null; 530 mHolidays[i] = QString::null;
396 } 531 }
397 } 532 }
533#endif
398 mRedrawNeeded = true; 534 mRedrawNeeded = true;
399 if ( ! mPendingUpdateBeforeRepaint ) 535 if ( ! mPendingUpdateBeforeRepaint )
400 repaint(false); 536 repaint(false);
401} 537}
402void KODayMatrix::updateView(QDate actdate) 538void KODayMatrix::updateView(QDate actdate)
403{ 539{
404 540
405 if ( ! actdate.isValid() ) { 541 if ( ! actdate.isValid() ) {
406 //qDebug("date not valid "); 542 //qDebug("date not valid ");
407 return; 543 return;
408 } 544 }
409 mDayChanged = false; 545 mDayChanged = false;
410 //flag to indicate if the starting day of the matrix has changed by this call 546 //flag to indicate if the starting day of the matrix has changed by this call
411 //mDayChanged = false; 547 //mDayChanged = false;
412 // if a new startdate is to be set then apply Cornelius's calculation 548 // if a new startdate is to be set then apply Cornelius's calculation
413 // of the first day to be shown 549 // of the first day to be shown
414 if (actdate != startdate) { 550 if (actdate != startdate) {
415 // reset index of selection according to shift of starting date from startdate to actdate 551 // reset index of selection according to shift of starting date from startdate to actdate
416 if (mSelStart != NOSELECTION) { 552 if (mSelStart != NOSELECTION) {
417 int tmp = actdate.daysTo(startdate); 553 int tmp = actdate.daysTo(startdate);
418 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 554 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
419 // shift selection if new one would be visible at least partly ! 555 // shift selection if new one would be visible at least partly !
420 556
421 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 557 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
422 // nested if is required for next X display pushed from a different month - correction required 558 // nested if is required for next X display pushed from a different month - correction required
423 // otherwise, for month forward and backward, it must be avoided 559 // otherwise, for month forward and backward, it must be avoided
424 if( mSelStart > NUMDAYS || mSelStart < 0 ) 560 if( mSelStart > NUMDAYS || mSelStart < 0 )
425 mSelStart = mSelStart + tmp; 561 mSelStart = mSelStart + tmp;
426 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 562 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
427 mSelEnd = mSelEnd + tmp; 563 mSelEnd = mSelEnd + tmp;
428 } 564 }
429 } 565 }
430 startdate = actdate; 566 startdate = actdate;
431 mDayChanged = true; 567 mDayChanged = true;
432 recalculateToday(); 568 recalculateToday();
433 mRedrawNeeded = true; 569 mRedrawNeeded = true;
434 } 570 }
435 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 571 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
436 if ( !isVisible() ) { 572 if ( !isVisible() ) {
437 mPendingUpdateBeforeRepaint = true; 573 mPendingUpdateBeforeRepaint = true;
438 } else { 574 } else {
439#ifdef DESKTOP_VERSION 575#ifdef DESKTOP_VERSION
440 //mRepaintTimer->start( 100 ); 576 //mRepaintTimer->start( 100 );
441 //updateViewTimed(); 577 //updateViewTimed();
442 mUpdateTimer->start( 50 ); 578 mUpdateTimer->start( 50 );
443#else 579#else
444 mRepaintTimer->start( 350 ); 580 mRepaintTimer->start( 350 );
445 mUpdateTimer->start( 1200 ); 581 mUpdateTimer->start( 800 );
446#endif 582#endif
447 } 583 }
448} 584}
449void KODayMatrix::updateEvents() 585void KODayMatrix::updateEvents()
450{ 586{
451 if ( !mCalendar ) return; 587 if ( !mCalendar ) return;
452 588
453 for( int i = 0; i < NUMDAYS; i++ ) { 589 for( int i = 0; i < NUMDAYS; i++ ) {
454 // if events are set for the day then remember to draw it bold 590 // if events are set for the day then remember to draw it bold
455 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 591 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
456 int numEvents = eventlist.count(); 592 int numEvents = eventlist.count();
457 Event *event; 593 Event *event;
458 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 594 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
459 ushort recurType = event->doesRecur(); 595 ushort recurType = event->doesRecur();
460 596
461 if ( ( recurType == Recurrence::rDaily && 597 if ( ( recurType == Recurrence::rDaily &&
462 !KOPrefs::instance()->mDailyRecur ) || 598 !KOPrefs::instance()->mDailyRecur ) ||
463 ( recurType == Recurrence::rWeekly && 599 ( recurType == Recurrence::rWeekly &&
464 !KOPrefs::instance()->mWeeklyRecur ) ) { 600 !KOPrefs::instance()->mWeeklyRecur ) ) {
465 numEvents--; 601 numEvents--;
466 } 602 }
467 } 603 }
468 if ( numEvents ) 604 if ( numEvents )
469 eDays.setBit(i); 605 eDays.setBit(i);
@@ -852,129 +988,129 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
852 } else { 988 } else {
853 actcol = mDefaultTextColorShaded; 989 actcol = mDefaultTextColorShaded;
854 } 990 }
855 p.setPen(actcol); 991 p.setPen(actcol);
856 } 992 }
857 if (actcol == mDefaultTextColorShaded) { 993 if (actcol == mDefaultTextColorShaded) {
858 if ( ! mouseDown ) { 994 if ( ! mouseDown ) {
859 continue; 995 continue;
860 } 996 }
861 } 997 }
862 //Reset pen color after selected days block 998 //Reset pen color after selected days block
863 if (i == mSelEndT+1) { 999 if (i == mSelEndT+1) {
864 p.setPen(actcol); 1000 p.setPen(actcol);
865 } 1001 }
866 1002
867 // if today then draw rectangle around day 1003 // if today then draw rectangle around day
868 if (today == i) { 1004 if (today == i) {
869 tmppen = p.pen(); 1005 tmppen = p.pen();
870 QPen mTodayPen(p.pen()); 1006 QPen mTodayPen(p.pen());
871 if ( daysize.width() < 20 ) 1007 if ( daysize.width() < 20 )
872 mTodayPen.setWidth(1); 1008 mTodayPen.setWidth(1);
873 else 1009 else
874 mTodayPen.setWidth(mTodayMarginWidth); 1010 mTodayPen.setWidth(mTodayMarginWidth);
875 //draw red rectangle for holidays 1011 //draw red rectangle for holidays
876 if (!mHolidays[i].isNull()) { 1012 if (pDays.testBit(i)) {
877 if (actcol == mDefaultTextColor) { 1013 if (actcol == mDefaultTextColor) {
878 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 1014 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
879 } else { 1015 } else {
880 mTodayPen.setColor(mHolidayColorShaded); 1016 mTodayPen.setColor(mHolidayColorShaded);
881 } 1017 }
882 } 1018 }
883 //draw gray rectangle for today if in selection 1019 //draw gray rectangle for today if in selection
884 if (i >= mSelStartT && i <= mSelEndT) { 1020 if (i >= mSelStartT && i <= mSelEndT) {
885 QColor grey("grey"); 1021 QColor grey("grey");
886 mTodayPen.setColor(grey); 1022 mTodayPen.setColor(grey);
887 } 1023 }
888 p.setPen(mTodayPen); 1024 p.setPen(mTodayPen);
889 1025
890 1026
891 int addCol = 0; 1027 int addCol = 0;
892 int addRow = 0; 1028 int addRow = 0;
893 if (rowModulo) { 1029 if (rowModulo) {
894 if ( row >= 6 - rowModulo ) 1030 if ( row >= 6 - rowModulo )
895 addRow = row - 5 + rowModulo; 1031 addRow = row - 5 + rowModulo;
896 } 1032 }
897 if ( colModulo ) { 1033 if ( colModulo ) {
898 if ( col >= 7 - colModulo ) 1034 if ( col >= 7 - colModulo )
899 addCol = col - 6 + colModulo-1; 1035 addCol = col - 6 + colModulo-1;
900 } 1036 }
901 1037
902 addCol += 1; 1038 addCol += 1;
903 if ( row == 0 ) 1039 if ( row == 0 )
904 addRow = 1; 1040 addRow = 1;
905 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); 1041 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
906 p.setPen(tmppen); 1042 p.setPen(tmppen);
907 } 1043 }
908 1044
909 // if any events are on that day then draw it using a bold font 1045 // if any events are on that day then draw it using a bold font
910 if ( eDays.testBit(i) ) { 1046 if ( eDays.testBit(i) ) {
911 QFont myFont = font(); 1047 QFont myFont = font();
912 myFont.setBold(true); 1048 myFont.setBold(true);
913 p.setFont(myFont); 1049 p.setFont(myFont);
914 } 1050 }
915 1051
916 // if it is a holiday then use the default holiday color 1052 // if it is a holiday then use the default holiday color
917 if ( !mHolidays[i].isNull()) { 1053 if ( pDays.testBit(i)) {
918 if ( bDays.testBit(i) ) { 1054 if ( bDays.testBit(i) ) {
919 if ( hDays.testBit(i) ) 1055 if ( hDays.testBit(i) )
920 p.setPen(QColor(Qt::green)); 1056 p.setPen(QColor(Qt::green));
921 else 1057 else
922 p.setPen(QColor(Qt::green).dark()); 1058 p.setPen(QColor(Qt::green).dark());
923 } else { 1059 } else {
924 if (actcol == mDefaultTextColor ) { 1060 if (actcol == mDefaultTextColor ) {
925 p.setPen(KOPrefs::instance()->mHolidayColor); 1061 p.setPen(KOPrefs::instance()->mHolidayColor);
926 } else { 1062 } else {
927 p.setPen(mHolidayColorShaded); 1063 p.setPen(mHolidayColorShaded);
928 } 1064 }
929 } 1065 }
930 } 1066 }
931 1067
932 // draw selected days with special color 1068 // draw selected days with special color
933 // DO NOT specially highlight holidays in selection ! 1069 // DO NOT specially highlight holidays in selection !
934 if (i >= mSelStartT && i <= mSelEndT) { 1070 if (i >= mSelStartT && i <= mSelEndT) {
935 ;//p.setPen(mSelectedDaysColor); 1071 ;//p.setPen(mSelectedDaysColor);
936 } 1072 }
937 1073
938 int addCol = 0; 1074 int addCol = 0;
939 int addRow = 0; 1075 int addRow = 0;
940 if ( colModulo ) { 1076 if ( colModulo ) {
941 if ( col >= 7 - colModulo ) 1077 if ( col >= 7 - colModulo )
942 addCol = col - 7 + colModulo; 1078 addCol = col - 7 + colModulo;
943 } 1079 }
944 if ( rowModulo ) { 1080 if ( rowModulo ) {
945 if ( row >= 6 - rowModulo ) 1081 if ( row >= 6 - rowModulo )
946 addRow = row - 5 + rowModulo; 1082 addRow = row - 5 + rowModulo;
947 } 1083 }
948 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 1084 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
949 ++addCol;//++addCol; 1085 ++addCol;//++addCol;
950 if ( row == 0) 1086 if ( row == 0)
951 addRow = 1; 1087 addRow = 1;
952 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 1088 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
953 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 1089 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
954 1090
955 // reset color to actual color 1091 // reset color to actual color
956 if (!mHolidays[i].isNull()) { 1092 if (pDays.testBit(i)) {
957 p.setPen(actcol); 1093 p.setPen(actcol);
958 } 1094 }
959 // reset bold font to plain font 1095 // reset bold font to plain font
960 if ( eDays.testBit(i)) { 1096 if ( eDays.testBit(i)) {
961 QFont myFont = font(); 1097 QFont myFont = font();
962 myFont.setBold(false); 1098 myFont.setBold(false);
963 p.setFont(myFont); 1099 p.setFont(myFont);
964 } 1100 }
965 } 1101 }
966 } else { 1102 } else {
967 //qDebug("NO redraw "); 1103 //qDebug("NO redraw ");
968 } 1104 }
969 1105
970 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); 1106 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP);
971 mRedrawNeeded = false; 1107 mRedrawNeeded = false;
972} 1108}
973 1109
974// ---------------------------------------------------------------------------- 1110// ----------------------------------------------------------------------------
975// R E SI Z E E V E N T H A N D L I N G 1111// R E SI Z E E V E N T H A N D L I N G
976// ---------------------------------------------------------------------------- 1112// ----------------------------------------------------------------------------
977 1113
978void KODayMatrix::resizeEvent(QResizeEvent *) 1114void KODayMatrix::resizeEvent(QResizeEvent *)
979{ 1115{
980 QRect sz = frameRect(); 1116 QRect sz = frameRect();
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index d725ead..b686bd7 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -206,55 +206,57 @@ signals:
206 */ 206 */
207 void eventDropped(Event *event); 207 void eventDropped(Event *event);
208 208
209protected: 209protected:
210 210
211 void paintEvent(QPaintEvent *ev); 211 void paintEvent(QPaintEvent *ev);
212 212
213 void mousePressEvent (QMouseEvent* e); 213 void mousePressEvent (QMouseEvent* e);
214 214
215 void mouseReleaseEvent (QMouseEvent* e); 215 void mouseReleaseEvent (QMouseEvent* e);
216 216
217 void mouseMoveEvent (QMouseEvent* e); 217 void mouseMoveEvent (QMouseEvent* e);
218 218
219 void dragEnterEvent(QDragEnterEvent *); 219 void dragEnterEvent(QDragEnterEvent *);
220 220
221 void dragMoveEvent(QDragMoveEvent *); 221 void dragMoveEvent(QDragMoveEvent *);
222 222
223 void dragLeaveEvent(QDragLeaveEvent *); 223 void dragLeaveEvent(QDragLeaveEvent *);
224 224
225 void dropEvent(QDropEvent *); 225 void dropEvent(QDropEvent *);
226 226
227 void resizeEvent(QResizeEvent *); 227 void resizeEvent(QResizeEvent *);
228 228
229private: 229private:
230 void computeEvent(Event *even, int dayindex );
230 int oldW, oldH; 231 int oldW, oldH;
231 bool mRedrawNeeded; 232 bool mRedrawNeeded;
232 KODaymatrixWhatsThis* mKODaymatrixWhatsThis; 233 KODaymatrixWhatsThis* mKODaymatrixWhatsThis;
233 bool mouseDown; 234 bool mouseDown;
234 QBitArray bDays; 235 QBitArray bDays;
235 QBitArray hDays; 236 QBitArray hDays;
236 QBitArray eDays; 237 QBitArray eDays;
238 QBitArray pDays;
237 QPixmap myPix; 239 QPixmap myPix;
238 QTimer* mUpdateTimer; 240 QTimer* mUpdateTimer;
239 QTimer* mRepaintTimer; 241 QTimer* mRepaintTimer;
240 bool mDayChanged; 242 bool mDayChanged;
241 bool mPendingUpdateBeforeRepaint; 243 bool mPendingUpdateBeforeRepaint;
242 244
243 /** returns the index of the day located at the matrix's widget (x,y) position. 245 /** returns the index of the day located at the matrix's widget (x,y) position.
244 * 246 *
245 * @param x horizontal coordinate 247 * @param x horizontal coordinate
246 * @param y vertical coordinate 248 * @param y vertical coordinate
247 */ 249 */
248 int getDayIndexFrom(int x, int y); 250 int getDayIndexFrom(int x, int y);
249 251
250 /** calculates a "shaded" color from the supplied color object. 252 /** calculates a "shaded" color from the supplied color object.
251 * (Copied from Cornelius's kdpdatebutton.cpp) 253 * (Copied from Cornelius's kdpdatebutton.cpp)
252 * 254 *
253 * @param color source based on which a shaded color should be calculated. 255 * @param color source based on which a shaded color should be calculated.
254 */ 256 */
255 QColor getShadedColor(QColor color); 257 QColor getShadedColor(QColor color);
256 258
257 /** number of days to be displayed. For now there is no support for any other number then 42. 259 /** number of days to be displayed. For now there is no support for any other number then 42.
258 so change it at your own risk :o) */ 260 so change it at your own risk :o) */
259 static const int NUMDAYS; 261 static const int NUMDAYS;
260 262
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 1ed288b..425496a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -248,61 +248,63 @@ void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
248 } 248 }
249} 249}
250 250
251void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 251void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
252{ 252{
253 QListBox::mousePressEvent(e); 253 QListBox::mousePressEvent(e);
254 254
255 if(e->button() == RightButton) { 255 if(e->button() == RightButton) {
256 emit rightClick(); 256 emit rightClick();
257 } 257 }
258} 258}
259 259
260MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 260MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
261 : QListBoxItem() 261 : QListBoxItem()
262{ 262{
263 mblockRepaint = true; 263 mblockRepaint = true;
264 setText( s ); 264 setText( s );
265 mMultiday = 0; 265 mMultiday = 0;
266 mIncidence = incidence; 266 mIncidence = incidence;
267 mDate = qd; 267 mDate = qd;
268 mRecur = false; 268 mRecur = false;
269 mAlarm = false; 269 mAlarm = false;
270 mReply = false; 270 mReply = false;
271 mInfo = false; 271 mInfo = false;
272 mdayPos = 0;
272 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 273 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
273 //qDebug("NEWWWWWWWWWWWWW "); 274 //qDebug("NEWWWWWWWWWWWWW ");
274} 275}
275void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 276void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
276{ 277{
277 setText( s ); 278 setText( s );
278 mMultiday = 0; 279 mMultiday = 0;
279 mIncidence = incidence; 280 mIncidence = incidence;
280 mDate = qd; 281 mDate = qd;
281 mRecur = false; 282 mRecur = false;
282 mAlarm = false; 283 mAlarm = false;
283 mReply = false; 284 mReply = false;
284 mInfo = false; 285 mInfo = false;
286 mdayPos = 0;
285 //qDebug("recucleeeeeeeeeeeeeeeee "); 287 //qDebug("recucleeeeeeeeeeeeeeeee ");
286} 288}
287 289
288void MonthViewItem::paint(QPainter *p) 290void MonthViewItem::paint(QPainter *p)
289{ 291{
290 if ( mblockRepaint ) { 292 if ( mblockRepaint ) {
291 //qDebug("block "); 293 //qDebug("block ");
292 return; 294 return;
293 } 295 }
294 //qDebug("NON block "); 296 //qDebug("NON block ");
295#if QT_VERSION >= 0x030000 297#if QT_VERSION >= 0x030000
296 bool sel = isSelected(); 298 bool sel = isSelected();
297#else 299#else
298 bool sel = selected(); 300 bool sel = selected();
299#endif 301#endif
300 302
301 303
302 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 304 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
303 { 305 {
304 p->setBackgroundColor( palette().color( QPalette::Normal, \ 306 p->setBackgroundColor( palette().color( QPalette::Normal, \
305 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 307 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
306 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 308 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
307 } 309 }
308 int x = 1; 310 int x = 1;
@@ -549,49 +551,49 @@ QPalette MonthViewCell::getPalette ()
549 return mNonPrimaryPalette; 551 return mNonPrimaryPalette;
550} 552}
551bool MonthViewCell::isPrimary() const 553bool MonthViewCell::isPrimary() const
552{ 554{
553 return mPrimary; 555 return mPrimary;
554} 556}
555 557
556void MonthViewCell::setHoliday( bool holiday ) 558void MonthViewCell::setHoliday( bool holiday )
557{ 559{
558 mHoliday = holiday; 560 mHoliday = holiday;
559 //setMyPalette(); 561 //setMyPalette();
560} 562}
561 563
562void MonthViewCell::setHoliday( const QString &holiday ) 564void MonthViewCell::setHoliday( const QString &holiday )
563{ 565{
564 mHolidayString = holiday; 566 mHolidayString = holiday;
565 567
566 if ( !holiday.isEmpty() ) { 568 if ( !holiday.isEmpty() ) {
567 setHoliday( true ); 569 setHoliday( true );
568 } 570 }
569} 571}
570 572
571void MonthViewCell::startUpdateCell() 573void MonthViewCell::startUpdateCell()
572{ 574{
573 575 mdayCount = 0;
574 setFocusPolicy(NoFocus); 576 setFocusPolicy(NoFocus);
575 if ( !mMonthView->isUpdatePossible() ) 577 if ( !mMonthView->isUpdatePossible() )
576 return; 578 return;
577 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 579 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
578 while ( mitem ) { 580 while ( mitem ) {
579 mitem->setBlockRepaint( true ); 581 mitem->setBlockRepaint( true );
580 mitem = (MonthViewItem *)mitem->next(); 582 mitem = (MonthViewItem *)mitem->next();
581 } 583 }
582 if ( mAvailItemList.count() > 20 ) { 584 if ( mAvailItemList.count() > 20 ) {
583 mAvailItemList.setAutoDelete( true ); 585 mAvailItemList.setAutoDelete( true );
584 mAvailItemList.clear(); 586 mAvailItemList.clear();
585 mAvailItemList.setAutoDelete( false ); 587 mAvailItemList.setAutoDelete( false );
586 } 588 }
587 /* 589 /*
588 if ( !isVisible() ){ 590 if ( !isVisible() ){
589 return; 591 return;
590 } 592 }
591 */ 593 */
592 // qDebug("MonthViewCell::updateCell() "); 594 // qDebug("MonthViewCell::updateCell() ");
593 setPrimary( mDate.month()%2 ); 595 setPrimary( mDate.month()%2 );
594 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 596 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
595 if ( mDate == QDate::currentDate() ) { 597 if ( mDate == QDate::currentDate() ) {
596 setLineWidth( 3 ); 598 setLineWidth( 3 );
597 } else { 599 } else {
@@ -600,58 +602,58 @@ void MonthViewCell::startUpdateCell()
600 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 602 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
601 //clear(); 603 //clear();
602 while ( CurrentAvailItem ) { 604 while ( CurrentAvailItem ) {
603 MonthViewItem *item = CurrentAvailItem; 605 MonthViewItem *item = CurrentAvailItem;
604 CurrentAvailItem = (MonthViewItem *)item->next(); 606 CurrentAvailItem = (MonthViewItem *)item->next();
605 mAvailItemList.append( item ); 607 mAvailItemList.append( item );
606 takeItem ( item ); 608 takeItem ( item );
607 } 609 }
608 610
609#ifdef DESKTOP_VERSION 611#ifdef DESKTOP_VERSION
610 QToolTip::remove(this); 612 QToolTip::remove(this);
611#endif 613#endif
612 mToolTip.clear(); 614 mToolTip.clear();
613 //qApp->processEvents(); 615 //qApp->processEvents();
614#if 0 616#if 0
615 if ( !mHolidayString.isEmpty() ) { 617 if ( !mHolidayString.isEmpty() ) {
616 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 618 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
617 item->setPalette( mHolidayPalette ); 619 item->setPalette( mHolidayPalette );
618 insertItem( item ); 620 insertItem( item );
619 mToolTip.append ( mHolidayString ); 621 mToolTip.append ( mHolidayString );
620 } 622 }
621#endif 623#endif
622} 624}
623 625
624void MonthViewCell::insertEvent(Event *event) 626int MonthViewCell::insertEvent(Event *event)
625{ 627{
626 QString mToolTipText; 628 QString mToolTipText;
627 setFocusPolicy(WheelFocus); 629 setFocusPolicy(WheelFocus);
628 if ( !(event->doesRecur() == Recurrence::rNone) ) { 630 if ( !(event->doesRecur() == Recurrence::rNone) ) {
629 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 631 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
630 return; 632 return mdayCount;
631 else 633 else
632 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 634 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
633 return; 635 return mdayCount;
634 } 636 }
635 637
636 if ( event->isHoliday()) { 638 if ( event->isHoliday()) {
637 setHoliday( true ); 639 setHoliday( true );
638 if ( mDate.dayOfWeek() == 7 ) 640 if ( mDate.dayOfWeek() == 7 )
639 setLineWidth( 3 ); 641 setLineWidth( 3 );
640 } 642 }
641 QString text; 643 QString text;
642 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 644 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
643 if (event->isMultiDay()) { 645 if (event->isMultiDay()) {
644 QString prefix = "<->";multiday = 2; 646 QString prefix = "<->";multiday = 2;
645 QString time; 647 QString time;
646 if ( event->doesRecur() ) { 648 if ( event->doesRecur() ) {
647 if ( event->recursOn( mDate) ) { 649 if ( event->recursOn( mDate) ) {
648 prefix ="->" ;multiday = 1; 650 prefix ="->" ;multiday = 1;
649 } 651 }
650 else { 652 else {
651 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 653 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
652 if ( event->recursOn( mDate.addDays( -days)) ) { 654 if ( event->recursOn( mDate.addDays( -days)) ) {
653 prefix ="<-" ;multiday = 3; 655 prefix ="<-" ;multiday = 3;
654 } 656 }
655 } 657 }
656 658
657 } else { 659 } else {
@@ -709,50 +711,66 @@ void MonthViewCell::insertEvent(Event *event)
709 } else { 711 } else {
710 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 712 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
711 } 713 }
712 } 714 }
713 715
714 } else { 716 } else {
715 pal = mStandardPalette ; 717 pal = mStandardPalette ;
716 } 718 }
717 item->setPalette( pal ); 719 item->setPalette( pal );
718 item->setRecur( event->recurrence()->doesRecur() ); 720 item->setRecur( event->recurrence()->doesRecur() );
719 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 721 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
720 item->setMoreInfo( event->description().length() > 0 ); 722 item->setMoreInfo( event->description().length() > 0 );
721#ifdef DESKTOP_VERSION 723#ifdef DESKTOP_VERSION
722 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 724 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
723 KOPrefs::instance()->email()); 725 KOPrefs::instance()->email());
724 if ( me != 0 ) { 726 if ( me != 0 ) {
725 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 727 if ( me->status() == Attendee::NeedsAction && me->RSVP())
726 item->setReply(true && multiday < 2); 728 item->setReply(true && multiday < 2);
727 else 729 else
728 item->setReply(false); 730 item->setReply(false);
729 } else 731 } else
730 item->setReply(false); 732 item->setReply(false);
731#endif 733#endif
732 item->setMultiDay( multiday ); 734 item->setMultiDay( multiday );
733 insertItem( item ); 735 if ( multiday ) {
736 insertItem( item ,mdayCount);
737 ++mdayCount;
738 } else {
739 uint i;
740 int pos = mdayCount;
741 for ( i = mdayCount; i < count();++i ) {
742 QListBoxItem* it = this->item ( i );
743 if ( text < it->text() ) {
744 pos = i;
745 break;
746 }
747 ++pos;
748 }
749 insertItem( item ,pos);
750 }
734 mToolTip.append( mToolTipText ); 751 mToolTip.append( mToolTipText );
752 return mdayCount;
735} 753}
736void MonthViewCell::insertTodo(Todo *todo) 754void MonthViewCell::insertTodo(Todo *todo)
737{ 755{
738 setFocusPolicy(WheelFocus); 756 setFocusPolicy(WheelFocus);
739 QString text; 757 QString text;
740 if (todo->hasDueDate()) { 758 if (todo->hasDueDate()) {
741 if (!todo->doesFloat()) { 759 if (!todo->doesFloat()) {
742 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 760 text += KGlobal::locale()->formatTime(todo->dtDue().time());
743 text += " "; 761 text += " ";
744 } 762 }
745 } 763 }
746 text += todo->summary(); 764 text += todo->summary();
747 MonthViewItem *item ; 765 MonthViewItem *item ;
748 if ( mAvailItemList.count() ) { 766 if ( mAvailItemList.count() ) {
749 item = mAvailItemList.first(); 767 item = mAvailItemList.first();
750 mAvailItemList.remove( item ); 768 mAvailItemList.remove( item );
751 item->recycle( todo, mDate, text ); 769 item->recycle( todo, mDate, text );
752 } else { 770 } else {
753 item = new MonthViewItem( todo, mDate, text ); 771 item = new MonthViewItem( todo, mDate, text );
754 } 772 }
755 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 773 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
756 //item->setPalette( mStandardPalette ); 774 //item->setPalette( mStandardPalette );
757 QPalette pal; 775 QPalette pal;
758 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 776 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
@@ -760,72 +778,72 @@ void MonthViewCell::insertTodo(Todo *todo)
760 QString cat = categories.first(); 778 QString cat = categories.first();
761 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 779 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
762 pal = getPalette(); 780 pal = getPalette();
763 if (cat.isEmpty()) { 781 if (cat.isEmpty()) {
764 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 782 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
765 } else { 783 } else {
766 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 784 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
767 } 785 }
768 786
769 } else { 787 } else {
770 if (cat.isEmpty()) { 788 if (cat.isEmpty()) {
771 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 789 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
772 } else { 790 } else {
773 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 791 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
774 } 792 }
775 } 793 }
776 794
777 } else { 795 } else {
778 pal = mStandardPalette ; 796 pal = mStandardPalette ;
779 } 797 }
780 item->setPalette( pal ); 798 item->setPalette( pal );
781 item->setRecur( todo->recurrence()->doesRecur() ); 799 item->setRecur( todo->recurrence()->doesRecur() );
782 item->setAlarm( todo->isAlarmEnabled() ); 800 item->setAlarm( todo->isAlarmEnabled() );
783 item->setMoreInfo( todo->description().length() > 0 ); 801 item->setMoreInfo( todo->description().length() > 0 );
784 insertItem( item ); 802 insertItem( item , count());
785 mToolTip.append( text ); 803 mToolTip.append( text );
786} 804}
787void MonthViewCell::repaintfinishUpdateCell() 805void MonthViewCell::repaintfinishUpdateCell()
788{ 806{
789 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 807 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
790 while ( mitem ) { 808 while ( mitem ) {
791 mitem->setBlockRepaint( false ); 809 mitem->setBlockRepaint( false );
792 updateItem ( mitem ); 810 updateItem ( mitem );
793 mitem = (MonthViewItem *)mitem->next(); 811 mitem = (MonthViewItem *)mitem->next();
794 } 812 }
795} 813}
796void MonthViewCell::finishUpdateCell() 814void MonthViewCell::finishUpdateCell()
797{ 815{
798 816
799 817
800 818
801#ifdef DESKTOP_VERSION 819#ifdef DESKTOP_VERSION
802 if (mToolTip.count() > 0 ) { 820 if (mToolTip.count() > 0 ) {
803 mToolTip.sort(); 821 mToolTip.sort();
804 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 822 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
805 } 823 }
806#endif 824#endif
807 sort(); 825 //sort();
808 //setMyPalette(); 826 //setMyPalette();
809 setMyPalette(); 827 setMyPalette();
810 828
811 resizeEvent( 0 ); 829 resizeEvent( 0 );
812 830
813} 831}
814void MonthViewCell::updateCell() 832void MonthViewCell::updateCell()
815{ 833{
816 //qDebug("MonthViewCell::updateCell() "); 834 //qDebug("MonthViewCell::updateCell() ");
817 if ( !mMonthView->isUpdatePossible() ) 835 if ( !mMonthView->isUpdatePossible() )
818 return; 836 return;
819 startUpdateCell(); 837 startUpdateCell();
820 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 838 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
821 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 839 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
822 Event *event; 840 Event *event;
823 for( event = events.first(); event; event = events.next() ) { // for event 841 for( event = events.first(); event; event = events.next() ) { // for event
824 insertEvent(event); 842 insertEvent(event);
825 } 843 }
826 // insert due todos 844 // insert due todos
827 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 845 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
828 Todo *todo; 846 Todo *todo;
829 for(todo = todos.first(); todo; todo = todos.next()) { 847 for(todo = todos.first(); todo; todo = todos.next()) {
830 insertTodo( todo ); 848 insertTodo( todo );
831 } 849 }
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e962756..e39eeb0 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -87,137 +87,141 @@ class KNoScrollListBox: public QListBox
87 protected slots: 87 protected slots:
88 void oneDown(); 88 void oneDown();
89 void keyPressEvent(QKeyEvent *); 89 void keyPressEvent(QKeyEvent *);
90 void keyReleaseEvent(QKeyEvent *); 90 void keyReleaseEvent(QKeyEvent *);
91 void mousePressEvent(QMouseEvent *); 91 void mousePressEvent(QMouseEvent *);
92 void focusInEvent ( QFocusEvent * ); 92 void focusInEvent ( QFocusEvent * );
93 void focusOutEvent ( QFocusEvent * ); 93 void focusOutEvent ( QFocusEvent * );
94 94
95 private: 95 private:
96 bool resetOnFocusIn; 96 bool resetOnFocusIn;
97 KNOWhatsThis * mWT; 97 KNOWhatsThis * mWT;
98}; 98};
99 99
100 100
101class MonthViewItem: public QListBoxItem 101class MonthViewItem: public QListBoxItem
102{ 102{
103 public: 103 public:
104 MonthViewItem( Incidence *, QDate qd, const QString & title ); 104 MonthViewItem( Incidence *, QDate qd, const QString & title );
105 void recycle( Incidence *incidence, QDate qd, const QString & s); 105 void recycle( Incidence *incidence, QDate qd, const QString & s);
106 void setRecur(bool on) { mRecur = on; } 106 void setRecur(bool on) { mRecur = on; }
107 void setAlarm(bool on) { mAlarm = on; } 107 void setAlarm(bool on) { mAlarm = on; }
108 void setReply(bool on) { mReply = on; } 108 void setReply(bool on) { mReply = on; }
109 void setMoreInfo(bool on) { mInfo = on; } 109 void setMoreInfo(bool on) { mInfo = on; }
110 void setMultiDay(int type) { mMultiday = type; } 110 void setMultiDay(int type) { mMultiday = type; }
111 void setMultiDayPos(int type) { mdayPos = type; }
112 int gettMultiDayPos() { return mdayPos; }
111 void setBlockRepaint(bool on) { mblockRepaint = on; } 113 void setBlockRepaint(bool on) { mblockRepaint = on; }
112 114
113 115
114 void setPalette(const QPalette &p) { mPalette = p; } 116 void setPalette(const QPalette &p) { mPalette = p; }
115 QPalette palette() const { return mPalette; } 117 QPalette palette() const { return mPalette; }
116 118
117 Incidence *incidence() const { return mIncidence; } 119 Incidence *incidence() const { return mIncidence; }
118 QDate incidenceDate() { return mDate; } 120 QDate incidenceDate() { return mDate; }
119 121
120 protected: 122 protected:
121 virtual void paint(QPainter *); 123 virtual void paint(QPainter *);
122 virtual int height(const QListBox *) const; 124 virtual int height(const QListBox *) const;
123 virtual int width(const QListBox *) const; 125 virtual int width(const QListBox *) const;
124 126
125 private: 127 private:
128 int mdayPos;
126 bool isWeekItem; 129 bool isWeekItem;
127 bool mblockRepaint; 130 bool mblockRepaint;
128 int mMultiday; 131 int mMultiday;
129 bool mRecur; 132 bool mRecur;
130 bool mAlarm; 133 bool mAlarm;
131 bool mReply; 134 bool mReply;
132 bool mInfo; 135 bool mInfo;
133 136
134 QPalette mPalette; 137 QPalette mPalette;
135 QDate mDate; 138 QDate mDate;
136 139
137 Incidence *mIncidence; 140 Incidence *mIncidence;
138}; 141};
139 142
140 143
141class KOMonthView; 144class KOMonthView;
142 145
143class MonthViewCell : public KNoScrollListBox 146class MonthViewCell : public KNoScrollListBox
144{ 147{
145 Q_OBJECT 148 Q_OBJECT
146 public: 149 public:
147 MonthViewCell(KOMonthView *,QWidget* ); 150 MonthViewCell(KOMonthView *,QWidget* );
148 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 151 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
149 152
150 void setDate( const QDate & ); 153 void setDate( const QDate & );
151 QDate date() const; 154 QDate date() const;
152 155
153 void setPrimary( bool ); 156 void setPrimary( bool );
154 bool isPrimary() const; 157 bool isPrimary() const;
155 158
156 void setHoliday( bool ); 159 void setHoliday( bool );
157 void setHoliday( const QString & ); 160 void setHoliday( const QString & );
158 161
159 void updateCell(); 162 void updateCell();
160 void startUpdateCell(); 163 void startUpdateCell();
161 void finishUpdateCell(); 164 void finishUpdateCell();
162 void repaintfinishUpdateCell(); 165 void repaintfinishUpdateCell();
163 void insertEvent(Event *); 166 int insertEvent(Event *);
164 void insertTodo(Todo *); 167 void insertTodo(Todo *);
165 168
166 void updateConfig( bool bigFont = false ); 169 void updateConfig( bool bigFont = false );
167 170
168 void enableScrollBars( bool ); 171 void enableScrollBars( bool );
169 172
170 Incidence *selectedIncidence(); 173 Incidence *selectedIncidence();
171 QDate selectedIncidenceDate(); 174 QDate selectedIncidenceDate();
172 QPushButton * dateLabel() { return mLabel; } 175 QPushButton * dateLabel() { return mLabel; }
173 176
174 void deselect(); 177 void deselect();
175 void select(); 178 void select();
176#ifdef DESKTOP_VERSION 179#ifdef DESKTOP_VERSION
177 static QToolTipGroup *toolTipGroup(); 180 static QToolTipGroup *toolTipGroup();
178#endif 181#endif
179 signals: 182 signals:
180 void defaultAction( Incidence * ); 183 void defaultAction( Incidence * );
181 void newEventSignal( QDateTime ); 184 void newEventSignal( QDateTime );
182 void showDaySignal( QDate ); 185 void showDaySignal( QDate );
183 186
184 protected: 187 protected:
185 QStringList mToolTip; 188 QStringList mToolTip;
186 void resizeEvent( QResizeEvent * ); 189 void resizeEvent( QResizeEvent * );
187 190
188 191
189public slots: 192public slots:
190 void showDay(); 193 void showDay();
191 194
192 protected slots: 195 protected slots:
193 void defaultAction( QListBoxItem * ); 196 void defaultAction( QListBoxItem * );
194 void contextMenu( QListBoxItem * ); 197 void contextMenu( QListBoxItem * );
195 void selection( QListBoxItem * ); 198 void selection( QListBoxItem * );
196 void cellClicked( QListBoxItem * ); 199 void cellClicked( QListBoxItem * );
197 void newEvent(); 200 void newEvent();
198 201
199 private: 202 private:
203 int mdayCount;
200 QPtrList <MonthViewItem> mAvailItemList; 204 QPtrList <MonthViewItem> mAvailItemList;
201 KOMonthView *mMonthView; 205 KOMonthView *mMonthView;
202 int currentPalette; 206 int currentPalette;
203 207
204 QDate mDate; 208 QDate mDate;
205 bool mPrimary; 209 bool mPrimary;
206 bool mHoliday; 210 bool mHoliday;
207 QString mHolidayString; 211 QString mHolidayString;
208 212
209 //QLabel *mLabel; 213 //QLabel *mLabel;
210 QPushButton *mLabel; 214 QPushButton *mLabel;
211 //QListBox *mItemList; 215 //QListBox *mItemList;
212#ifdef DESKTOP_VERSION 216#ifdef DESKTOP_VERSION
213 static QToolTipGroup *mToolTipGroup; 217 static QToolTipGroup *mToolTipGroup;
214#endif 218#endif
215 QSize mLabelSize; 219 QSize mLabelSize;
216 QSize mLabelBigSize; 220 QSize mLabelBigSize;
217 QPalette mHolidayPalette; 221 QPalette mHolidayPalette;
218 QPalette mStandardPalette; 222 QPalette mStandardPalette;
219 QPalette mPrimaryPalette; 223 QPalette mPrimaryPalette;
220 QPalette mNonPrimaryPalette; 224 QPalette mNonPrimaryPalette;
221 void setMyPalette(); 225 void setMyPalette();
222 QPalette getPalette (); 226 QPalette getPalette ();
223 227