-rw-r--r-- | korganizer/kodaymatrix.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 057df0d..7076e05 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -413,96 +413,99 @@ void KODayMatrix::computeEvent(Event *event, int i ) | |||
413 | holiStr += " (" + event->location() + ")"; | 413 | holiStr += " (" + event->location() + ")"; |
414 | mHolidays[i] =holiStr ; | 414 | mHolidays[i] =holiStr ; |
415 | eDays.setBit(i); | 415 | eDays.setBit(i); |
416 | } | 416 | } |
417 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { | 417 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { |
418 | if ( event->isBirthday()) { | 418 | if ( event->isBirthday()) { |
419 | pDays.setBit(i); | 419 | pDays.setBit(i); |
420 | if ( !holiStr.isEmpty() ) | 420 | if ( !holiStr.isEmpty() ) |
421 | holiStr += "\n"; | 421 | holiStr += "\n"; |
422 | holiStr += i18n("Birthday") + ": "+event->summary(); | 422 | holiStr += i18n("Birthday") + ": "+event->summary(); |
423 | if ( !event->location().isEmpty() ) | 423 | if ( !event->location().isEmpty() ) |
424 | holiStr += " (" + event->location() + ")"; | 424 | holiStr += " (" + event->location() + ")"; |
425 | bDays.setBit(i); | 425 | bDays.setBit(i); |
426 | mHolidays[i] =holiStr ; | 426 | mHolidays[i] =holiStr ; |
427 | } | 427 | } |
428 | } | 428 | } |
429 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) | 429 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) |
430 | eDays.setBit(i); | 430 | eDays.setBit(i); |
431 | } | 431 | } |
432 | void KODayMatrix::updateViewTimed() | 432 | void KODayMatrix::updateViewTimed() |
433 | { | 433 | { |
434 | mUpdateTimer->stop(); | 434 | mUpdateTimer->stop(); |
435 | if ( !mCalendar ) { | 435 | if ( !mCalendar ) { |
436 | qDebug("NOT CAL "); | 436 | qDebug("NOT CAL "); |
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | #if 1 | 439 | #if 1 |
440 | 440 | ||
441 | 441 | ||
442 | int i; | 442 | int i; |
443 | int timeSpan = NUMDAYS-1; | 443 | int timeSpan = NUMDAYS-1; |
444 | QPtrList<Event> events = mCalendar->events(); | 444 | QPtrList<Event> events = mCalendar->events(); |
445 | Event *event; | 445 | Event *event; |
446 | QDateTime dt; | 446 | QDateTime dt; |
447 | bool ok; | 447 | bool ok; |
448 | bDays.fill( false); | 448 | bDays.fill( false); |
449 | pDays.fill( false); | 449 | pDays.fill( false); |
450 | hDays.fill( false); | 450 | hDays.fill( false); |
451 | eDays.fill( false); | 451 | eDays.fill( false); |
452 | mHolidays.clear(); | 452 | mHolidays.clear(); |
453 | QDate mStartDate = days[0]; | 453 | QDate mStartDate = days[0]; |
454 | QDate endDate = mStartDate.addDays( timeSpan ); | 454 | QDate endDate = mStartDate.addDays( timeSpan ); |
455 | for( event = events.first(); event; event = events.next() ) { // for event | 455 | for( event = events.first(); event; event = events.next() ) { // for event |
456 | ushort recurType = event->doesRecur(); | 456 | ushort recurType = event->doesRecur(); |
457 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 457 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
458 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 458 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
459 | continue; | 459 | continue; |
460 | } | 460 | } |
461 | if ( !KOPrefs::instance()->mLongAllday && event->doesFloat()&& event->isMultiDay() ) { | ||
462 | continue; | ||
463 | } | ||
461 | if ( event->doesRecur() ) { | 464 | if ( event->doesRecur() ) { |
462 | bool last; | 465 | bool last; |
463 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 466 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
464 | QDateTime incidenceEnd; | 467 | QDateTime incidenceEnd; |
465 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 468 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
466 | bool invalid = false; | 469 | bool invalid = false; |
467 | while( true ) { | 470 | while( true ) { |
468 | if ( incidenceStart.isValid() ) { | 471 | if ( incidenceStart.isValid() ) { |
469 | incidenceEnd = incidenceStart.addDays( eventlen ); | 472 | incidenceEnd = incidenceStart.addDays( eventlen ); |
470 | int st = incidenceStart.date().daysTo( endDate ); | 473 | int st = incidenceStart.date().daysTo( endDate ); |
471 | if ( st >= 0 ) { // start before timeend | 474 | if ( st >= 0 ) { // start before timeend |
472 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 475 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
473 | if ( end >= 0 ) { // end after timestart --- got one! | 476 | if ( end >= 0 ) { // end after timestart --- got one! |
474 | //normalize | 477 | //normalize |
475 | st = timeSpan - st; | 478 | st = timeSpan - st; |
476 | if ( st < 0 ) st = 0; | 479 | if ( st < 0 ) st = 0; |
477 | if ( end > timeSpan ) end = timeSpan; | 480 | if ( end > timeSpan ) end = timeSpan; |
478 | int iii; | 481 | int iii; |
479 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 482 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
480 | for ( iii = st;iii<= end;++iii) { | 483 | for ( iii = st;iii<= end;++iii) { |
481 | computeEvent( event, iii ); | 484 | computeEvent( event, iii ); |
482 | } | 485 | } |
483 | } | 486 | } |
484 | } | 487 | } |
485 | } else { | 488 | } else { |
486 | if ( invalid ) | 489 | if ( invalid ) |
487 | break; | 490 | break; |
488 | invalid = true; | 491 | invalid = true; |
489 | //qDebug("invalid %s", event->summary().latin1()); | 492 | //qDebug("invalid %s", event->summary().latin1()); |
490 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 493 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
491 | } | 494 | } |
492 | if ( last ) | 495 | if ( last ) |
493 | break; | 496 | break; |
494 | bool ok; | 497 | bool ok; |
495 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 498 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
496 | if ( ! ok ) | 499 | if ( ! ok ) |
497 | break; | 500 | break; |
498 | if ( incidenceStart.date() > endDate ) | 501 | if ( incidenceStart.date() > endDate ) |
499 | break; | 502 | break; |
500 | } | 503 | } |
501 | } else { // no recur | 504 | } else { // no recur |
502 | int st = event->dtStart().date().daysTo( endDate ); | 505 | int st = event->dtStart().date().daysTo( endDate ); |
503 | if ( st >= 0 ) { // start before timeend | 506 | if ( st >= 0 ) { // start before timeend |
504 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 507 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
505 | if ( end >= 0 ) { // end after timestart --- got one! | 508 | if ( end >= 0 ) { // end after timestart --- got one! |
506 | //normalize | 509 | //normalize |
507 | st = timeSpan - st; | 510 | st = timeSpan - st; |
508 | if ( st < 0 ) st = 0; | 511 | if ( st < 0 ) st = 0; |
@@ -639,96 +642,99 @@ void KODayMatrix::updateView(QDate actdate) | |||
639 | // shift selection if new one would be visible at least partly ! | 642 | // shift selection if new one would be visible at least partly ! |
640 | 643 | ||
641 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 644 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
642 | // nested if is required for next X display pushed from a different month - correction required | 645 | // nested if is required for next X display pushed from a different month - correction required |
643 | // otherwise, for month forward and backward, it must be avoided | 646 | // otherwise, for month forward and backward, it must be avoided |
644 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 647 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
645 | mSelStart = mSelStart + tmp; | 648 | mSelStart = mSelStart + tmp; |
646 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 649 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
647 | mSelEnd = mSelEnd + tmp; | 650 | mSelEnd = mSelEnd + tmp; |
648 | } | 651 | } |
649 | } | 652 | } |
650 | startdate = actdate; | 653 | startdate = actdate; |
651 | mDayChanged = true; | 654 | mDayChanged = true; |
652 | recalculateToday(); | 655 | recalculateToday(); |
653 | mRedrawNeeded = true; | 656 | mRedrawNeeded = true; |
654 | } | 657 | } |
655 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 658 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
656 | if ( !isVisible() ) { | 659 | if ( !isVisible() ) { |
657 | mPendingUpdateBeforeRepaint = true; | 660 | mPendingUpdateBeforeRepaint = true; |
658 | } else { | 661 | } else { |
659 | #ifdef DESKTOP_VERSION | 662 | #ifdef DESKTOP_VERSION |
660 | //mRepaintTimer->start( 100 ); | 663 | //mRepaintTimer->start( 100 ); |
661 | //updateViewTimed(); | 664 | //updateViewTimed(); |
662 | mUpdateTimer->start( 50 ); | 665 | mUpdateTimer->start( 50 ); |
663 | #else | 666 | #else |
664 | mRepaintTimer->start( 350 ); | 667 | mRepaintTimer->start( 350 ); |
665 | mUpdateTimer->start( 800 ); | 668 | mUpdateTimer->start( 800 ); |
666 | #endif | 669 | #endif |
667 | } | 670 | } |
668 | } | 671 | } |
669 | void KODayMatrix::updateEvents() | 672 | void KODayMatrix::updateEvents() |
670 | { | 673 | { |
671 | if ( !mCalendar ) return; | 674 | if ( !mCalendar ) return; |
672 | 675 | ||
673 | for( int i = 0; i < NUMDAYS; i++ ) { | 676 | for( int i = 0; i < NUMDAYS; i++ ) { |
674 | // if events are set for the day then remember to draw it bold | 677 | // if events are set for the day then remember to draw it bold |
675 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 678 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
676 | int numEvents = eventlist.count(); | 679 | int numEvents = eventlist.count(); |
677 | Event *event; | 680 | Event *event; |
678 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 681 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
679 | ushort recurType = event->doesRecur(); | 682 | ushort recurType = event->doesRecur(); |
680 | 683 | ||
681 | if ( ( recurType == Recurrence::rDaily && | 684 | if ( ( recurType == Recurrence::rDaily && |
682 | !KOPrefs::instance()->mDailyRecur ) || | 685 | !KOPrefs::instance()->mDailyRecur ) || |
683 | ( recurType == Recurrence::rWeekly && | 686 | ( recurType == Recurrence::rWeekly && |
684 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 687 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
685 | numEvents--; | 688 | numEvents--; |
686 | } | 689 | } |
690 | if ( !KOPrefs::instance()->mLongAllday && event->doesFloat()&& event->isMultiDay() ) { | ||
691 | numEvents--; | ||
692 | } | ||
687 | } | 693 | } |
688 | if ( numEvents ) | 694 | if ( numEvents ) |
689 | eDays.setBit(i); | 695 | eDays.setBit(i); |
690 | else | 696 | else |
691 | eDays.clearBit(i); | 697 | eDays.clearBit(i); |
692 | } | 698 | } |
693 | } | 699 | } |
694 | 700 | ||
695 | const QDate& KODayMatrix::getDate(int offset) | 701 | const QDate& KODayMatrix::getDate(int offset) |
696 | { | 702 | { |
697 | if (offset < 0 || offset > NUMDAYS-1) { | 703 | if (offset < 0 || offset > NUMDAYS-1) { |
698 | qDebug("Wrong offset2 %d", offset); | 704 | qDebug("Wrong offset2 %d", offset); |
699 | return days[0]; | 705 | return days[0]; |
700 | } | 706 | } |
701 | return days[offset]; | 707 | return days[offset]; |
702 | } | 708 | } |
703 | 709 | ||
704 | QString KODayMatrix::getHolidayLabel(int offset) | 710 | QString KODayMatrix::getHolidayLabel(int offset) |
705 | { | 711 | { |
706 | if (offset < 0 || offset > NUMDAYS-1) { | 712 | if (offset < 0 || offset > NUMDAYS-1) { |
707 | qDebug("Wrong offset1 %d", offset); | 713 | qDebug("Wrong offset1 %d", offset); |
708 | return QString(); | 714 | return QString(); |
709 | } | 715 | } |
710 | return mHolidays[offset]; | 716 | return mHolidays[offset]; |
711 | } | 717 | } |
712 | 718 | ||
713 | int KODayMatrix::getDayIndexFrom(int x, int y) | 719 | int KODayMatrix::getDayIndexFrom(int x, int y) |
714 | { | 720 | { |
715 | int colModulo = (width()-2) % 7; | 721 | int colModulo = (width()-2) % 7; |
716 | int rowModulo = (height()-2) % 6; | 722 | int rowModulo = (height()-2) % 6; |
717 | #if 0 | 723 | #if 0 |
718 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 724 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
719 | 6 - x/daysize.width() : x/daysize.width()); | 725 | 6 - x/daysize.width() : x/daysize.width()); |
720 | #endif | 726 | #endif |
721 | int xVal = (x-colModulo/2-2)/daysize.width(); | 727 | int xVal = (x-colModulo/2-2)/daysize.width(); |
722 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 728 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
723 | 729 | ||
724 | 730 | ||
725 | return 7*(yVal) + xVal; | 731 | return 7*(yVal) + xVal; |
726 | 732 | ||
727 | } | 733 | } |
728 | 734 | ||
729 | // ---------------------------------------------------------------------------- | 735 | // ---------------------------------------------------------------------------- |
730 | // M O U S E E V E N T H A N D L I N G | 736 | // M O U S E E V E N T H A N D L I N G |
731 | // ---------------------------------------------------------------------------- | 737 | // ---------------------------------------------------------------------------- |
732 | 738 | ||
733 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 739 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
734 | { | 740 | { |