-rw-r--r-- | korganizer/komonthview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index eea9a4d..4aeb20c 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -600,1025 +600,1029 @@ QPalette MonthViewCell::getPalette () | |||
600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
601 | return mStandardPalette; | 601 | return mStandardPalette; |
602 | if ( mHoliday) { | 602 | if ( mHoliday) { |
603 | return mHolidayPalette ; | 603 | return mHolidayPalette ; |
604 | } else { | 604 | } else { |
605 | if ( mPrimary ) { | 605 | if ( mPrimary ) { |
606 | return mPrimaryPalette ; | 606 | return mPrimaryPalette ; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | return mNonPrimaryPalette; | 609 | return mNonPrimaryPalette; |
610 | } | 610 | } |
611 | bool MonthViewCell::isPrimary() const | 611 | bool MonthViewCell::isPrimary() const |
612 | { | 612 | { |
613 | return mPrimary; | 613 | return mPrimary; |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::setHoliday( bool holiday ) | 616 | void MonthViewCell::setHoliday( bool holiday ) |
617 | { | 617 | { |
618 | mHoliday = holiday; | 618 | mHoliday = holiday; |
619 | //setMyPalette(); | 619 | //setMyPalette(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void MonthViewCell::setHoliday( const QString &holiday ) | 622 | void MonthViewCell::setHoliday( const QString &holiday ) |
623 | { | 623 | { |
624 | mHolidayString = holiday; | 624 | mHolidayString = holiday; |
625 | 625 | ||
626 | if ( !holiday.isEmpty() ) { | 626 | if ( !holiday.isEmpty() ) { |
627 | setHoliday( true ); | 627 | setHoliday( true ); |
628 | } | 628 | } |
629 | } | 629 | } |
630 | 630 | ||
631 | void MonthViewCell::startUpdateCell() | 631 | void MonthViewCell::startUpdateCell() |
632 | { | 632 | { |
633 | blockSignals( true ); | 633 | blockSignals( true ); |
634 | mdayCount = 0; | 634 | mdayCount = 0; |
635 | setFocusPolicy(NoFocus); | 635 | setFocusPolicy(NoFocus); |
636 | if ( !mMonthView->isUpdatePossible() ) | 636 | if ( !mMonthView->isUpdatePossible() ) |
637 | return; | 637 | return; |
638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
639 | while ( mitem ) { | 639 | while ( mitem ) { |
640 | mitem->setBlockRepaint( true ); | 640 | mitem->setBlockRepaint( true ); |
641 | mitem = (MonthViewItem *)mitem->next(); | 641 | mitem = (MonthViewItem *)mitem->next(); |
642 | } | 642 | } |
643 | if ( mAvailItemList.count() > 20 ) { | 643 | if ( mAvailItemList.count() > 20 ) { |
644 | mAvailItemList.setAutoDelete( true ); | 644 | mAvailItemList.setAutoDelete( true ); |
645 | mAvailItemList.clear(); | 645 | mAvailItemList.clear(); |
646 | mAvailItemList.setAutoDelete( false ); | 646 | mAvailItemList.setAutoDelete( false ); |
647 | clear(); | 647 | clear(); |
648 | } | 648 | } |
649 | 649 | ||
650 | setPrimary( mDate.month()%2 ); | 650 | setPrimary( mDate.month()%2 ); |
651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
652 | if ( mDate == QDate::currentDate() ) { | 652 | if ( mDate == QDate::currentDate() ) { |
653 | setLineWidth( 3 ); | 653 | setLineWidth( 3 ); |
654 | } else { | 654 | } else { |
655 | setLineWidth( 1 ); | 655 | setLineWidth( 1 ); |
656 | } | 656 | } |
657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
658 | //clear(); | 658 | //clear(); |
659 | while ( CurrentAvailItem ) { | 659 | while ( CurrentAvailItem ) { |
660 | MonthViewItem *item = CurrentAvailItem; | 660 | MonthViewItem *item = CurrentAvailItem; |
661 | //item->setHighlightedFalse(); | 661 | //item->setHighlightedFalse(); |
662 | item->recycle( 0, ""); | 662 | item->recycle( 0, ""); |
663 | CurrentAvailItem = (MonthViewItem *)item->next(); | 663 | CurrentAvailItem = (MonthViewItem *)item->next(); |
664 | mAvailItemList.append( item ); | 664 | mAvailItemList.append( item ); |
665 | takeItem ( item ); | 665 | takeItem ( item ); |
666 | } | 666 | } |
667 | 667 | ||
668 | #ifdef DESKTOP_VERSION | 668 | #ifdef DESKTOP_VERSION |
669 | QToolTip::remove(this); | 669 | QToolTip::remove(this); |
670 | #endif | 670 | #endif |
671 | mToolTip.clear(); | 671 | mToolTip.clear(); |
672 | //qApp->processEvents(); | 672 | //qApp->processEvents(); |
673 | #if 0 | 673 | #if 0 |
674 | if ( !mHolidayString.isEmpty() ) { | 674 | if ( !mHolidayString.isEmpty() ) { |
675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
676 | item->setPalette( mHolidayPalette ); | 676 | item->setPalette( mHolidayPalette ); |
677 | insertItem( item ); | 677 | insertItem( item ); |
678 | mToolTip.append ( mHolidayString ); | 678 | mToolTip.append ( mHolidayString ); |
679 | } | 679 | } |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | int MonthViewCell::insertEvent(Event *event) | 683 | int MonthViewCell::insertEvent(Event *event) |
684 | { | 684 | { |
685 | bool useToolTips = true; | 685 | bool useToolTips = true; |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | useToolTips = false; | 687 | useToolTips = false; |
688 | #endif | 688 | #endif |
689 | QString mToolTipText; | 689 | QString mToolTipText; |
690 | setFocusPolicy(WheelFocus); | 690 | setFocusPolicy(WheelFocus); |
691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
693 | return mdayCount; | 693 | return mdayCount; |
694 | else | 694 | else |
695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
696 | return mdayCount; | 696 | return mdayCount; |
697 | } | 697 | } |
698 | 698 | ||
699 | if ( event->isHoliday()) { | 699 | if ( event->isHoliday()) { |
700 | setHoliday( true ); | 700 | setHoliday( true ); |
701 | if ( mDate.dayOfWeek() == 7 ) | 701 | if ( mDate.dayOfWeek() == 7 ) |
702 | setLineWidth( 3 ); | 702 | setLineWidth( 3 ); |
703 | } | 703 | } |
704 | QString text; | 704 | QString text; |
705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
706 | if (event->isMultiDay()) { | 706 | if (event->isMultiDay()) { |
707 | QString prefix = "<->";multiday = 2; | 707 | QString prefix = "<->";multiday = 2; |
708 | QString time; | 708 | QString time; |
709 | if ( event->doesRecur() ) { | 709 | if ( event->doesRecur() ) { |
710 | if ( event->recursOn( mDate) ) { | 710 | if ( event->recursOn( mDate) ) { |
711 | prefix ="->" ;multiday = 1; | 711 | prefix ="->" ;multiday = 1; |
712 | } | 712 | } |
713 | else { | 713 | else { |
714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
715 | if ( event->recursOn( mDate.addDays( -days)) ) { | 715 | if ( event->recursOn( mDate.addDays( -days)) ) { |
716 | prefix ="<-" ;multiday = 3; | 716 | prefix ="<-" ;multiday = 3; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | } else { | 720 | } else { |
721 | if (mDate == event->dtStart().date()) { | 721 | if (mDate == event->dtStart().date()) { |
722 | prefix ="->" ;multiday = 1; | 722 | prefix ="->" ;multiday = 1; |
723 | } else if (mDate == event->dtEnd().date()) { | 723 | } else if (mDate == event->dtEnd().date()) { |
724 | prefix ="<-" ;multiday = 3; | 724 | prefix ="<-" ;multiday = 3; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | if ( !event->doesFloat() ) { | 727 | if ( !event->doesFloat() ) { |
728 | if ( mDate == event->dtStart().date () ) | 728 | if ( mDate == event->dtStart().date () ) |
729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
730 | else if ( mDate == event->dtEnd().date () ) | 730 | else if ( mDate == event->dtEnd().date () ) |
731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
732 | 732 | ||
733 | } | 733 | } |
734 | text = time + event->summary(); | 734 | text = time + event->summary(); |
735 | if ( useToolTips ) | 735 | if ( useToolTips ) |
736 | mToolTipText += prefix + text; | 736 | mToolTipText += prefix + text; |
737 | } else { | 737 | } else { |
738 | if (event->doesFloat()) { | 738 | if (event->doesFloat()) { |
739 | text = event->summary(); | 739 | text = event->summary(); |
740 | if ( useToolTips ) | 740 | if ( useToolTips ) |
741 | mToolTipText += text; | 741 | mToolTipText += text; |
742 | } | 742 | } |
743 | else { | 743 | else { |
744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
745 | text += " " + event->summary(); | 745 | text += " " + event->summary(); |
746 | if ( useToolTips ) | 746 | if ( useToolTips ) |
747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
748 | } | 748 | } |
749 | } | 749 | } |
750 | if ( useToolTips && ! event->location().isEmpty() ) { | 750 | if ( useToolTips && ! event->location().isEmpty() ) { |
751 | mToolTipText += " (" + event->location() +")"; | 751 | mToolTipText += " (" + event->location() +")"; |
752 | } | 752 | } |
753 | MonthViewItem *item ; | 753 | MonthViewItem *item ; |
754 | 754 | ||
755 | if ( mAvailItemList.count() ) { | 755 | if ( mAvailItemList.count() ) { |
756 | item = mAvailItemList.first(); | 756 | item = mAvailItemList.first(); |
757 | mAvailItemList.remove( item ); | 757 | mAvailItemList.remove( item ); |
758 | item->recycle( event, text ); | 758 | item->recycle( event, text ); |
759 | } else { | 759 | } else { |
760 | item = new MonthViewItem( event, text ); | 760 | item = new MonthViewItem( event, text ); |
761 | } | 761 | } |
762 | 762 | ||
763 | QPalette pal; | 763 | QPalette pal; |
764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
765 | QStringList categories = event->categories(); | 765 | QStringList categories = event->categories(); |
766 | QString cat = categories.first(); | 766 | QString cat = categories.first(); |
767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
768 | pal = getPalette(); | 768 | pal = getPalette(); |
769 | if (cat.isEmpty()) { | 769 | if (cat.isEmpty()) { |
770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
772 | } else { | 772 | } else { |
773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
774 | } | 774 | } |
775 | 775 | ||
776 | } else { | 776 | } else { |
777 | if (cat.isEmpty()) { | 777 | if (cat.isEmpty()) { |
778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
780 | } else { | 780 | } else { |
781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | } else { | 785 | } else { |
786 | pal = mStandardPalette ; | 786 | pal = mStandardPalette ; |
787 | } | 787 | } |
788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
789 | item->setPalette( pal ); | 789 | item->setPalette( pal ); |
790 | item->setRecur( event->doesRecur() ); | 790 | item->setRecur( event->doesRecur() ); |
791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
792 | item->setMoreInfo( event->description().length() > 0 ); | 792 | item->setMoreInfo( event->description().length() > 0 ); |
793 | #ifdef DESKTOP_VERSION | 793 | #ifdef DESKTOP_VERSION |
794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
795 | KOPrefs::instance()->email()); | 795 | KOPrefs::instance()->email()); |
796 | if ( me != 0 ) { | 796 | if ( me != 0 ) { |
797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
798 | item->setReply(true && multiday < 2); | 798 | item->setReply(true && multiday < 2); |
799 | else | 799 | else |
800 | item->setReply(false); | 800 | item->setReply(false); |
801 | } else | 801 | } else |
802 | item->setReply(false); | 802 | item->setReply(false); |
803 | #endif | 803 | #endif |
804 | 804 | ||
805 | item->setMultiDay( multiday ); | 805 | item->setMultiDay( multiday ); |
806 | if ( multiday ) { | 806 | if ( multiday ) { |
807 | insertItem( item ,mdayCount); | 807 | insertItem( item ,mdayCount); |
808 | ++mdayCount; | 808 | ++mdayCount; |
809 | } else { | 809 | } else { |
810 | uint i = mdayCount; | 810 | uint i = mdayCount; |
811 | uint pos = mdayCount; | 811 | uint pos = mdayCount; |
812 | uint itcount = count(); | 812 | uint itcount = count(); |
813 | if ( itcount > 1000 ) { | 813 | if ( itcount > 1000 ) { |
814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
815 | itcount = 0; | 815 | itcount = 0; |
816 | } | 816 | } |
817 | for ( i = pos; i < itcount;++i ) { | 817 | for ( i = pos; i < itcount;++i ) { |
818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
819 | QListBoxItem* it = this->item ( i ); | 819 | QListBoxItem* it = this->item ( i ); |
820 | if ( it && text < it->text() ) { | 820 | if ( it && text < it->text() ) { |
821 | pos = i; | 821 | pos = i; |
822 | break; | 822 | break; |
823 | } | 823 | } |
824 | ++pos; | 824 | ++pos; |
825 | } | 825 | } |
826 | insertItem( item ,pos); | 826 | insertItem( item ,pos); |
827 | } | 827 | } |
828 | if ( useToolTips ) { | 828 | if ( useToolTips ) { |
829 | mToolTip.append( mToolTipText ); | 829 | mToolTip.append( mToolTipText ); |
830 | } | 830 | } |
831 | return mdayCount; | 831 | return mdayCount; |
832 | } | 832 | } |
833 | void MonthViewCell::insertTodo(Todo *todo) | 833 | void MonthViewCell::insertTodo(Todo *todo) |
834 | { | 834 | { |
835 | setFocusPolicy(WheelFocus); | 835 | setFocusPolicy(WheelFocus); |
836 | QString text; | 836 | QString text; |
837 | if (todo->hasDueDate()) { | 837 | if (todo->hasDueDate()) { |
838 | if (!todo->doesFloat()) { | 838 | if (!todo->doesFloat()) { |
839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
840 | text += " "; | 840 | text += " "; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | text += todo->summary(); | 843 | text += todo->summary(); |
844 | MonthViewItem *item ; | 844 | MonthViewItem *item ; |
845 | if ( mAvailItemList.count() ) { | 845 | if ( mAvailItemList.count() ) { |
846 | item = mAvailItemList.first(); | 846 | item = mAvailItemList.first(); |
847 | mAvailItemList.remove( item ); | 847 | mAvailItemList.remove( item ); |
848 | item->recycle( todo, text ); | 848 | item->recycle( todo, text ); |
849 | } else { | 849 | } else { |
850 | item = new MonthViewItem( todo, text ); | 850 | item = new MonthViewItem( todo, text ); |
851 | } | 851 | } |
852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
853 | //item->setPalette( mStandardPalette ); | 853 | //item->setPalette( mStandardPalette ); |
854 | QPalette pal; | 854 | QPalette pal; |
855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
856 | QStringList categories = todo->categories(); | 856 | QStringList categories = todo->categories(); |
857 | QString cat = categories.first(); | 857 | QString cat = categories.first(); |
858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
859 | pal = getPalette(); | 859 | pal = getPalette(); |
860 | if (cat.isEmpty()) { | 860 | if (cat.isEmpty()) { |
861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); | 862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); |
863 | } else { | 863 | } else { |
864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
865 | } | 865 | } |
866 | 866 | ||
867 | } else { | 867 | } else { |
868 | if (cat.isEmpty()) { | 868 | if (cat.isEmpty()) { |
869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); | 870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); |
871 | } else { | 871 | } else { |
872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
876 | } else { | 876 | } else { |
877 | pal = mStandardPalette ; | 877 | pal = mStandardPalette ; |
878 | } | 878 | } |
879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
880 | item->setPalette( pal ); | 880 | item->setPalette( pal ); |
881 | item->setRecur( todo->doesRecur() ); | 881 | item->setRecur( todo->doesRecur() ); |
882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
883 | item->setMoreInfo( todo->description().length() > 0 ); | 883 | item->setMoreInfo( todo->description().length() > 0 ); |
884 | insertItem( item , count()); | 884 | insertItem( item , count()); |
885 | #ifdef DESKTOP_VERSION | 885 | #ifdef DESKTOP_VERSION |
886 | mToolTip.append( text ); | 886 | mToolTip.append( text ); |
887 | #endif | 887 | #endif |
888 | } | 888 | } |
889 | void MonthViewCell::repaintfinishUpdateCell() | 889 | void MonthViewCell::repaintfinishUpdateCell() |
890 | { | 890 | { |
891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
892 | while ( mitem ) { | 892 | while ( mitem ) { |
893 | mitem->setBlockRepaint( false ); | 893 | mitem->setBlockRepaint( false ); |
894 | updateItem ( mitem ); | 894 | updateItem ( mitem ); |
895 | mitem = (MonthViewItem *)mitem->next(); | 895 | mitem = (MonthViewItem *)mitem->next(); |
896 | } | 896 | } |
897 | blockSignals( false ); | 897 | blockSignals( false ); |
898 | } | 898 | } |
899 | void MonthViewCell::finishUpdateCell() | 899 | void MonthViewCell::finishUpdateCell() |
900 | { | 900 | { |
901 | 901 | ||
902 | 902 | ||
903 | 903 | ||
904 | #ifdef DESKTOP_VERSION | 904 | #ifdef DESKTOP_VERSION |
905 | if (mToolTip.count() > 0 ) { | 905 | if (mToolTip.count() > 0 ) { |
906 | mToolTip.sort(); | 906 | mToolTip.sort(); |
907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
908 | } | 908 | } |
909 | #endif | 909 | #endif |
910 | //sort(); | 910 | //sort(); |
911 | //setMyPalette(); | 911 | //setMyPalette(); |
912 | setMyPalette(); | 912 | setMyPalette(); |
913 | 913 | ||
914 | resizeEvent( 0 ); | 914 | resizeEvent( 0 ); |
915 | 915 | ||
916 | } | 916 | } |
917 | void MonthViewCell::updateCell() | 917 | void MonthViewCell::updateCell() |
918 | { | 918 | { |
919 | if ( !mMonthView->isUpdatePossible() ) | 919 | if ( !mMonthView->isUpdatePossible() ) |
920 | return; | 920 | return; |
921 | startUpdateCell(); | 921 | startUpdateCell(); |
922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
924 | Event *event; | 924 | Event *event; |
925 | for( event = events.first(); event; event = events.next() ) { // for event | 925 | for( event = events.first(); event; event = events.next() ) { // for event |
926 | insertEvent(event); | 926 | insertEvent(event); |
927 | } | 927 | } |
928 | // insert due todos | 928 | // insert due todos |
929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
930 | Todo *todo; | 930 | Todo *todo; |
931 | for(todo = todos.first(); todo; todo = todos.next()) { | 931 | for(todo = todos.first(); todo; todo = todos.next()) { |
932 | insertTodo( todo ); | 932 | insertTodo( todo ); |
933 | } | 933 | } |
934 | finishUpdateCell(); | 934 | finishUpdateCell(); |
935 | // if ( isVisible()) | 935 | // if ( isVisible()) |
936 | //qApp->processEvents(); | 936 | //qApp->processEvents(); |
937 | } | 937 | } |
938 | 938 | ||
939 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 939 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
940 | { | 940 | { |
941 | 941 | ||
942 | if ( bigFont ) { | 942 | if ( bigFont ) { |
943 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 943 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
944 | int ps = fo.pointSize() + 2; | 944 | int ps = fo.pointSize() + 2; |
945 | if ( ps < 18 ) | 945 | if ( ps < 18 ) |
946 | ps += 2; | 946 | ps += 2; |
947 | fo.setPointSize( ps ); | 947 | fo.setPointSize( ps ); |
948 | setFont( fo ); | 948 | setFont( fo ); |
949 | } else | 949 | } else |
950 | setFont( KOPrefs::instance()->mMonthViewFont ); | 950 | setFont( KOPrefs::instance()->mMonthViewFont ); |
951 | 951 | ||
952 | QFontMetrics fm( font() ); | 952 | QFontMetrics fm( font() ); |
953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
955 | mHolidayPalette = mStandardPalette; | 955 | mHolidayPalette = mStandardPalette; |
956 | mPrimaryPalette = mStandardPalette; | 956 | mPrimaryPalette = mStandardPalette; |
957 | mNonPrimaryPalette = mStandardPalette; | 957 | mNonPrimaryPalette = mStandardPalette; |
958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
968 | } | 968 | } |
969 | //updateCell(); | 969 | //updateCell(); |
970 | } | 970 | } |
971 | 971 | ||
972 | void MonthViewCell::enableScrollBars( bool enabled ) | 972 | void MonthViewCell::enableScrollBars( bool enabled ) |
973 | { | 973 | { |
974 | 974 | ||
975 | return; | 975 | return; |
976 | if ( enabled ) { | 976 | if ( enabled ) { |
977 | QListBoxItem *fi = firstItem (); | 977 | QListBoxItem *fi = firstItem (); |
978 | if (fi ) { | 978 | if (fi ) { |
979 | int ihei = fi->height( this ); | 979 | int ihei = fi->height( this ); |
980 | int hei = numRows () * ihei; | 980 | int hei = numRows () * ihei; |
981 | if ( hei < height() - horizontalScrollBar()->height () ) { | 981 | if ( hei < height() - horizontalScrollBar()->height () ) { |
982 | setVScrollBarMode(QScrollView::AlwaysOff); | 982 | setVScrollBarMode(QScrollView::AlwaysOff); |
983 | } | 983 | } |
984 | else | 984 | else |
985 | setVScrollBarMode(QScrollView::Auto); | 985 | setVScrollBarMode(QScrollView::Auto); |
986 | if ( ihei *3 > height() ) { | 986 | if ( ihei *3 > height() ) { |
987 | setHScrollBarMode(QScrollView::AlwaysOff); | 987 | setHScrollBarMode(QScrollView::AlwaysOff); |
988 | } | 988 | } |
989 | else { | 989 | else { |
990 | setHScrollBarMode(QScrollView::Auto); | 990 | setHScrollBarMode(QScrollView::Auto); |
991 | } | 991 | } |
992 | } else { | 992 | } else { |
993 | setVScrollBarMode(QScrollView::Auto); | 993 | setVScrollBarMode(QScrollView::Auto); |
994 | setHScrollBarMode(QScrollView::Auto); | 994 | setHScrollBarMode(QScrollView::Auto); |
995 | } | 995 | } |
996 | } else { | 996 | } else { |
997 | setVScrollBarMode(QScrollView::AlwaysOff); | 997 | setVScrollBarMode(QScrollView::AlwaysOff); |
998 | setHScrollBarMode(QScrollView::AlwaysOff); | 998 | setHScrollBarMode(QScrollView::AlwaysOff); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | Incidence *MonthViewCell::selectedIncidence() | 1002 | Incidence *MonthViewCell::selectedIncidence() |
1003 | { | 1003 | { |
1004 | int index = currentItem(); | 1004 | int index = currentItem(); |
1005 | if ( index < 0 ) return 0; | 1005 | if ( index < 0 ) return 0; |
1006 | 1006 | ||
1007 | MonthViewItem *mitem = | 1007 | MonthViewItem *mitem = |
1008 | static_cast<MonthViewItem *>( item( index ) ); | 1008 | static_cast<MonthViewItem *>( item( index ) ); |
1009 | 1009 | ||
1010 | if ( !mitem ) return 0; | 1010 | if ( !mitem ) return 0; |
1011 | 1011 | ||
1012 | return mitem->incidence(); | 1012 | return mitem->incidence(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | QDate MonthViewCell::selectedIncidenceDate() | 1015 | QDate MonthViewCell::selectedIncidenceDate() |
1016 | { | 1016 | { |
1017 | QDate qd; | 1017 | QDate qd; |
1018 | int index = currentItem(); | 1018 | int index = currentItem(); |
1019 | if ( index < 0 ) return qd; | 1019 | if ( index < 0 ) return qd; |
1020 | return mDate; | 1020 | return mDate; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void MonthViewCell::deselect() | 1023 | void MonthViewCell::deselect() |
1024 | { | 1024 | { |
1025 | clearSelection(); | 1025 | clearSelection(); |
1026 | enableScrollBars( false ); | 1026 | enableScrollBars( false ); |
1027 | // updateCell(); | 1027 | // updateCell(); |
1028 | } | 1028 | } |
1029 | void MonthViewCell::select() | 1029 | void MonthViewCell::select() |
1030 | { | 1030 | { |
1031 | ;// updateCell(); | 1031 | ;// updateCell(); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
1035 | { | 1035 | { |
1036 | if ( !mMonthView->isUpdatePossible() ) | 1036 | if ( !mMonthView->isUpdatePossible() ) |
1037 | return; | 1037 | return; |
1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1039 | deselect(); | 1039 | deselect(); |
1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1041 | 1041 | ||
1042 | QString text; | 1042 | QString text; |
1043 | //mLabel->setText( text ); | 1043 | //mLabel->setText( text ); |
1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); | 1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); |
1047 | mLabel->resize( mLabelBigSize ); | 1047 | mLabel->resize( mLabelBigSize ); |
1048 | } else { | 1048 | } else { |
1049 | mLabel->resize( mLabelSize ); | 1049 | mLabel->resize( mLabelSize ); |
1050 | text = QString::number( mDate.day() ); | 1050 | text = QString::number( mDate.day() ); |
1051 | } | 1051 | } |
1052 | mLabel->setText( text ); | 1052 | mLabel->setText( text ); |
1053 | 1053 | ||
1054 | int size = height() - mLabel->height() - lineWidth()-1; | 1054 | int size = height() - mLabel->height() - lineWidth()-1; |
1055 | //qDebug("LW %d ", lineWidth()); | 1055 | //qDebug("LW %d ", lineWidth()); |
1056 | if ( size > 0 ) | 1056 | if ( size > 0 ) |
1057 | verticalScrollBar()->setMaximumHeight( size ); | 1057 | verticalScrollBar()->setMaximumHeight( size ); |
1058 | size = width() - mLabel->width() -lineWidth()-1; | 1058 | size = width() - mLabel->width() -lineWidth()-1; |
1059 | if ( size > 0 ) | 1059 | if ( size > 0 ) |
1060 | horizontalScrollBar()->setMaximumWidth( size ); | 1060 | horizontalScrollBar()->setMaximumWidth( size ); |
1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1063 | // mItemList->resize ( width(), height () ); | 1063 | // mItemList->resize ( width(), height () ); |
1064 | if ( e ) | 1064 | if ( e ) |
1065 | KNoScrollListBox::resizeEvent ( e ); | 1065 | KNoScrollListBox::resizeEvent ( e ); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1069 | { | 1069 | { |
1070 | 1070 | ||
1071 | if ( !item ) { | 1071 | if ( !item ) { |
1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1073 | emit newEventSignal( dt ); | 1073 | emit newEventSignal( dt ); |
1074 | return; | 1074 | return; |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1078 | Incidence *incidence = eventItem->incidence(); | 1078 | Incidence *incidence = eventItem->incidence(); |
1079 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1079 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1080 | } | 1080 | } |
1081 | void MonthViewCell::showDay() | 1081 | void MonthViewCell::showDay() |
1082 | { | 1082 | { |
1083 | emit showDaySignal( date() ); | 1083 | emit showDaySignal( date() ); |
1084 | } | 1084 | } |
1085 | void MonthViewCell::newEvent() | 1085 | void MonthViewCell::newEvent() |
1086 | { | 1086 | { |
1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1088 | emit newEventSignal( dt ); | 1088 | emit newEventSignal( dt ); |
1089 | } | 1089 | } |
1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1091 | { | 1091 | { |
1092 | mMonthView->setSelectedCell( this ); | 1092 | mMonthView->setSelectedCell( this ); |
1093 | if ( item == 0 ) { | 1093 | if ( item == 0 ) { |
1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1095 | emit newEventSignal( dt ); | 1095 | emit newEventSignal( dt ); |
1096 | return; | 1096 | return; |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1102 | { | 1102 | { |
1103 | mMonthView->setPopupCell( this ); | 1103 | mMonthView->setPopupCell( this ); |
1104 | if ( !item ) { | 1104 | if ( !item ) { |
1105 | mMonthView->showContextMenu( 0 ); | 1105 | mMonthView->showContextMenu( 0 ); |
1106 | return; | 1106 | return; |
1107 | } | 1107 | } |
1108 | //selection( item ); | 1108 | //selection( item ); |
1109 | //qApp->processEvents(); | 1109 | //qApp->processEvents(); |
1110 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1110 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1111 | Incidence *incidence = eventItem->incidence(); | 1111 | Incidence *incidence = eventItem->incidence(); |
1112 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1112 | if ( incidence ) { |
1113 | mMonthView->showContextMenu( incidence ); | ||
1114 | selection( item ); | ||
1115 | doHighLight( incidence ); | ||
1116 | } | ||
1113 | } | 1117 | } |
1114 | 1118 | ||
1115 | void MonthViewCell::selection( QListBoxItem *item ) | 1119 | void MonthViewCell::selection( QListBoxItem *item ) |
1116 | { | 1120 | { |
1117 | if ( !item ) { | 1121 | if ( !item ) { |
1118 | emit highlightIncidence( 0 , this, 0 ); | 1122 | emit highlightIncidence( 0 , this, 0 ); |
1119 | return; | 1123 | return; |
1120 | } | 1124 | } |
1121 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1125 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1122 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1126 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1123 | mMonthView->setSelectedCell( this ); | 1127 | mMonthView->setSelectedCell( this ); |
1124 | } | 1128 | } |
1125 | 1129 | ||
1126 | void MonthViewCell::deHighLight() | 1130 | void MonthViewCell::deHighLight() |
1127 | { | 1131 | { |
1128 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1132 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1129 | while ( mitem ) { | 1133 | while ( mitem ) { |
1130 | if ( mitem->setHighlightedFalse() ) | 1134 | if ( mitem->setHighlightedFalse() ) |
1131 | updateItem ( mitem ); | 1135 | updateItem ( mitem ); |
1132 | mitem = (MonthViewItem *)mitem->next(); | 1136 | mitem = (MonthViewItem *)mitem->next(); |
1133 | } | 1137 | } |
1134 | } | 1138 | } |
1135 | // returns true if no inc found | 1139 | // returns true if no inc found |
1136 | bool MonthViewCell::doHighLight( Incidence * inc ) | 1140 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1137 | { | 1141 | { |
1138 | 1142 | ||
1139 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1143 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1140 | while ( mitem ) { | 1144 | while ( mitem ) { |
1141 | if ( mitem->incidence() == inc ) { | 1145 | if ( mitem->incidence() == inc ) { |
1142 | if ( mitem->setHighlighted( inc ) ) | 1146 | if ( mitem->setHighlighted( inc ) ) |
1143 | updateItem ( mitem ); | 1147 | updateItem ( mitem ); |
1144 | return false; | 1148 | return false; |
1145 | } | 1149 | } |
1146 | mitem = (MonthViewItem *)mitem->next(); | 1150 | mitem = (MonthViewItem *)mitem->next(); |
1147 | } | 1151 | } |
1148 | return true; | 1152 | return true; |
1149 | } | 1153 | } |
1150 | // ******************************************************************************* | 1154 | // ******************************************************************************* |
1151 | // ******************************************************************************* | 1155 | // ******************************************************************************* |
1152 | // ******************************************************************************* | 1156 | // ******************************************************************************* |
1153 | 1157 | ||
1154 | 1158 | ||
1155 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1159 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1156 | : KOEventView( calendar, parent, name ), | 1160 | : KOEventView( calendar, parent, name ), |
1157 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1161 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1158 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1162 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1159 | { | 1163 | { |
1160 | mFlagKeyPressed = false; | 1164 | mFlagKeyPressed = false; |
1161 | mShortDayLabelsM = false; | 1165 | mShortDayLabelsM = false; |
1162 | mShortDayLabelsW = false; | 1166 | mShortDayLabelsW = false; |
1163 | skipResize = false; | 1167 | skipResize = false; |
1164 | clPending = true; | 1168 | clPending = true; |
1165 | mPopupCell = 0; | 1169 | mPopupCell = 0; |
1166 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1170 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1167 | mWidStack = new QWidgetStack( this ); | 1171 | mWidStack = new QWidgetStack( this ); |
1168 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1172 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1169 | mMonthView = new QWidget( mWidStack ); | 1173 | mMonthView = new QWidget( mWidStack ); |
1170 | mWeekView = new QWidget( mWidStack ); | 1174 | mWeekView = new QWidget( mWidStack ); |
1171 | #if QT_VERSION >= 0x030000 | 1175 | #if QT_VERSION >= 0x030000 |
1172 | mWidStack->addWidget(mMonthView ); | 1176 | mWidStack->addWidget(mMonthView ); |
1173 | mWidStack->addWidget(mWeekView ); | 1177 | mWidStack->addWidget(mWeekView ); |
1174 | #else | 1178 | #else |
1175 | mWidStack->addWidget( mMonthView, 1 ); | 1179 | mWidStack->addWidget( mMonthView, 1 ); |
1176 | mWidStack->addWidget( mWeekView , 1 ); | 1180 | mWidStack->addWidget( mWeekView , 1 ); |
1177 | #endif | 1181 | #endif |
1178 | hb->addWidget( mNavigatorBar ); | 1182 | hb->addWidget( mNavigatorBar ); |
1179 | hb->addWidget( mWidStack ); | 1183 | hb->addWidget( mWidStack ); |
1180 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1184 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1181 | updatePossible = false; | 1185 | updatePossible = false; |
1182 | //updatePossible = true; | 1186 | //updatePossible = true; |
1183 | mCells.setAutoDelete( true ); | 1187 | mCells.setAutoDelete( true ); |
1184 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1188 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1185 | mDayLabels.resize( mDaysPerWeek ); | 1189 | mDayLabels.resize( mDaysPerWeek ); |
1186 | mDayLabelsW.resize( mDaysPerWeek ); | 1190 | mDayLabelsW.resize( mDaysPerWeek ); |
1187 | QFont bfont = font(); | 1191 | QFont bfont = font(); |
1188 | if ( QApplication::desktop()->width() < 650 ) { | 1192 | if ( QApplication::desktop()->width() < 650 ) { |
1189 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1193 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1190 | } | 1194 | } |
1191 | bfont.setBold( true ); | 1195 | bfont.setBold( true ); |
1192 | int i; | 1196 | int i; |
1193 | 1197 | ||
1194 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1198 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1195 | QLabel *label = new QLabel( mMonthView ); | 1199 | QLabel *label = new QLabel( mMonthView ); |
1196 | label->setFont(bfont); | 1200 | label->setFont(bfont); |
1197 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1198 | label->setLineWidth(1); | 1202 | label->setLineWidth(1); |
1199 | label->setAlignment(AlignCenter); | 1203 | label->setAlignment(AlignCenter); |
1200 | mDayLabels.insert( i, label ); | 1204 | mDayLabels.insert( i, label ); |
1201 | label = new QLabel( mWeekView ); | 1205 | label = new QLabel( mWeekView ); |
1202 | label->setFont(bfont); | 1206 | label->setFont(bfont); |
1203 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1207 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1204 | label->setLineWidth(1); | 1208 | label->setLineWidth(1); |
1205 | label->setAlignment(AlignCenter); | 1209 | label->setAlignment(AlignCenter); |
1206 | mDayLabelsW.insert( i, label ); | 1210 | mDayLabelsW.insert( i, label ); |
1207 | } | 1211 | } |
1208 | 1212 | ||
1209 | bfont.setBold( false ); | 1213 | bfont.setBold( false ); |
1210 | mWeekLabels.resize( mNumWeeks+1 ); | 1214 | mWeekLabels.resize( mNumWeeks+1 ); |
1211 | mWeekLabelsW.resize( 2 ); | 1215 | mWeekLabelsW.resize( 2 ); |
1212 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1216 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1213 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1217 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1214 | label->setFocusPolicy(NoFocus); | 1218 | label->setFocusPolicy(NoFocus); |
1215 | label->setFont(bfont); | 1219 | label->setFont(bfont); |
1216 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1220 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1217 | label->setFlat(true); | 1221 | label->setFlat(true); |
1218 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1222 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1219 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1223 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1220 | //label->setLineWidth(1); | 1224 | //label->setLineWidth(1); |
1221 | //label->setAlignment(AlignCenter); | 1225 | //label->setAlignment(AlignCenter); |
1222 | mWeekLabels.insert( i, label ); | 1226 | mWeekLabels.insert( i, label ); |
1223 | } | 1227 | } |
1224 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1228 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1225 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1229 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1226 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1230 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1227 | 1231 | ||
1228 | for( i = 0; i < 1+1; i++ ) { | 1232 | for( i = 0; i < 1+1; i++ ) { |
1229 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1233 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1230 | label->setFocusPolicy(NoFocus); | 1234 | label->setFocusPolicy(NoFocus); |
1231 | label->setFont(bfont); | 1235 | label->setFont(bfont); |
1232 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1236 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1233 | label->setFlat(true); | 1237 | label->setFlat(true); |
1234 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1238 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1235 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1239 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1236 | //label->setLineWidth(1); | 1240 | //label->setLineWidth(1); |
1237 | //label->setAlignment(AlignCenter); | 1241 | //label->setAlignment(AlignCenter); |
1238 | mWeekLabelsW.insert( i, label ); | 1242 | mWeekLabelsW.insert( i, label ); |
1239 | } | 1243 | } |
1240 | mWeekLabelsW[1]->setText( i18n("W")); | 1244 | mWeekLabelsW[1]->setText( i18n("W")); |
1241 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1245 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1242 | 1246 | ||
1243 | 1247 | ||
1244 | int row, col; | 1248 | int row, col; |
1245 | mCells.resize( mNumCells ); | 1249 | mCells.resize( mNumCells ); |
1246 | for( row = 0; row < mNumWeeks; ++row ) { | 1250 | for( row = 0; row < mNumWeeks; ++row ) { |
1247 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1251 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1248 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1252 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1249 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1253 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1250 | 1254 | ||
1251 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1255 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1252 | SLOT( defaultAction( Incidence * ) ) ); | 1256 | SLOT( defaultAction( Incidence * ) ) ); |
1253 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1257 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1254 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1258 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1255 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1259 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1256 | SIGNAL( showDaySignal( QDate ) ) ); | 1260 | SIGNAL( showDaySignal( QDate ) ) ); |
1257 | connect( cell, SIGNAL( nextCell() ), | 1261 | connect( cell, SIGNAL( nextCell() ), |
1258 | SLOT( nextCell() ) ); | 1262 | SLOT( nextCell() ) ); |
1259 | connect( cell, SIGNAL( prevCell() ), | 1263 | connect( cell, SIGNAL( prevCell() ), |
1260 | SLOT( prevCell() ) ); | 1264 | SLOT( prevCell() ) ); |
1261 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1265 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1262 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1266 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1263 | } | 1267 | } |
1264 | } | 1268 | } |
1265 | mCellsW.resize( mDaysPerWeek ); | 1269 | mCellsW.resize( mDaysPerWeek ); |
1266 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1270 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1267 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1271 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1268 | mCellsW.insert( col, cell ); | 1272 | mCellsW.insert( col, cell ); |
1269 | 1273 | ||
1270 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1274 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1271 | SLOT( defaultAction( Incidence * ) ) ); | 1275 | SLOT( defaultAction( Incidence * ) ) ); |
1272 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1276 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1273 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1277 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1274 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1278 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1275 | SIGNAL( showDaySignal( QDate ) ) ); | 1279 | SIGNAL( showDaySignal( QDate ) ) ); |
1276 | connect( cell, SIGNAL( nextCell() ), | 1280 | connect( cell, SIGNAL( nextCell() ), |
1277 | SLOT( nextCell() ) ); | 1281 | SLOT( nextCell() ) ); |
1278 | connect( cell, SIGNAL( prevCell() ), | 1282 | connect( cell, SIGNAL( prevCell() ), |
1279 | SLOT( prevCell() ) ); | 1283 | SLOT( prevCell() ) ); |
1280 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1284 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1281 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1285 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1282 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1286 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1283 | } | 1287 | } |
1284 | 1288 | ||
1285 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1289 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1286 | mContextMenu = eventPopup(); | 1290 | mContextMenu = eventPopup(); |
1287 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1288 | i18n("New Event..."),this, | 1292 | i18n("New Event..."),this, |
1289 | SLOT(slotNewEvent()),false); | 1293 | SLOT(slotNewEvent()),false); |
1290 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1294 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1291 | i18n("New Todo..."),this, | 1295 | i18n("New Todo..."),this, |
1292 | SLOT(slotNewTodo()),false); | 1296 | SLOT(slotNewTodo()),false); |
1293 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1297 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1294 | i18n("Journal"),this, | 1298 | i18n("Journal"),this, |
1295 | SLOT(slotEditJournal()),false); | 1299 | SLOT(slotEditJournal()),false); |
1296 | 1300 | ||
1297 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1301 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1298 | SLOT( catChanged( Incidence * ) )); | 1302 | SLOT( catChanged( Incidence * ) )); |
1299 | 1303 | ||
1300 | 1304 | ||
1301 | QString pathString = ""; | 1305 | QString pathString = ""; |
1302 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1306 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1303 | if ( QApplication::desktop()->width() < 480 ) | 1307 | if ( QApplication::desktop()->width() < 480 ) |
1304 | pathString += "icons16/"; | 1308 | pathString += "icons16/"; |
1305 | } else | 1309 | } else |
1306 | pathString += "iconsmini/"; | 1310 | pathString += "iconsmini/"; |
1307 | mNewItemMenu = new QPopupMenu( this ); | 1311 | mNewItemMenu = new QPopupMenu( this ); |
1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1312 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1309 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1313 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1310 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1314 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1311 | 1315 | ||
1312 | // updateConfig(); //useless here... | 1316 | // updateConfig(); //useless here... |
1313 | // ... but we need mWidthLongDayLabel computed | 1317 | // ... but we need mWidthLongDayLabel computed |
1314 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1318 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1315 | mWidthLongDayLabel = 0; | 1319 | mWidthLongDayLabel = 0; |
1316 | for (int i = 0; i < 7; i++) { | 1320 | for (int i = 0; i < 7; i++) { |
1317 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1321 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1318 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1322 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1319 | } | 1323 | } |
1320 | 1324 | ||
1321 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1325 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1322 | 1326 | ||
1323 | #if 0 | 1327 | #if 0 |
1324 | if ( mShowWeekView ) | 1328 | if ( mShowWeekView ) |
1325 | mWidStack->raiseWidget( mWeekView ); | 1329 | mWidStack->raiseWidget( mWeekView ); |
1326 | else | 1330 | else |
1327 | mWidStack->raiseWidget( mMonthView ); | 1331 | mWidStack->raiseWidget( mMonthView ); |
1328 | #endif | 1332 | #endif |
1329 | 1333 | ||
1330 | emit incidenceSelected( 0 ); | 1334 | emit incidenceSelected( 0 ); |
1331 | 1335 | ||
1332 | mComputeLayoutTimer = new QTimer( this ); | 1336 | mComputeLayoutTimer = new QTimer( this ); |
1333 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1337 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1334 | 1338 | ||
1335 | 1339 | ||
1336 | #ifndef DESKTOP_VERSION | 1340 | #ifndef DESKTOP_VERSION |
1337 | resize( QApplication::desktop()->size() ); | 1341 | resize( QApplication::desktop()->size() ); |
1338 | #else | 1342 | #else |
1339 | resize(640, 480 ); | 1343 | resize(640, 480 ); |
1340 | updatePossible = true; | 1344 | updatePossible = true; |
1341 | #endif | 1345 | #endif |
1342 | computeLayout(); | 1346 | computeLayout(); |
1343 | 1347 | ||
1344 | if ( mShowWeekView ) | 1348 | if ( mShowWeekView ) |
1345 | mWidStack->raiseWidget( mWeekView ); | 1349 | mWidStack->raiseWidget( mWeekView ); |
1346 | else | 1350 | else |
1347 | mWidStack->raiseWidget( mMonthView ); | 1351 | mWidStack->raiseWidget( mMonthView ); |
1348 | } | 1352 | } |
1349 | 1353 | ||
1350 | KOMonthView::~KOMonthView() | 1354 | KOMonthView::~KOMonthView() |
1351 | { | 1355 | { |
1352 | delete mContextMenu; | 1356 | delete mContextMenu; |
1353 | } | 1357 | } |
1354 | 1358 | ||
1355 | void KOMonthView::catChanged( Incidence * ) | 1359 | void KOMonthView::catChanged( Incidence * ) |
1356 | { | 1360 | { |
1357 | updateView(); | 1361 | updateView(); |
1358 | } | 1362 | } |
1359 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1363 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1360 | { | 1364 | { |
1361 | static Incidence * lastInc = 0; | 1365 | static Incidence * lastInc = 0; |
1362 | static MonthViewCell * lastCell = 0; | 1366 | static MonthViewCell * lastCell = 0; |
1363 | 1367 | ||
1364 | if ( lastInc == inc && lastCell == mc ) | 1368 | if ( lastInc == inc && lastCell == mc ) |
1365 | return; | 1369 | return; |
1366 | lastInc = inc; | 1370 | lastInc = inc; |
1367 | lastCell = mc; | 1371 | lastCell = mc; |
1368 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1372 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1369 | 1373 | ||
1370 | bool weekview = false; | 1374 | bool weekview = false; |
1371 | uint index = 0; | 1375 | uint index = 0; |
1372 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1376 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1373 | if ( mCellsW[i] == mc ) { | 1377 | if ( mCellsW[i] == mc ) { |
1374 | weekview = true; | 1378 | weekview = true; |
1375 | index = i; | 1379 | index = i; |
1376 | break; | 1380 | break; |
1377 | } | 1381 | } |
1378 | } | 1382 | } |
1379 | QPtrVector<MonthViewCell> *cells; | 1383 | QPtrVector<MonthViewCell> *cells; |
1380 | if ( weekview ) | 1384 | if ( weekview ) |
1381 | cells = &mCellsW; | 1385 | cells = &mCellsW; |
1382 | else { | 1386 | else { |
1383 | for (uint i = 0; i < mCells.count(); ++i) { | 1387 | for (uint i = 0; i < mCells.count(); ++i) { |
1384 | if ( mCells[i] == mc ) { | 1388 | if ( mCells[i] == mc ) { |
1385 | index = i; | 1389 | index = i; |
1386 | break; | 1390 | break; |
1387 | } | 1391 | } |
1388 | } | 1392 | } |
1389 | cells = &mCells; | 1393 | cells = &mCells; |
1390 | } | 1394 | } |
1391 | for (uint i = 0; i < (*cells).count(); ++i) { | 1395 | for (uint i = 0; i < (*cells).count(); ++i) { |
1392 | (*cells)[i]->deHighLight(); | 1396 | (*cells)[i]->deHighLight(); |
1393 | } | 1397 | } |
1394 | if ( ! inc ) | 1398 | if ( ! inc ) |
1395 | return; | 1399 | return; |
1396 | 1400 | ||
1397 | uint count = (*cells).count(); | 1401 | uint count = (*cells).count(); |
1398 | bool goLeft = (mday > 1 && index > 0); | 1402 | bool goLeft = (mday > 1 && index > 0); |
1399 | bool goRight = (mday < 3 && mday > 0 && index < count -1); | 1403 | bool goRight = (mday < 3 && mday > 0 && index < count -1); |
1400 | for (uint iii = 1; iii < count; ++iii) { | 1404 | for (uint iii = 1; iii < count; ++iii) { |
1401 | if ( goLeft ) { | 1405 | if ( goLeft ) { |
1402 | int left = index - iii; | 1406 | int left = index - iii; |
1403 | if ( left >= 0 ) { | 1407 | if ( left >= 0 ) { |
1404 | if ( (*cells)[(uint)left]->doHighLight(inc) ) | 1408 | if ( (*cells)[(uint)left]->doHighLight(inc) ) |
1405 | goLeft = false; | 1409 | goLeft = false; |
1406 | } else | 1410 | } else |
1407 | goLeft = false; | 1411 | goLeft = false; |
1408 | } | 1412 | } |
1409 | if ( goRight ) { | 1413 | if ( goRight ) { |
1410 | uint right = index + iii; | 1414 | uint right = index + iii; |
1411 | if ( right < count ) { | 1415 | if ( right < count ) { |
1412 | if ( (*cells)[right]->doHighLight(inc) ) | 1416 | if ( (*cells)[right]->doHighLight(inc) ) |
1413 | goRight = false; | 1417 | goRight = false; |
1414 | 1418 | ||
1415 | } else | 1419 | } else |
1416 | goRight = false; | 1420 | goRight = false; |
1417 | } | 1421 | } |
1418 | 1422 | ||
1419 | } | 1423 | } |
1420 | #if 0 | 1424 | #if 0 |
1421 | if ( mday > 1 && index > 0 ) | 1425 | if ( mday > 1 && index > 0 ) |
1422 | for (int i = index-1; i >= 0; --i) { | 1426 | for (int i = index-1; i >= 0; --i) { |
1423 | //qDebug("index %d iii %d ", index, i); | 1427 | //qDebug("index %d iii %d ", index, i); |
1424 | if ( (*cells)[(uint)i]->doHighLight(inc) ) | 1428 | if ( (*cells)[(uint)i]->doHighLight(inc) ) |
1425 | break; | 1429 | break; |
1426 | } | 1430 | } |
1427 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | 1431 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) |
1428 | for (uint i = index+1; i < (*cells).count(); ++i) { | 1432 | for (uint i = index+1; i < (*cells).count(); ++i) { |
1429 | if ( (*cells)[i]->doHighLight(inc) ) | 1433 | if ( (*cells)[i]->doHighLight(inc) ) |
1430 | break; | 1434 | break; |
1431 | } | 1435 | } |
1432 | #endif | 1436 | #endif |
1433 | 1437 | ||
1434 | } | 1438 | } |
1435 | void KOMonthView::selectInternalWeekNum ( int n ) | 1439 | void KOMonthView::selectInternalWeekNum ( int n ) |
1436 | { | 1440 | { |
1437 | switchView(); | 1441 | switchView(); |
1438 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1442 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1439 | emit selectMonth (); | 1443 | emit selectMonth (); |
1440 | else | 1444 | else |
1441 | emit selectWeekNum ( n ); | 1445 | emit selectWeekNum ( n ); |
1442 | } | 1446 | } |
1443 | 1447 | ||
1444 | int KOMonthView::currentWeek() | 1448 | int KOMonthView::currentWeek() |
1445 | { | 1449 | { |
1446 | if ( mShowWeekView ) | 1450 | if ( mShowWeekView ) |
1447 | return mWeekLabelsW[0]->getWeekNum(); | 1451 | return mWeekLabelsW[0]->getWeekNum(); |
1448 | return mWeekLabels[0]->getWeekNum(); | 1452 | return mWeekLabels[0]->getWeekNum(); |
1449 | } | 1453 | } |
1450 | void KOMonthView::switchView() | 1454 | void KOMonthView::switchView() |
1451 | { | 1455 | { |
1452 | if ( selectedCell( ) ) | 1456 | if ( selectedCell( ) ) |
1453 | selectedCell()->deselect(); | 1457 | selectedCell()->deselect(); |
1454 | mShowWeekView = !mShowWeekView; | 1458 | mShowWeekView = !mShowWeekView; |
1455 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1459 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1456 | if ( clPending ) { | 1460 | if ( clPending ) { |
1457 | computeLayout(); | 1461 | computeLayout(); |
1458 | updateConfig(); | 1462 | updateConfig(); |
1459 | } | 1463 | } |
1460 | if ( mShowWeekView ) | 1464 | if ( mShowWeekView ) |
1461 | mWidStack->raiseWidget( mWeekView ); | 1465 | mWidStack->raiseWidget( mWeekView ); |
1462 | else | 1466 | else |
1463 | mWidStack->raiseWidget( mMonthView ); | 1467 | mWidStack->raiseWidget( mMonthView ); |
1464 | clPending = false; | 1468 | clPending = false; |
1465 | } | 1469 | } |
1466 | 1470 | ||
1467 | int KOMonthView::maxDatesHint() | 1471 | int KOMonthView::maxDatesHint() |
1468 | { | 1472 | { |
1469 | return mNumCells; | 1473 | return mNumCells; |
1470 | } | 1474 | } |
1471 | 1475 | ||
1472 | int KOMonthView::currentDateCount() | 1476 | int KOMonthView::currentDateCount() |
1473 | { | 1477 | { |
1474 | return mNumCells; | 1478 | return mNumCells; |
1475 | } | 1479 | } |
1476 | 1480 | ||
1477 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1481 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1478 | { | 1482 | { |
1479 | QPtrList<Incidence> selected; | 1483 | QPtrList<Incidence> selected; |
1480 | 1484 | ||
1481 | if ( mSelectedCell ) { | 1485 | if ( mSelectedCell ) { |
1482 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1486 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1483 | if ( incidence ) selected.append( incidence ); | 1487 | if ( incidence ) selected.append( incidence ); |
1484 | } | 1488 | } |
1485 | 1489 | ||
1486 | return selected; | 1490 | return selected; |
1487 | } | 1491 | } |
1488 | 1492 | ||
1489 | DateList KOMonthView::selectedDates() | 1493 | DateList KOMonthView::selectedDates() |
1490 | { | 1494 | { |
1491 | DateList selected; | 1495 | DateList selected; |
1492 | 1496 | ||
1493 | if ( mSelectedCell ) { | 1497 | if ( mSelectedCell ) { |
1494 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1498 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1495 | if ( qd.isValid() ) selected.append( qd ); | 1499 | if ( qd.isValid() ) selected.append( qd ); |
1496 | } | 1500 | } |
1497 | 1501 | ||
1498 | return selected; | 1502 | return selected; |
1499 | } | 1503 | } |
1500 | #if 0 | 1504 | #if 0 |
1501 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1505 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1502 | const QDate &td) | 1506 | const QDate &td) |
1503 | { | 1507 | { |
1504 | #ifndef KORG_NOPRINTER | 1508 | #ifndef KORG_NOPRINTER |
1505 | calPrinter->preview(CalPrinter::Month, fd, td); | 1509 | calPrinter->preview(CalPrinter::Month, fd, td); |
1506 | #endif | 1510 | #endif |
1507 | } | 1511 | } |
1508 | #endif | 1512 | #endif |
1509 | void KOMonthView::updateConfig() | 1513 | void KOMonthView::updateConfig() |
1510 | { | 1514 | { |
1511 | 1515 | ||
1512 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1516 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1513 | 1517 | ||
1514 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1518 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1515 | mWeekStartsMonday = true; | 1519 | mWeekStartsMonday = true; |
1516 | } | 1520 | } |
1517 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1521 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1518 | mWidthLongDayLabel = 0; | 1522 | mWidthLongDayLabel = 0; |
1519 | 1523 | ||
1520 | for (int i = 0; i < 7; i++) { | 1524 | for (int i = 0; i < 7; i++) { |
1521 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1525 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1522 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1526 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1523 | } | 1527 | } |
1524 | bool temp = mShowSatSunComp ; | 1528 | bool temp = mShowSatSunComp ; |
1525 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1529 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1526 | if ( ! mShowWeekView ) { | 1530 | if ( ! mShowWeekView ) { |
1527 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1531 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1528 | computeLayout(); | 1532 | computeLayout(); |
1529 | } else | 1533 | } else |
1530 | doComputeLayoutWeek(); | 1534 | doComputeLayoutWeek(); |
1531 | updateDayLabels(); | 1535 | updateDayLabels(); |
1532 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1536 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1533 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1537 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1534 | //resizeEvent( 0 ); | 1538 | //resizeEvent( 0 ); |
1535 | for (uint i = 0; i < mCells.count(); ++i) { | 1539 | for (uint i = 0; i < mCells.count(); ++i) { |
1536 | mCells[i]->updateConfig(); | 1540 | mCells[i]->updateConfig(); |
1537 | } | 1541 | } |
1538 | 1542 | ||
1539 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1543 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1540 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1544 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1541 | } | 1545 | } |
1542 | #ifdef DESKTOP_VERSION | 1546 | #ifdef DESKTOP_VERSION |
1543 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1547 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1544 | #endif | 1548 | #endif |
1545 | updateView(); | 1549 | updateView(); |
1546 | } | 1550 | } |
1547 | 1551 | ||
1548 | void KOMonthView::updateDayLabels() | 1552 | void KOMonthView::updateDayLabels() |
1549 | { | 1553 | { |
1550 | 1554 | ||
1551 | QPtrVector<QLabel> *mDayLabelsT; | 1555 | QPtrVector<QLabel> *mDayLabelsT; |
1552 | 1556 | ||
1553 | mDayLabelsT = &mDayLabelsW; | 1557 | mDayLabelsT = &mDayLabelsW; |
1554 | for (int i = 0; i < 7; i++) { | 1558 | for (int i = 0; i < 7; i++) { |
1555 | { | 1559 | { |
1556 | bool show = mShortDayLabelsW; | 1560 | bool show = mShortDayLabelsW; |
1557 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1561 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1558 | show = true; | 1562 | show = true; |
1559 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1563 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1560 | } | 1564 | } |
1561 | } | 1565 | } |
1562 | mDayLabelsT = &mDayLabels; | 1566 | mDayLabelsT = &mDayLabels; |
1563 | for (int i = 0; i < 7; i++) { | 1567 | for (int i = 0; i < 7; i++) { |
1564 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1568 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1565 | bool show = mShortDayLabelsM; | 1569 | bool show = mShortDayLabelsM; |
1566 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1570 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1567 | show = true; | 1571 | show = true; |
1568 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1572 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1569 | } else { | 1573 | } else { |
1570 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1574 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1571 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1575 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1572 | 1576 | ||
1573 | } | 1577 | } |
1574 | } | 1578 | } |
1575 | 1579 | ||
1576 | } | 1580 | } |
1577 | 1581 | ||
1578 | void KOMonthView::clearList() | 1582 | void KOMonthView::clearList() |
1579 | { | 1583 | { |
1580 | unsigned int i; | 1584 | unsigned int i; |
1581 | for( i = 0; i < mCells.size(); ++i ) { | 1585 | for( i = 0; i < mCells.size(); ++i ) { |
1582 | mCells[i]->clear(); | 1586 | mCells[i]->clear(); |
1583 | } | 1587 | } |
1584 | for( i = 0; i < mCellsW.size(); ++i ) { | 1588 | for( i = 0; i < mCellsW.size(); ++i ) { |
1585 | mCellsW[i]->clear(); | 1589 | mCellsW[i]->clear(); |
1586 | } | 1590 | } |
1587 | } | 1591 | } |
1588 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1592 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1589 | { | 1593 | { |
1590 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1594 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1591 | 1595 | ||
1592 | QPtrVector<MonthViewCell> *cells; | 1596 | QPtrVector<MonthViewCell> *cells; |
1593 | QPtrVector<QLabel> *dayLabels; | 1597 | QPtrVector<QLabel> *dayLabels; |
1594 | QPtrVector<KOWeekButton> *weekLabels; | 1598 | QPtrVector<KOWeekButton> *weekLabels; |
1595 | uint weekNum = 6; | 1599 | uint weekNum = 6; |
1596 | mStartDate = start; | 1600 | mStartDate = start; |
1597 | if ( mShowWeekView ) { | 1601 | if ( mShowWeekView ) { |
1598 | weekNum = 1; | 1602 | weekNum = 1; |
1599 | cells = &mCellsW; | 1603 | cells = &mCellsW; |
1600 | dayLabels = &mDayLabelsW; | 1604 | dayLabels = &mDayLabelsW; |
1601 | weekLabels = &mWeekLabelsW; | 1605 | weekLabels = &mWeekLabelsW; |
1602 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1606 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1603 | mStartDate = mStartDate.addDays( 1 ); | 1607 | mStartDate = mStartDate.addDays( 1 ); |
1604 | } | 1608 | } |
1605 | } else { | 1609 | } else { |
1606 | cells = &mCells; | 1610 | cells = &mCells; |
1607 | dayLabels = &mDayLabels; | 1611 | dayLabels = &mDayLabels; |
1608 | weekLabels = &mWeekLabels; | 1612 | weekLabels = &mWeekLabels; |
1609 | } | 1613 | } |
1610 | 1614 | ||
1611 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1615 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1612 | 1616 | ||
1613 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1617 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1614 | mWeekStartsMonday = true; | 1618 | mWeekStartsMonday = true; |
1615 | } | 1619 | } |
1616 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1620 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1617 | 1621 | ||
1618 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1622 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1619 | mStartDate = mStartDate.addDays( -1 ); | 1623 | mStartDate = mStartDate.addDays( -1 ); |
1620 | } | 1624 | } |
1621 | uint i; | 1625 | uint i; |
1622 | for( i = 0; i < (*cells).size(); ++i ) { | 1626 | for( i = 0; i < (*cells).size(); ++i ) { |
1623 | QDate date = mStartDate.addDays( i ); | 1627 | QDate date = mStartDate.addDays( i ); |
1624 | (*cells)[i]->setDate( date ); | 1628 | (*cells)[i]->setDate( date ); |