author | zautrix <zautrix> | 2005-10-22 17:03:38 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-22 17:03:38 (UTC) |
commit | c1cb0653160e8e449d07a0df7b84b2398c0201fb (patch) (unidiff) | |
tree | 41c648d74574cb47b1e3341a918b448b86c264d9 | |
parent | 3ec18dd19fdf4eb7e763b8022f90de83249facfd (diff) | |
download | kdepimpi-c1cb0653160e8e449d07a0df7b84b2398c0201fb.zip kdepimpi-c1cb0653160e8e449d07a0df7b84b2398c0201fb.tar.gz kdepimpi-c1cb0653160e8e449d07a0df7b84b2398c0201fb.tar.bz2 |
fix
-rw-r--r-- | korganizer/kodaymatrix.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 7076e05..52fd1e8 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -475,386 +475,386 @@ void KODayMatrix::updateViewTimed() | |||
475 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 475 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
476 | if ( end >= 0 ) { // end after timestart --- got one! | 476 | if ( end >= 0 ) { // end after timestart --- got one! |
477 | //normalize | 477 | //normalize |
478 | st = timeSpan - st; | 478 | st = timeSpan - st; |
479 | if ( st < 0 ) st = 0; | 479 | if ( st < 0 ) st = 0; |
480 | if ( end > timeSpan ) end = timeSpan; | 480 | if ( end > timeSpan ) end = timeSpan; |
481 | int iii; | 481 | int iii; |
482 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 482 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
483 | for ( iii = st;iii<= end;++iii) { | 483 | for ( iii = st;iii<= end;++iii) { |
484 | computeEvent( event, iii ); | 484 | computeEvent( event, iii ); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | } | 487 | } |
488 | } else { | 488 | } else { |
489 | if ( invalid ) | 489 | if ( invalid ) |
490 | break; | 490 | break; |
491 | invalid = true; | 491 | invalid = true; |
492 | //qDebug("invalid %s", event->summary().latin1()); | 492 | //qDebug("invalid %s", event->summary().latin1()); |
493 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 493 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
494 | } | 494 | } |
495 | if ( last ) | 495 | if ( last ) |
496 | break; | 496 | break; |
497 | bool ok; | 497 | bool ok; |
498 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 498 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
499 | if ( ! ok ) | 499 | if ( ! ok ) |
500 | break; | 500 | break; |
501 | if ( incidenceStart.date() > endDate ) | 501 | if ( incidenceStart.date() > endDate ) |
502 | break; | 502 | break; |
503 | } | 503 | } |
504 | } else { // no recur | 504 | } else { // no recur |
505 | int st = event->dtStart().date().daysTo( endDate ); | 505 | int st = event->dtStart().date().daysTo( endDate ); |
506 | if ( st >= 0 ) { // start before timeend | 506 | if ( st >= 0 ) { // start before timeend |
507 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 507 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
508 | if ( end >= 0 ) { // end after timestart --- got one! | 508 | if ( end >= 0 ) { // end after timestart --- got one! |
509 | //normalize | 509 | //normalize |
510 | st = timeSpan - st; | 510 | st = timeSpan - st; |
511 | if ( st < 0 ) st = 0; | 511 | if ( st < 0 ) st = 0; |
512 | if ( end > timeSpan ) end = timeSpan; | 512 | if ( end > timeSpan ) end = timeSpan; |
513 | int iii; | 513 | int iii; |
514 | for ( iii = st;iii<= end;++iii) | 514 | for ( iii = st;iii<= end;++iii) |
515 | computeEvent( event, iii ); | 515 | computeEvent( event, iii ); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | } | 518 | } |
519 | } | 519 | } |
520 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday | 520 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday |
521 | for(i = 0; i < NUMDAYS; i++) { | 521 | for(i = 0; i < NUMDAYS; i++) { |
522 | if ( ( (i+startDay) % 7 == 0 ) ) { | 522 | if ( ( (i+startDay) % 7 == 0 ) ) { |
523 | pDays.setBit(i); | 523 | pDays.setBit(i); |
524 | } | 524 | } |
525 | } | 525 | } |
526 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 526 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
527 | bDays.fill( false); | 527 | bDays.fill( false); |
528 | // insert due todos | 528 | // insert due todos |
529 | QPtrList<Todo> todos = mCalendar->todos( ); | 529 | QPtrList<Todo> todos = mCalendar->todos( ); |
530 | Todo *todo; | 530 | Todo *todo; |
531 | for(todo = todos.first(); todo; todo = todos.next()) { | 531 | for(todo = todos.first(); todo; todo = todos.next()) { |
532 | //insertTodo( todo ); | 532 | //insertTodo( todo ); |
533 | if ( todo->hasDueDate() ) { | 533 | if ( todo->hasDueDate() ) { |
534 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 534 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
535 | if ( day >= 0 && day < timeSpan + 1) { | 535 | if ( day >= 0 && day < timeSpan + 1) { |
536 | int i = day; | 536 | int i = day; |
537 | QString holiStr = mHolidays[i]; | 537 | QString holiStr = mHolidays[i]; |
538 | pDays.setBit(i); | 538 | pDays.setBit(i); |
539 | if ( !holiStr.isEmpty() ) | 539 | if ( !holiStr.isEmpty() ) |
540 | holiStr += "\n"; | 540 | holiStr += "\n"; |
541 | holiStr += i18n("Todo") + ": "+todo->summary(); | 541 | holiStr += i18n("Todo") + ": "+todo->summary(); |
542 | if ( !todo->location().isEmpty() ) | 542 | if ( !todo->location().isEmpty() ) |
543 | holiStr += " (" + todo->location() + ")"; | 543 | holiStr += " (" + todo->location() + ")"; |
544 | bDays.setBit(i); | 544 | bDays.setBit(i); |
545 | mHolidays[i] =holiStr ; | 545 | mHolidays[i] =holiStr ; |
546 | eDays.setBit(i); | 546 | eDays.setBit(i); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | } | 549 | } |
550 | } | 550 | } |
551 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 551 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
552 | bDays.fill( false); | 552 | bDays.fill( false); |
553 | // insert due todos | 553 | // insert due todos |
554 | QPtrList<Journal> todos = mCalendar->journals( ); | 554 | QPtrList<Journal> todos = mCalendar->journals( ); |
555 | Journal *todo; | 555 | Journal *todo; |
556 | for(todo = todos.first(); todo; todo = todos.next()) { | 556 | for(todo = todos.first(); todo; todo = todos.next()) { |
557 | int day = mStartDate.daysTo( todo->dtStart().date() ); | 557 | int day = mStartDate.daysTo( todo->dtStart().date() ); |
558 | if ( day >= 0 && day < timeSpan + 1) { | 558 | if ( day >= 0 && day < timeSpan + 1) { |
559 | int i = day; | 559 | int i = day; |
560 | QString holiStr = mHolidays[i]; | 560 | QString holiStr = mHolidays[i]; |
561 | pDays.setBit(i); | 561 | pDays.setBit(i); |
562 | if ( !holiStr.isEmpty() ) | 562 | if ( !holiStr.isEmpty() ) |
563 | holiStr += "\n"; | 563 | holiStr += "\n"; |
564 | holiStr += i18n("Journal: ")+todo->summary().left(25); | 564 | holiStr += i18n("Journal: ")+todo->summary().left(25); |
565 | if ( todo->summary().length() > 25 ) | 565 | if ( todo->summary().length() > 25 ) |
566 | holiStr +="..."; | 566 | holiStr +="..."; |
567 | bDays.setBit(i); | 567 | bDays.setBit(i); |
568 | mHolidays[i] =holiStr ; | 568 | mHolidays[i] =holiStr ; |
569 | eDays.setBit(i); | 569 | eDays.setBit(i); |
570 | 570 | ||
571 | } | 571 | } |
572 | } | 572 | } |
573 | } | 573 | } |
574 | #else | 574 | #else |
575 | //qDebug("KODayMatrix::updateViewTimed "); | 575 | //qDebug("KODayMatrix::updateViewTimed "); |
576 | for(int i = 0; i < NUMDAYS; i++) { | 576 | for(int i = 0; i < NUMDAYS; i++) { |
577 | // if events are set for the day then remember to draw it bold | 577 | // if events are set for the day then remember to draw it bold |
578 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 578 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
579 | Event *event; | 579 | Event *event; |
580 | int numEvents = eventlist.count(); | 580 | int numEvents = eventlist.count(); |
581 | QString holiStr = ""; | 581 | QString holiStr = ""; |
582 | bDays.clearBit(i); | 582 | bDays.clearBit(i); |
583 | hDays.clearBit(i); | 583 | hDays.clearBit(i); |
584 | eDays.clearBit(i); | 584 | eDays.clearBit(i); |
585 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 585 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
586 | ushort recurType = event->recurrence()->doesRecur(); | 586 | ushort recurType = event->recurrence()->doesRecur(); |
587 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 587 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
588 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 588 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
589 | numEvents--; | 589 | numEvents--; |
590 | } | 590 | } |
591 | if ( event->isHoliday()) { | 591 | if ( event->isHoliday()) { |
592 | hDays.setBit(i); | 592 | hDays.setBit(i); |
593 | if ( !holiStr.isEmpty() ) | 593 | if ( !holiStr.isEmpty() ) |
594 | holiStr += "\n"; | 594 | holiStr += "\n"; |
595 | holiStr += event->summary(); | 595 | holiStr += event->summary(); |
596 | if ( !event->location().isEmpty() ) | 596 | if ( !event->location().isEmpty() ) |
597 | holiStr += " (" + event->location() + ")"; | 597 | holiStr += " (" + event->location() + ")"; |
598 | } | 598 | } |
599 | if ( event->isBirthday()) { | 599 | if ( event->isBirthday()) { |
600 | if ( !holiStr.isEmpty() ) | 600 | if ( !holiStr.isEmpty() ) |
601 | holiStr += "\n"; | 601 | holiStr += "\n"; |
602 | holiStr += i18n("Birthday") + ": "+event->summary(); | 602 | holiStr += i18n("Birthday") + ": "+event->summary(); |
603 | if ( !event->location().isEmpty() ) | 603 | if ( !event->location().isEmpty() ) |
604 | holiStr += " (" + event->location() + ")"; | 604 | holiStr += " (" + event->location() + ")"; |
605 | bDays.setBit(i); | 605 | bDays.setBit(i); |
606 | } | 606 | } |
607 | } | 607 | } |
608 | if ( numEvents ) | 608 | if ( numEvents ) |
609 | eDays.setBit(i); | 609 | eDays.setBit(i); |
610 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 610 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
611 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 611 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
612 | !holiStr.isEmpty()) { | 612 | !holiStr.isEmpty()) { |
613 | mHolidays[i] = holiStr; | 613 | mHolidays[i] = holiStr; |
614 | } else { | 614 | } else { |
615 | mHolidays[i] = QString::null; | 615 | mHolidays[i] = QString::null; |
616 | } | 616 | } |
617 | } | 617 | } |
618 | #endif | 618 | #endif |
619 | mRedrawNeeded = true; | 619 | mRedrawNeeded = true; |
620 | if ( ! mPendingUpdateBeforeRepaint ) | 620 | if ( ! mPendingUpdateBeforeRepaint ) |
621 | repaint(false); | 621 | repaint(false); |
622 | } | 622 | } |
623 | void KODayMatrix::updateView(QDate actdate) | 623 | void KODayMatrix::updateView(QDate actdate) |
624 | { | 624 | { |
625 | if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) | 625 | if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) |
626 | mRedrawNeeded = true; | 626 | mRedrawNeeded = true; |
627 | mLastView = KOPrefs::instance()->mCurrentDisplayedView; | 627 | mLastView = KOPrefs::instance()->mCurrentDisplayedView; |
628 | if ( ! actdate.isValid() ) { | 628 | if ( ! actdate.isValid() ) { |
629 | //qDebug("date not valid "); | 629 | //qDebug("date not valid "); |
630 | return; | 630 | return; |
631 | } | 631 | } |
632 | mDayChanged = false; | 632 | mDayChanged = false; |
633 | //flag to indicate if the starting day of the matrix has changed by this call | 633 | //flag to indicate if the starting day of the matrix has changed by this call |
634 | //mDayChanged = false; | 634 | //mDayChanged = false; |
635 | // if a new startdate is to be set then apply Cornelius's calculation | 635 | // if a new startdate is to be set then apply Cornelius's calculation |
636 | // of the first day to be shown | 636 | // of the first day to be shown |
637 | if (actdate != startdate) { | 637 | if (actdate != startdate) { |
638 | // reset index of selection according to shift of starting date from startdate to actdate | 638 | // reset index of selection according to shift of starting date from startdate to actdate |
639 | if (mSelStart != NOSELECTION) { | 639 | if (mSelStart != NOSELECTION) { |
640 | int tmp = actdate.daysTo(startdate); | 640 | int tmp = actdate.daysTo(startdate); |
641 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 641 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
642 | // shift selection if new one would be visible at least partly ! | 642 | // shift selection if new one would be visible at least partly ! |
643 | 643 | ||
644 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 644 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
645 | // 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 |
646 | // otherwise, for month forward and backward, it must be avoided | 646 | // otherwise, for month forward and backward, it must be avoided |
647 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 647 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
648 | mSelStart = mSelStart + tmp; | 648 | mSelStart = mSelStart + tmp; |
649 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 649 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
650 | mSelEnd = mSelEnd + tmp; | 650 | mSelEnd = mSelEnd + tmp; |
651 | } | 651 | } |
652 | } | 652 | } |
653 | startdate = actdate; | 653 | startdate = actdate; |
654 | mDayChanged = true; | 654 | mDayChanged = true; |
655 | recalculateToday(); | 655 | recalculateToday(); |
656 | mRedrawNeeded = true; | 656 | mRedrawNeeded = true; |
657 | } | 657 | } |
658 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 658 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
659 | if ( !isVisible() ) { | 659 | if ( !isVisible() ) { |
660 | mPendingUpdateBeforeRepaint = true; | 660 | mPendingUpdateBeforeRepaint = true; |
661 | } else { | 661 | } else { |
662 | #ifdef DESKTOP_VERSION | 662 | #ifdef DESKTOP_VERSION |
663 | //mRepaintTimer->start( 100 ); | 663 | //mRepaintTimer->start( 100 ); |
664 | //updateViewTimed(); | 664 | //updateViewTimed(); |
665 | mUpdateTimer->start( 50 ); | 665 | mUpdateTimer->start( 50 ); |
666 | #else | 666 | #else |
667 | mRepaintTimer->start( 350 ); | 667 | mRepaintTimer->start( 250 ); |
668 | mUpdateTimer->start( 800 ); | 668 | mUpdateTimer->start( 500 ); |
669 | #endif | 669 | #endif |
670 | } | 670 | } |
671 | } | 671 | } |
672 | void KODayMatrix::updateEvents() | 672 | void KODayMatrix::updateEvents() |
673 | { | 673 | { |
674 | if ( !mCalendar ) return; | 674 | if ( !mCalendar ) return; |
675 | 675 | ||
676 | for( int i = 0; i < NUMDAYS; i++ ) { | 676 | for( int i = 0; i < NUMDAYS; i++ ) { |
677 | // 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 |
678 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 678 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
679 | int numEvents = eventlist.count(); | 679 | int numEvents = eventlist.count(); |
680 | Event *event; | 680 | Event *event; |
681 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 681 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
682 | ushort recurType = event->doesRecur(); | 682 | ushort recurType = event->doesRecur(); |
683 | 683 | ||
684 | if ( ( recurType == Recurrence::rDaily && | 684 | if ( ( recurType == Recurrence::rDaily && |
685 | !KOPrefs::instance()->mDailyRecur ) || | 685 | !KOPrefs::instance()->mDailyRecur ) || |
686 | ( recurType == Recurrence::rWeekly && | 686 | ( recurType == Recurrence::rWeekly && |
687 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 687 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
688 | numEvents--; | 688 | numEvents--; |
689 | } | 689 | } |
690 | if ( !KOPrefs::instance()->mLongAllday && event->doesFloat()&& event->isMultiDay() ) { | 690 | if ( !KOPrefs::instance()->mLongAllday && event->doesFloat()&& event->isMultiDay() ) { |
691 | numEvents--; | 691 | numEvents--; |
692 | } | 692 | } |
693 | } | 693 | } |
694 | if ( numEvents ) | 694 | if ( numEvents ) |
695 | eDays.setBit(i); | 695 | eDays.setBit(i); |
696 | else | 696 | else |
697 | eDays.clearBit(i); | 697 | eDays.clearBit(i); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | 700 | ||
701 | const QDate& KODayMatrix::getDate(int offset) | 701 | const QDate& KODayMatrix::getDate(int offset) |
702 | { | 702 | { |
703 | if (offset < 0 || offset > NUMDAYS-1) { | 703 | if (offset < 0 || offset > NUMDAYS-1) { |
704 | qDebug("Wrong offset2 %d", offset); | 704 | qDebug("Wrong offset2 %d", offset); |
705 | return days[0]; | 705 | return days[0]; |
706 | } | 706 | } |
707 | return days[offset]; | 707 | return days[offset]; |
708 | } | 708 | } |
709 | 709 | ||
710 | QString KODayMatrix::getHolidayLabel(int offset) | 710 | QString KODayMatrix::getHolidayLabel(int offset) |
711 | { | 711 | { |
712 | if (offset < 0 || offset > NUMDAYS-1) { | 712 | if (offset < 0 || offset > NUMDAYS-1) { |
713 | qDebug("Wrong offset1 %d", offset); | 713 | qDebug("Wrong offset1 %d", offset); |
714 | return QString(); | 714 | return QString(); |
715 | } | 715 | } |
716 | return mHolidays[offset]; | 716 | return mHolidays[offset]; |
717 | } | 717 | } |
718 | 718 | ||
719 | int KODayMatrix::getDayIndexFrom(int x, int y) | 719 | int KODayMatrix::getDayIndexFrom(int x, int y) |
720 | { | 720 | { |
721 | int colModulo = (width()-2) % 7; | 721 | int colModulo = (width()-2) % 7; |
722 | int rowModulo = (height()-2) % 6; | 722 | int rowModulo = (height()-2) % 6; |
723 | #if 0 | 723 | #if 0 |
724 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 724 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
725 | 6 - x/daysize.width() : x/daysize.width()); | 725 | 6 - x/daysize.width() : x/daysize.width()); |
726 | #endif | 726 | #endif |
727 | int xVal = (x-colModulo/2-2)/daysize.width(); | 727 | int xVal = (x-colModulo/2-2)/daysize.width(); |
728 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 728 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
729 | 729 | ||
730 | 730 | ||
731 | return 7*(yVal) + xVal; | 731 | return 7*(yVal) + xVal; |
732 | 732 | ||
733 | } | 733 | } |
734 | 734 | ||
735 | // ---------------------------------------------------------------------------- | 735 | // ---------------------------------------------------------------------------- |
736 | // 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 |
737 | // ---------------------------------------------------------------------------- | 737 | // ---------------------------------------------------------------------------- |
738 | 738 | ||
739 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 739 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
740 | { | 740 | { |
741 | 741 | ||
742 | if ( e->button() == LeftButton ) | 742 | if ( e->button() == LeftButton ) |
743 | mouseDown = true; | 743 | mouseDown = true; |
744 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 744 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
745 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 745 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
746 | mSelInit = mSelStart; | 746 | mSelInit = mSelStart; |
747 | mSelEnd = mSelStart; | 747 | mSelEnd = mSelStart; |
748 | mRedrawNeeded = true; | 748 | mRedrawNeeded = true; |
749 | repaint(false); | 749 | repaint(false); |
750 | } | 750 | } |
751 | 751 | ||
752 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 752 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
753 | { | 753 | { |
754 | mRedrawNeeded = true; | 754 | mRedrawNeeded = true; |
755 | if ( e->button() == LeftButton ) | 755 | if ( e->button() == LeftButton ) |
756 | if ( ! mouseDown ) { | 756 | if ( ! mouseDown ) { |
757 | return; | 757 | return; |
758 | } | 758 | } |
759 | else | 759 | else |
760 | mouseDown = false; | 760 | mouseDown = false; |
761 | int tmp = getDayIndexFrom(e->x(), e->y()); | 761 | int tmp = getDayIndexFrom(e->x(), e->y()); |
762 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 762 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
763 | 763 | ||
764 | if (mSelInit > tmp) { | 764 | if (mSelInit > tmp) { |
765 | mSelEnd = mSelInit; | 765 | mSelEnd = mSelInit; |
766 | if (tmp != mSelStart) { | 766 | if (tmp != mSelStart) { |
767 | mSelStart = tmp; | 767 | mSelStart = tmp; |
768 | repaint(false); | 768 | repaint(false); |
769 | } | 769 | } |
770 | } else { | 770 | } else { |
771 | mSelStart = mSelInit; | 771 | mSelStart = mSelInit; |
772 | 772 | ||
773 | //repaint only if selection has changed | 773 | //repaint only if selection has changed |
774 | if (tmp != mSelEnd) { | 774 | if (tmp != mSelEnd) { |
775 | mSelEnd = tmp; | 775 | mSelEnd = tmp; |
776 | repaint(false); | 776 | repaint(false); |
777 | } | 777 | } |
778 | } | 778 | } |
779 | 779 | ||
780 | DateList daylist; | 780 | DateList daylist; |
781 | if ( mSelStart < 0 ) | 781 | if ( mSelStart < 0 ) |
782 | mSelStart = 0; | 782 | mSelStart = 0; |
783 | for (int i = mSelStart; i <= mSelEnd; i++) { | 783 | for (int i = mSelStart; i <= mSelEnd; i++) { |
784 | daylist.append(days[i]); | 784 | daylist.append(days[i]); |
785 | } | 785 | } |
786 | emit selected((const DateList)daylist); | 786 | emit selected((const DateList)daylist); |
787 | 787 | ||
788 | } | 788 | } |
789 | 789 | ||
790 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 790 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
791 | { | 791 | { |
792 | if ( ! mouseDown ) { | 792 | if ( ! mouseDown ) { |
793 | return; | 793 | return; |
794 | } | 794 | } |
795 | mRedrawNeeded = true; | 795 | mRedrawNeeded = true; |
796 | int tmp = getDayIndexFrom(e->x(), e->y()); | 796 | int tmp = getDayIndexFrom(e->x(), e->y()); |
797 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 797 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
798 | 798 | ||
799 | if (mSelInit > tmp) { | 799 | if (mSelInit > tmp) { |
800 | mSelEnd = mSelInit; | 800 | mSelEnd = mSelInit; |
801 | if (tmp != mSelStart) { | 801 | if (tmp != mSelStart) { |
802 | mSelStart = tmp; | 802 | mSelStart = tmp; |
803 | repaint(false); | 803 | repaint(false); |
804 | } | 804 | } |
805 | } else { | 805 | } else { |
806 | mSelStart = mSelInit; | 806 | mSelStart = mSelInit; |
807 | 807 | ||
808 | //repaint only if selection has changed | 808 | //repaint only if selection has changed |
809 | if (tmp != mSelEnd) { | 809 | if (tmp != mSelEnd) { |
810 | mSelEnd = tmp; | 810 | mSelEnd = tmp; |
811 | repaint(false); | 811 | repaint(false); |
812 | } | 812 | } |
813 | } | 813 | } |
814 | } | 814 | } |
815 | 815 | ||
816 | // ---------------------------------------------------------------------------- | 816 | // ---------------------------------------------------------------------------- |
817 | // D R A G ' N D R O P H A N D L I N G | 817 | // D R A G ' N D R O P H A N D L I N G |
818 | // ---------------------------------------------------------------------------- | 818 | // ---------------------------------------------------------------------------- |
819 | 819 | ||
820 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 820 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
821 | { | 821 | { |
822 | #ifndef KORG_NODND | 822 | #ifndef KORG_NODND |
823 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 823 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
824 | e->ignore(); | 824 | e->ignore(); |
825 | return; | 825 | return; |
826 | } | 826 | } |
827 | 827 | ||
828 | // some visual feedback | 828 | // some visual feedback |
829 | // oldPalette = palette(); | 829 | // oldPalette = palette(); |
830 | // setPalette(my_HilitePalette); | 830 | // setPalette(my_HilitePalette); |
831 | // update(); | 831 | // update(); |
832 | #endif | 832 | #endif |
833 | } | 833 | } |
834 | 834 | ||
835 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 835 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
836 | { | 836 | { |
837 | #ifndef KORG_NODND | 837 | #ifndef KORG_NODND |
838 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 838 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
839 | e->ignore(); | 839 | e->ignore(); |
840 | return; | 840 | return; |
841 | } | 841 | } |
842 | 842 | ||
843 | e->accept(); | 843 | e->accept(); |
844 | #endif | 844 | #endif |
845 | } | 845 | } |
846 | 846 | ||
847 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 847 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
848 | { | 848 | { |
849 | #ifndef KORG_NODND | 849 | #ifndef KORG_NODND |
850 | // setPalette(oldPalette); | 850 | // setPalette(oldPalette); |
851 | // update(); | 851 | // update(); |
852 | #endif | 852 | #endif |
853 | } | 853 | } |
854 | 854 | ||
855 | void KODayMatrix::dropEvent(QDropEvent *e) | 855 | void KODayMatrix::dropEvent(QDropEvent *e) |
856 | { | 856 | { |
857 | #ifndef KORG_NODND | 857 | #ifndef KORG_NODND |
858 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 858 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
859 | 859 | ||
860 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 860 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |