summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.cpp
Unidiff
Diffstat (limited to 'korganizer/kodaymatrix.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index ecca374..17a1d13 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -404,193 +404,192 @@ void KODayMatrix::updateViewTimed()
404 for( event = events.first(); event; event = events.next() ) { // for event 404 for( event = events.first(); event; event = events.next() ) { // for event
405 ushort recurType = event->recurrence()->doesRecur(); 405 ushort recurType = event->recurrence()->doesRecur();
406 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 406 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
407 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 407 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
408 continue; 408 continue;
409 } 409 }
410 if ( event->doesRecur() ) { 410 if ( event->doesRecur() ) {
411 bool last; 411 bool last;
412 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 412 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
413 QDateTime incidenceEnd; 413 QDateTime incidenceEnd;
414 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 414 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
415 bool invalid = false; 415 bool invalid = false;
416 while( true ) { 416 while( true ) {
417 if ( incidenceStart.isValid() ) { 417 if ( incidenceStart.isValid() ) {
418 incidenceEnd = incidenceStart.addDays( eventlen ); 418 incidenceEnd = incidenceStart.addDays( eventlen );
419 int st = incidenceStart.date().daysTo( endDate ); 419 int st = incidenceStart.date().daysTo( endDate );
420 if ( st >= 0 ) { // start before timeend 420 if ( st >= 0 ) { // start before timeend
421 int end = mStartDate.daysTo( incidenceEnd.date() ); 421 int end = mStartDate.daysTo( incidenceEnd.date() );
422 if ( end >= 0 ) { // end after timestart --- got one! 422 if ( end >= 0 ) { // end after timestart --- got one!
423 //normalize 423 //normalize
424 st = timeSpan - st; 424 st = timeSpan - st;
425 if ( st < 0 ) st = 0; 425 if ( st < 0 ) st = 0;
426 if ( end > timeSpan ) end = timeSpan; 426 if ( end > timeSpan ) end = timeSpan;
427 int iii; 427 int iii;
428 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 428 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
429 for ( iii = st;iii<= end;++iii) { 429 for ( iii = st;iii<= end;++iii) {
430 computeEvent( event, iii ); 430 computeEvent( event, iii );
431 } 431 }
432 } 432 }
433 } 433 }
434 } else { 434 } else {
435 if ( invalid ) 435 if ( invalid )
436 break; 436 break;
437 invalid = true; 437 invalid = true;
438 //qDebug("invalid %s", event->summary().latin1()); 438 //qDebug("invalid %s", event->summary().latin1());
439 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 439 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
440 } 440 }
441 if ( last ) 441 if ( last )
442 break; 442 break;
443 bool ok; 443 bool ok;
444 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 444 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
445 if ( ! ok ) 445 if ( ! ok )
446 break; 446 break;
447 if ( incidenceStart.date() > endDate ) 447 if ( incidenceStart.date() > endDate )
448 break; 448 break;
449 } 449 }
450 } else { // no recur 450 } else { // no recur
451 int st = event->dtStart().date().daysTo( endDate ); 451 int st = event->dtStart().date().daysTo( endDate );
452 if ( st >= 0 ) { // start before timeend 452 if ( st >= 0 ) { // start before timeend
453 int end = mStartDate.daysTo( event->dtEnd().date() ); 453 int end = mStartDate.daysTo( event->dtEnd().date() );
454 if ( end >= 0 ) { // end after timestart --- got one! 454 if ( end >= 0 ) { // end after timestart --- got one!
455 //normalize 455 //normalize
456 st = timeSpan - st; 456 st = timeSpan - st;
457 if ( st < 0 ) st = 0; 457 if ( st < 0 ) st = 0;
458 if ( end > timeSpan ) end = timeSpan; 458 if ( end > timeSpan ) end = timeSpan;
459 int iii; 459 int iii;
460 for ( iii = st;iii<= end;++iii) 460 for ( iii = st;iii<= end;++iii)
461 computeEvent( event, iii ); 461 computeEvent( event, iii );
462 } 462 }
463 } 463 }
464 } 464 }
465 } 465 }
466 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday 466 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
467 for(i = 0; i < NUMDAYS; i++) { 467 for(i = 0; i < NUMDAYS; i++) {
468 if ( ( (i+startDay) % 7 == 0 ) ) { 468 if ( ( (i+startDay) % 7 == 0 ) ) {
469 pDays.setBit(i); 469 pDays.setBit(i);
470 } 470 }
471 } 471 }
472 472
473#if 0 473#if 0
474 // insert due todos 474 // insert due todos
475 QPtrList<Todo> todos = calendar()->todos( ); 475 QPtrList<Todo> todos = calendar()->todos( );
476 Todo *todo; 476 Todo *todo;
477 for(todo = todos.first(); todo; todo = todos.next()) { 477 for(todo = todos.first(); todo; todo = todos.next()) {
478 //insertTodo( todo ); 478 //insertTodo( todo );
479 if ( todo->hasDueDate() ) { 479 if ( todo->hasDueDate() ) {
480 int day = mStartDate.daysTo( todo->dtDue().date() ); 480 int day = mStartDate.daysTo( todo->dtDue().date() );
481 if ( day >= 0 && day < timeSpan + 1) { 481 if ( day >= 0 && day < timeSpan + 1) {
482 (*cells)[day]->insertTodo( todo ); 482 (*cells)[day]->insertTodo( todo );
483 } 483 }
484 } 484 }
485 } 485 }
486#endif 486#endif
487 487
488#else 488#else
489 //qDebug("KODayMatrix::updateViewTimed "); 489 //qDebug("KODayMatrix::updateViewTimed ");
490 for(int i = 0; i < NUMDAYS; i++) { 490 for(int i = 0; i < NUMDAYS; i++) {
491 // 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
492 QPtrList<Event> eventlist = mCalendar->events(days[i]); 492 QPtrList<Event> eventlist = mCalendar->events(days[i]);
493 Event *event; 493 Event *event;
494 int numEvents = eventlist.count(); 494 int numEvents = eventlist.count();
495 QString holiStr = ""; 495 QString holiStr = "";
496 bDays.clearBit(i); 496 bDays.clearBit(i);
497 hDays.clearBit(i); 497 hDays.clearBit(i);
498 eDays.clearBit(i); 498 eDays.clearBit(i);
499 for(event=eventlist.first();event != 0;event=eventlist.next()) { 499 for(event=eventlist.first();event != 0;event=eventlist.next()) {
500 qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF ");
501 ushort recurType = event->recurrence()->doesRecur(); 500 ushort recurType = event->recurrence()->doesRecur();
502 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 501 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
503 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 502 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
504 numEvents--; 503 numEvents--;
505 } 504 }
506 if ( event->isHoliday()) { 505 if ( event->isHoliday()) {
507 hDays.setBit(i); 506 hDays.setBit(i);
508 if ( !holiStr.isEmpty() ) 507 if ( !holiStr.isEmpty() )
509 holiStr += "\n"; 508 holiStr += "\n";
510 holiStr += event->summary(); 509 holiStr += event->summary();
511 if ( !event->location().isEmpty() ) 510 if ( !event->location().isEmpty() )
512 holiStr += " (" + event->location() + ")"; 511 holiStr += " (" + event->location() + ")";
513 } 512 }
514 if ( event->isBirthday()) { 513 if ( event->isBirthday()) {
515 if ( !holiStr.isEmpty() ) 514 if ( !holiStr.isEmpty() )
516 holiStr += "\n"; 515 holiStr += "\n";
517 holiStr += i18n("Birthday") + ": "+event->summary(); 516 holiStr += i18n("Birthday") + ": "+event->summary();
518 if ( !event->location().isEmpty() ) 517 if ( !event->location().isEmpty() )
519 holiStr += " (" + event->location() + ")"; 518 holiStr += " (" + event->location() + ")";
520 bDays.setBit(i); 519 bDays.setBit(i);
521 } 520 }
522 } 521 }
523 if ( numEvents ) 522 if ( numEvents )
524 eDays.setBit(i); 523 eDays.setBit(i);
525 //if it is a holy day then draw it red. Sundays are consider holidays, too 524 //if it is a holy day then draw it red. Sundays are consider holidays, too
526 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 525 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
527 !holiStr.isEmpty()) { 526 !holiStr.isEmpty()) {
528 mHolidays[i] = holiStr; 527 mHolidays[i] = holiStr;
529 } else { 528 } else {
530 mHolidays[i] = QString::null; 529 mHolidays[i] = QString::null;
531 } 530 }
532 } 531 }
533#endif 532#endif
534 mRedrawNeeded = true; 533 mRedrawNeeded = true;
535 if ( ! mPendingUpdateBeforeRepaint ) 534 if ( ! mPendingUpdateBeforeRepaint )
536 repaint(false); 535 repaint(false);
537} 536}
538void KODayMatrix::updateView(QDate actdate) 537void KODayMatrix::updateView(QDate actdate)
539{ 538{
540 539
541 if ( ! actdate.isValid() ) { 540 if ( ! actdate.isValid() ) {
542 //qDebug("date not valid "); 541 //qDebug("date not valid ");
543 return; 542 return;
544 } 543 }
545 mDayChanged = false; 544 mDayChanged = false;
546 //flag to indicate if the starting day of the matrix has changed by this call 545 //flag to indicate if the starting day of the matrix has changed by this call
547 //mDayChanged = false; 546 //mDayChanged = false;
548 // if a new startdate is to be set then apply Cornelius's calculation 547 // if a new startdate is to be set then apply Cornelius's calculation
549 // of the first day to be shown 548 // of the first day to be shown
550 if (actdate != startdate) { 549 if (actdate != startdate) {
551 // reset index of selection according to shift of starting date from startdate to actdate 550 // reset index of selection according to shift of starting date from startdate to actdate
552 if (mSelStart != NOSELECTION) { 551 if (mSelStart != NOSELECTION) {
553 int tmp = actdate.daysTo(startdate); 552 int tmp = actdate.daysTo(startdate);
554 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 553 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
555 // shift selection if new one would be visible at least partly ! 554 // shift selection if new one would be visible at least partly !
556 555
557 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 556 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
558 // nested if is required for next X display pushed from a different month - correction required 557 // nested if is required for next X display pushed from a different month - correction required
559 // otherwise, for month forward and backward, it must be avoided 558 // otherwise, for month forward and backward, it must be avoided
560 if( mSelStart > NUMDAYS || mSelStart < 0 ) 559 if( mSelStart > NUMDAYS || mSelStart < 0 )
561 mSelStart = mSelStart + tmp; 560 mSelStart = mSelStart + tmp;
562 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 561 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
563 mSelEnd = mSelEnd + tmp; 562 mSelEnd = mSelEnd + tmp;
564 } 563 }
565 } 564 }
566 startdate = actdate; 565 startdate = actdate;
567 mDayChanged = true; 566 mDayChanged = true;
568 recalculateToday(); 567 recalculateToday();
569 mRedrawNeeded = true; 568 mRedrawNeeded = true;
570 } 569 }
571 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 570 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
572 if ( !isVisible() ) { 571 if ( !isVisible() ) {
573 mPendingUpdateBeforeRepaint = true; 572 mPendingUpdateBeforeRepaint = true;
574 } else { 573 } else {
575#ifdef DESKTOP_VERSION 574#ifdef DESKTOP_VERSION
576 //mRepaintTimer->start( 100 ); 575 //mRepaintTimer->start( 100 );
577 //updateViewTimed(); 576 //updateViewTimed();
578 mUpdateTimer->start( 50 ); 577 mUpdateTimer->start( 50 );
579#else 578#else
580 mRepaintTimer->start( 350 ); 579 mRepaintTimer->start( 350 );
581 mUpdateTimer->start( 800 ); 580 mUpdateTimer->start( 800 );
582#endif 581#endif
583 } 582 }
584} 583}
585void KODayMatrix::updateEvents() 584void KODayMatrix::updateEvents()
586{ 585{
587 if ( !mCalendar ) return; 586 if ( !mCalendar ) return;
588 587
589 for( int i = 0; i < NUMDAYS; i++ ) { 588 for( int i = 0; i < NUMDAYS; i++ ) {
590 // if events are set for the day then remember to draw it bold 589 // if events are set for the day then remember to draw it bold
591 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 590 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
592 int numEvents = eventlist.count(); 591 int numEvents = eventlist.count();
593 Event *event; 592 Event *event;
594 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 593 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
595 ushort recurType = event->doesRecur(); 594 ushort recurType = event->doesRecur();
596 595