-rw-r--r-- | korganizer/koagendaview.cpp | 3 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 4 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 3 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 32 | ||||
-rw-r--r-- | libkcal/incidence.h | 5 |
6 files changed, 44 insertions, 11 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index e029fdb..eb3a6cd 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -653,924 +653,923 @@ void KOAgendaView::createDayLabels() | |||
653 | while ( needWid > maxWid ) { | 653 | while ( needWid > maxWid ) { |
654 | dayTest = dayTest.left( dayTest.length() - 1 ); | 654 | dayTest = dayTest.left( dayTest.length() - 1 ); |
655 | wid = fm.width( dayTest ); | 655 | wid = fm.width( dayTest ); |
656 | needWid = wid * selCount; | 656 | needWid = wid * selCount; |
657 | } | 657 | } |
658 | int maxLen = dayTest.length(); | 658 | int maxLen = dayTest.length(); |
659 | int fontPoint = dlf.pointSize(); | 659 | int fontPoint = dlf.pointSize(); |
660 | if ( maxLen < 2 ) { | 660 | if ( maxLen < 2 ) { |
661 | int fontPoint = dlf.pointSize(); | 661 | int fontPoint = dlf.pointSize(); |
662 | while ( fontPoint > 4 ) { | 662 | while ( fontPoint > 4 ) { |
663 | --fontPoint; | 663 | --fontPoint; |
664 | dlf.setPointSize( fontPoint ); | 664 | dlf.setPointSize( fontPoint ); |
665 | QFontMetrics f( dlf ); | 665 | QFontMetrics f( dlf ); |
666 | wid = f.width( "30" ); | 666 | wid = f.width( "30" ); |
667 | needWid = wid * selCount; | 667 | needWid = wid * selCount; |
668 | if ( needWid < maxWid ) | 668 | if ( needWid < maxWid ) |
669 | break; | 669 | break; |
670 | } | 670 | } |
671 | maxLen = 2; | 671 | maxLen = 2; |
672 | } | 672 | } |
673 | //qDebug("Max len %d ", dayTest.length() ); | 673 | //qDebug("Max len %d ", dayTest.length() ); |
674 | 674 | ||
675 | QFontMetrics tempF( dlf ); | 675 | QFontMetrics tempF( dlf ); |
676 | newHight = tempF.height(); | 676 | newHight = tempF.height(); |
677 | mDayLabels->setFont( dlf ); | 677 | mDayLabels->setFont( dlf ); |
678 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 678 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
679 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 679 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
680 | //mLayoutDayLabels->addSpacing( 2 ); | 680 | //mLayoutDayLabels->addSpacing( 2 ); |
681 | // QFont lFont = dlf; | 681 | // QFont lFont = dlf; |
682 | bool appendLabels = false; | 682 | bool appendLabels = false; |
683 | KOAgendaButton *dayLabel; | 683 | KOAgendaButton *dayLabel; |
684 | dayLabel = mDayLabelsList.first(); | 684 | dayLabel = mDayLabelsList.first(); |
685 | if ( !dayLabel ) { | 685 | if ( !dayLabel ) { |
686 | appendLabels = true; | 686 | appendLabels = true; |
687 | dayLabel = getNewDaylabel(); | 687 | dayLabel = getNewDaylabel(); |
688 | } | 688 | } |
689 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 689 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
690 | dayLabel->setFont( dlf ); | 690 | dayLabel->setFont( dlf ); |
691 | dayLabel->setNum( -1 ); | 691 | dayLabel->setNum( -1 ); |
692 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 692 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
693 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 693 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
694 | dayLabel->show(); | 694 | dayLabel->show(); |
695 | DateList::ConstIterator dit; | 695 | DateList::ConstIterator dit; |
696 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 696 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
697 | int counter = -1; | 697 | int counter = -1; |
698 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 698 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
699 | ++counter; | 699 | ++counter; |
700 | QDate date = *dit; | 700 | QDate date = *dit; |
701 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 701 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
702 | if ( ! appendLabels ) { | 702 | if ( ! appendLabels ) { |
703 | dayLabel = mDayLabelsList.next(); | 703 | dayLabel = mDayLabelsList.next(); |
704 | if ( !dayLabel ) | 704 | if ( !dayLabel ) |
705 | appendLabels = true; | 705 | appendLabels = true; |
706 | } | 706 | } |
707 | if ( appendLabels ) { | 707 | if ( appendLabels ) { |
708 | dayLabel = getNewDaylabel(); | 708 | dayLabel = getNewDaylabel(); |
709 | } | 709 | } |
710 | dayLabel->setMinimumWidth( 1 ); | 710 | dayLabel->setMinimumWidth( 1 ); |
711 | dayLabel->setMaximumWidth( 10240 ); | 711 | dayLabel->setMaximumWidth( 10240 ); |
712 | dayLabel->setFont( dlf ); | 712 | dayLabel->setFont( dlf ); |
713 | dayLabel->show(); | 713 | dayLabel->show(); |
714 | dayLabel->setNum( counter ); | 714 | dayLabel->setNum( counter ); |
715 | QString str; | 715 | QString str; |
716 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 716 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
717 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 717 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
718 | switch ( maxLen ) { | 718 | switch ( maxLen ) { |
719 | case 2: | 719 | case 2: |
720 | str = QString::number( date.day() ); | 720 | str = QString::number( date.day() ); |
721 | break; | 721 | break; |
722 | 722 | ||
723 | case 3: | 723 | case 3: |
724 | str = dayName.left( 1 ) +QString::number( date.day()); | 724 | str = dayName.left( 1 ) +QString::number( date.day()); |
725 | 725 | ||
726 | break; | 726 | break; |
727 | case 4: | 727 | case 4: |
728 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 728 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
729 | 729 | ||
730 | break; | 730 | break; |
731 | case 5: | 731 | case 5: |
732 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 732 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
733 | 733 | ||
734 | break; | 734 | break; |
735 | case 6: | 735 | case 6: |
736 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 736 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
737 | break; | 737 | break; |
738 | 738 | ||
739 | default: | 739 | default: |
740 | break; | 740 | break; |
741 | } | 741 | } |
742 | if ( oneday ) { | 742 | if ( oneday ) { |
743 | QString addString; | 743 | QString addString; |
744 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 744 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
745 | addString = i18n("Today"); | 745 | addString = i18n("Today"); |
746 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 746 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
747 | addString = i18n("Tomorrow"); | 747 | addString = i18n("Tomorrow"); |
748 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 748 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
749 | addString = i18n("Yesterday"); | 749 | addString = i18n("Yesterday"); |
750 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 750 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
751 | addString = i18n("Day before yesterday"); | 751 | addString = i18n("Day before yesterday"); |
752 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 752 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
753 | addString = i18n("Day after tomorrow"); | 753 | addString = i18n("Day after tomorrow"); |
754 | if ( !addString.isEmpty() ) { | 754 | if ( !addString.isEmpty() ) { |
755 | str = addString+", " + str; | 755 | str = addString+", " + str; |
756 | } | 756 | } |
757 | } | 757 | } |
758 | dayLabel->setText(str); | 758 | dayLabel->setText(str); |
759 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 759 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
760 | if (date == QDate::currentDate()) { | 760 | if (date == QDate::currentDate()) { |
761 | QFont bFont = dlf; | 761 | QFont bFont = dlf; |
762 | bFont.setBold( true ); | 762 | bFont.setBold( true ); |
763 | dayLabel->setFont(bFont); | 763 | dayLabel->setFont(bFont); |
764 | } | 764 | } |
765 | //dayLayout->addWidget(dayLabel); | 765 | //dayLayout->addWidget(dayLabel); |
766 | 766 | ||
767 | #ifndef KORG_NOPLUGINS | 767 | #ifndef KORG_NOPLUGINS |
768 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 768 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
769 | CalendarDecoration *it; | 769 | CalendarDecoration *it; |
770 | for(it = cds.first(); it; it = cds.next()) { | 770 | for(it = cds.first(); it; it = cds.next()) { |
771 | QString text = it->shortText( date ); | 771 | QString text = it->shortText( date ); |
772 | if ( !text.isEmpty() ) { | 772 | if ( !text.isEmpty() ) { |
773 | QLabel *label = new QLabel(text,mDayLabels); | 773 | QLabel *label = new QLabel(text,mDayLabels); |
774 | label->setAlignment(AlignCenter); | 774 | label->setAlignment(AlignCenter); |
775 | dayLayout->addWidget(label); | 775 | dayLayout->addWidget(label); |
776 | } | 776 | } |
777 | } | 777 | } |
778 | 778 | ||
779 | for(it = cds.first(); it; it = cds.next()) { | 779 | for(it = cds.first(); it; it = cds.next()) { |
780 | QWidget *wid = it->smallWidget(mDayLabels,date); | 780 | QWidget *wid = it->smallWidget(mDayLabels,date); |
781 | if ( wid ) { | 781 | if ( wid ) { |
782 | // wid->setHeight(20); | 782 | // wid->setHeight(20); |
783 | dayLayout->addWidget(wid); | 783 | dayLayout->addWidget(wid); |
784 | } | 784 | } |
785 | } | 785 | } |
786 | #endif | 786 | #endif |
787 | } | 787 | } |
788 | if ( ! appendLabels ) { | 788 | if ( ! appendLabels ) { |
789 | dayLabel = mDayLabelsList.next(); | 789 | dayLabel = mDayLabelsList.next(); |
790 | if ( !dayLabel ) | 790 | if ( !dayLabel ) |
791 | appendLabels = true; | 791 | appendLabels = true; |
792 | } | 792 | } |
793 | if ( appendLabels ) { | 793 | if ( appendLabels ) { |
794 | dayLabel = getNewDaylabel(); | 794 | dayLabel = getNewDaylabel(); |
795 | } | 795 | } |
796 | //dayLabel->hide();//test only | 796 | //dayLabel->hide();//test only |
797 | 797 | ||
798 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 798 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
799 | if ( offset < 0 ) offset = 0; | 799 | if ( offset < 0 ) offset = 0; |
800 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 800 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
801 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 801 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
802 | dayLabel->setFont( dlf ); | 802 | dayLabel->setFont( dlf ); |
803 | dayLabel->show(); | 803 | dayLabel->show(); |
804 | dayLabel->setNum( -2 ); | 804 | dayLabel->setNum( -2 ); |
805 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 805 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
806 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 806 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
807 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 807 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
808 | if ( !appendLabels ) { | 808 | if ( !appendLabels ) { |
809 | dayLabel = mDayLabelsList.next(); | 809 | dayLabel = mDayLabelsList.next(); |
810 | while ( dayLabel ) { | 810 | while ( dayLabel ) { |
811 | //qDebug("!dayLabel %d",dayLabel ); | 811 | //qDebug("!dayLabel %d",dayLabel ); |
812 | dayLabel->hide(); | 812 | dayLabel->hide(); |
813 | dayLabel = mDayLabelsList.next(); | 813 | dayLabel = mDayLabelsList.next(); |
814 | } | 814 | } |
815 | } | 815 | } |
816 | //mDayLabelsFrame->show(); | 816 | //mDayLabelsFrame->show(); |
817 | //mDayLabels->show(); | 817 | //mDayLabels->show(); |
818 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 818 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
819 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 819 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
820 | mDayLabelsFrame->setFixedHeight( newHight ); | 820 | mDayLabelsFrame->setFixedHeight( newHight ); |
821 | } | 821 | } |
822 | 822 | ||
823 | int KOAgendaView::maxDatesHint() | 823 | int KOAgendaView::maxDatesHint() |
824 | { | 824 | { |
825 | // Not sure about the max number of events, so return 0 for now. | 825 | // Not sure about the max number of events, so return 0 for now. |
826 | return 0; | 826 | return 0; |
827 | } | 827 | } |
828 | 828 | ||
829 | int KOAgendaView::currentDateCount() | 829 | int KOAgendaView::currentDateCount() |
830 | { | 830 | { |
831 | return mSelectedDates.count(); | 831 | return mSelectedDates.count(); |
832 | } | 832 | } |
833 | 833 | ||
834 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 834 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
835 | { | 835 | { |
836 | QPtrList<Incidence> selected; | 836 | QPtrList<Incidence> selected; |
837 | Incidence *incidence; | 837 | Incidence *incidence; |
838 | 838 | ||
839 | incidence = mAgenda->selectedIncidence(); | 839 | incidence = mAgenda->selectedIncidence(); |
840 | if (incidence) selected.append(incidence); | 840 | if (incidence) selected.append(incidence); |
841 | 841 | ||
842 | incidence = mAllDayAgenda->selectedIncidence(); | 842 | incidence = mAllDayAgenda->selectedIncidence(); |
843 | if (incidence) selected.append(incidence); | 843 | if (incidence) selected.append(incidence); |
844 | 844 | ||
845 | return selected; | 845 | return selected; |
846 | } | 846 | } |
847 | 847 | ||
848 | DateList KOAgendaView::selectedDates() | 848 | DateList KOAgendaView::selectedDates() |
849 | { | 849 | { |
850 | DateList selected; | 850 | DateList selected; |
851 | QDate qd; | 851 | QDate qd; |
852 | 852 | ||
853 | qd = mAgenda->selectedIncidenceDate(); | 853 | qd = mAgenda->selectedIncidenceDate(); |
854 | if (qd.isValid()) selected.append(qd); | 854 | if (qd.isValid()) selected.append(qd); |
855 | 855 | ||
856 | qd = mAllDayAgenda->selectedIncidenceDate(); | 856 | qd = mAllDayAgenda->selectedIncidenceDate(); |
857 | if (qd.isValid()) selected.append(qd); | 857 | if (qd.isValid()) selected.append(qd); |
858 | 858 | ||
859 | return selected; | 859 | return selected; |
860 | } | 860 | } |
861 | 861 | ||
862 | 862 | ||
863 | void KOAgendaView::updateView() | 863 | void KOAgendaView::updateView() |
864 | { | 864 | { |
865 | if ( mBlockUpdating ) | 865 | if ( mBlockUpdating ) |
866 | return; | 866 | return; |
867 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 867 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
868 | fillAgenda(); | 868 | fillAgenda(); |
869 | 869 | ||
870 | } | 870 | } |
871 | 871 | ||
872 | 872 | ||
873 | /* | 873 | /* |
874 | Update configuration settings for the agenda view. This method is not | 874 | Update configuration settings for the agenda view. This method is not |
875 | complete. | 875 | complete. |
876 | */ | 876 | */ |
877 | void KOAgendaView::updateConfig() | 877 | void KOAgendaView::updateConfig() |
878 | { | 878 | { |
879 | if ( mBlockUpdating ) | 879 | if ( mBlockUpdating ) |
880 | return; | 880 | return; |
881 | 881 | ||
882 | 882 | ||
883 | 883 | ||
884 | // update config for children | 884 | // update config for children |
885 | mTimeLabels->updateConfig(); | 885 | mTimeLabels->updateConfig(); |
886 | mAgenda->storePosition(); | 886 | mAgenda->storePosition(); |
887 | mAgenda->updateConfig(); | 887 | mAgenda->updateConfig(); |
888 | mAllDayAgenda->updateConfig(); | 888 | mAllDayAgenda->updateConfig(); |
889 | // widget synchronization | 889 | // widget synchronization |
890 | //TODO: find a better way, maybe signal/slot | 890 | //TODO: find a better way, maybe signal/slot |
891 | mTimeLabels->positionChanged(); | 891 | mTimeLabels->positionChanged(); |
892 | 892 | ||
893 | // for some reason, this needs to be called explicitly | 893 | // for some reason, this needs to be called explicitly |
894 | mTimeLabels->repaint(); | 894 | mTimeLabels->repaint(); |
895 | 895 | ||
896 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 896 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
897 | 897 | ||
898 | // ToolTips displaying summary of events | 898 | // ToolTips displaying summary of events |
899 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 899 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
900 | ->mEnableToolTips); | 900 | ->mEnableToolTips); |
901 | 901 | ||
902 | //setHolidayMasks(); | 902 | //setHolidayMasks(); |
903 | 903 | ||
904 | //createDayLabels(); called by via updateView(); | 904 | //createDayLabels(); called by via updateView(); |
905 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 905 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
906 | updateView(); | 906 | updateView(); |
907 | mAgenda->restorePosition(); | 907 | mAgenda->restorePosition(); |
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 911 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
912 | { | 912 | { |
913 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 913 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
914 | //qDebug("KOAgendaView::updateEventDates "); | 914 | //qDebug("KOAgendaView::updateEventDates "); |
915 | QDateTime startDt,endDt; | 915 | QDateTime startDt,endDt; |
916 | QDate startDate; | 916 | QDate startDate; |
917 | int lenInSecs; | 917 | int lenInSecs; |
918 | // if ( type == KOAgenda::RESIZETOP ) | 918 | // if ( type == KOAgenda::RESIZETOP ) |
919 | // qDebug("RESIZETOP "); | 919 | // qDebug("RESIZETOP "); |
920 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 920 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
921 | // qDebug("RESIZEBOTTOM "); | 921 | // qDebug("RESIZEBOTTOM "); |
922 | // if ( type == KOAgenda::MOVE ) | 922 | // if ( type == KOAgenda::MOVE ) |
923 | // qDebug("MOVE "); | 923 | // qDebug("MOVE "); |
924 | if ( item->incidence()->type() == "Event" ) { | 924 | if ( item->incidence()->type() == "Event" ) { |
925 | startDt =item->incidence()->dtStart(); | 925 | startDt =item->incidence()->dtStart(); |
926 | endDt = item->incidence()->dtEnd(); | 926 | endDt = item->incidence()->dtEnd(); |
927 | lenInSecs = startDt.secsTo( endDt ); | 927 | lenInSecs = startDt.secsTo( endDt ); |
928 | } | 928 | } |
929 | 929 | ||
930 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 930 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
931 | 931 | ||
932 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 932 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
933 | startDate = mSelectedDates[item->mLastMoveXPos]; | 933 | startDate = mSelectedDates[item->mLastMoveXPos]; |
934 | } else { | 934 | } else { |
935 | if (item->cellX() < 0) { | 935 | if (item->cellX() < 0) { |
936 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 936 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
937 | } else { | 937 | } else { |
938 | startDate = mSelectedDates[item->cellX()]; | 938 | startDate = mSelectedDates[item->cellX()]; |
939 | } | 939 | } |
940 | } | 940 | } |
941 | startDt.setDate(startDate); | 941 | startDt.setDate(startDate); |
942 | 942 | ||
943 | if (item->incidence()->doesFloat()) { | 943 | if (item->incidence()->doesFloat()) { |
944 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 944 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
945 | } else { | 945 | } else { |
946 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 946 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
947 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 947 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
948 | if ( item->incidence()->type() == "Event" ) { | 948 | if ( item->incidence()->type() == "Event" ) { |
949 | if ( type == KOAgenda::MOVE ) { | 949 | if ( type == KOAgenda::MOVE ) { |
950 | endDt = startDt.addSecs(lenInSecs); | 950 | endDt = startDt.addSecs(lenInSecs); |
951 | 951 | ||
952 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 952 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
953 | if (item->lastMultiItem()) { | 953 | if (item->lastMultiItem()) { |
954 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 954 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
955 | endDt.setDate(startDate. | 955 | endDt.setDate(startDate. |
956 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 956 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
957 | } else { | 957 | } else { |
958 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 958 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
959 | endDt.setDate(startDate); | 959 | endDt.setDate(startDate); |
960 | } | 960 | } |
961 | } | 961 | } |
962 | } else { | 962 | } else { |
963 | // todo | 963 | // todo |
964 | if (item->lastMultiItem()) { | 964 | if (item->lastMultiItem()) { |
965 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 965 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
966 | endDt.setDate(startDate. | 966 | endDt.setDate(startDate. |
967 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 967 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
968 | } else { | 968 | } else { |
969 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 969 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
970 | if ( item->cellYBottom() > 0 ) | 970 | if ( item->cellYBottom() > 0 ) |
971 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 971 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
972 | else | 972 | else |
973 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 973 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
974 | endDt.setDate(startDate); | 974 | endDt.setDate(startDate); |
975 | } | 975 | } |
976 | } | 976 | } |
977 | } | 977 | } |
978 | if ( item->incidence()->type() == "Event" ) { | 978 | if ( item->incidence()->type() == "Event" ) { |
979 | item->incidence()->setDtStart(startDt); | 979 | item->incidence()->setDtStart(startDt); |
980 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 980 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
981 | } else if ( item->incidence()->type() == "Todo" ) { | 981 | } else if ( item->incidence()->type() == "Todo" ) { |
982 | Todo* to = static_cast<Todo*>(item->incidence()); | 982 | Todo* to = static_cast<Todo*>(item->incidence()); |
983 | 983 | ||
984 | to->setDtDue(endDt); | 984 | to->setDtDue(endDt); |
985 | if ( to->hasStartDate() ) { | 985 | if ( to->hasStartDate() ) { |
986 | if (to->dtStart() >= to->dtDue() ) | 986 | if (to->dtStart() >= to->dtDue() ) |
987 | to->setDtStart(to->dtDue().addDays( -2 )); | 987 | to->setDtStart(to->dtDue().addDays( -2 )); |
988 | } | 988 | } |
989 | 989 | ||
990 | } | 990 | } |
991 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 991 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
992 | item->incidence()->setRevision(item->incidence()->revision()+1); | 992 | item->incidence()->setRevision(item->incidence()->revision()+1); |
993 | item->setItemDate(startDt.date()); | 993 | item->setItemDate(startDt.date()); |
994 | //item->updateItem(); | 994 | //item->updateItem(); |
995 | if ( item->incidence()->type() == "Todo" ) { | 995 | if ( item->incidence()->type() == "Todo" ) { |
996 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 996 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
997 | 997 | ||
998 | } | 998 | } |
999 | else | 999 | else |
1000 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1000 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1001 | item->updateItem(); | 1001 | item->updateItem(); |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1004 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1005 | { | 1005 | { |
1006 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1006 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1007 | 1007 | ||
1008 | mSelectedDates.clear(); | 1008 | mSelectedDates.clear(); |
1009 | // qDebug("KOAgendaView::showDates "); | 1009 | // qDebug("KOAgendaView::showDates "); |
1010 | QDate d = start; | 1010 | QDate d = start; |
1011 | while (d <= end) { | 1011 | while (d <= end) { |
1012 | mSelectedDates.append(d); | 1012 | mSelectedDates.append(d); |
1013 | d = d.addDays( 1 ); | 1013 | d = d.addDays( 1 ); |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | // and update the view | 1016 | // and update the view |
1017 | fillAgenda(); | 1017 | fillAgenda(); |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | 1020 | ||
1021 | void KOAgendaView::showEvents(QPtrList<Event>) | 1021 | void KOAgendaView::showEvents(QPtrList<Event>) |
1022 | { | 1022 | { |
1023 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1023 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | void KOAgendaView::changeEventDisplay(Event *, int) | 1026 | void KOAgendaView::changeEventDisplay(Event *, int) |
1027 | { | 1027 | { |
1028 | // qDebug("KOAgendaView::changeEventDisplay "); | 1028 | // qDebug("KOAgendaView::changeEventDisplay "); |
1029 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1029 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1030 | // this should be re-written to be MUCH smarter. Right now we | 1030 | // this should be re-written to be MUCH smarter. Right now we |
1031 | // are just playing dumb. | 1031 | // are just playing dumb. |
1032 | fillAgenda(); | 1032 | fillAgenda(); |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | void KOAgendaView::fillAgenda(const QDate &) | 1035 | void KOAgendaView::fillAgenda(const QDate &) |
1036 | { | 1036 | { |
1037 | // qDebug("KOAgendaView::fillAgenda "); | 1037 | // qDebug("KOAgendaView::fillAgenda "); |
1038 | fillAgenda(); | 1038 | fillAgenda(); |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | void KOAgendaView::fillAgenda() | 1041 | void KOAgendaView::fillAgenda() |
1042 | { | 1042 | { |
1043 | if ( globalFlagBlockStartup ) | 1043 | if ( globalFlagBlockStartup ) |
1044 | return; | 1044 | return; |
1045 | if ( globalFlagBlockAgenda == 1 ) | 1045 | if ( globalFlagBlockAgenda == 1 ) |
1046 | return; | 1046 | return; |
1047 | //if ( globalFlagBlockAgenda == 2 ) | 1047 | //if ( globalFlagBlockAgenda == 2 ) |
1048 | //globalFlagBlockAgenda = 0; | 1048 | //globalFlagBlockAgenda = 0; |
1049 | // globalFlagBlockPainting = false; | 1049 | // globalFlagBlockPainting = false; |
1050 | if ( globalFlagBlockAgenda == 0 ) | 1050 | if ( globalFlagBlockAgenda == 0 ) |
1051 | globalFlagBlockAgenda = 1; | 1051 | globalFlagBlockAgenda = 1; |
1052 | // clearView(); | 1052 | // clearView(); |
1053 | //qDebug("fillAgenda()++++ "); | 1053 | //qDebug("fillAgenda()++++ "); |
1054 | globalFlagBlockAgendaItemPaint = 1; | 1054 | globalFlagBlockAgendaItemPaint = 1; |
1055 | 1055 | ||
1056 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1056 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1057 | mAgenda->changeColumns(mSelectedDates.count()); | 1057 | mAgenda->changeColumns(mSelectedDates.count()); |
1058 | qApp->processEvents(); | 1058 | qApp->processEvents(); |
1059 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1059 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1060 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1060 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1061 | setHolidayMasks(); | 1061 | setHolidayMasks(); |
1062 | 1062 | ||
1063 | //mAgenda->hideUnused(); | 1063 | //mAgenda->hideUnused(); |
1064 | //mAllDayAgenda->hideUnused(); | 1064 | //mAllDayAgenda->hideUnused(); |
1065 | 1065 | ||
1066 | // mAgenda->blockNextRepaint( false ); | 1066 | // mAgenda->blockNextRepaint( false ); |
1067 | // mAgenda->viewport()->repaint(); | 1067 | // mAgenda->viewport()->repaint(); |
1068 | // mAgenda->blockNextRepaint( true ); | 1068 | // mAgenda->blockNextRepaint( true ); |
1069 | mMinY.resize(mSelectedDates.count()); | 1069 | mMinY.resize(mSelectedDates.count()); |
1070 | mMaxY.resize(mSelectedDates.count()); | 1070 | mMaxY.resize(mSelectedDates.count()); |
1071 | 1071 | ||
1072 | QPtrList<Event> dayEvents; | 1072 | QPtrList<Event> dayEvents; |
1073 | 1073 | ||
1074 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1074 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1075 | // Therefore, gtodoset all of them. | 1075 | // Therefore, gtodoset all of them. |
1076 | QPtrList<Todo> todos = calendar()->todos(); | 1076 | QPtrList<Todo> todos = calendar()->todos(); |
1077 | 1077 | ||
1078 | mAgenda->setDateList(mSelectedDates); | 1078 | mAgenda->setDateList(mSelectedDates); |
1079 | 1079 | ||
1080 | QDate today = QDate::currentDate(); | 1080 | QDate today = QDate::currentDate(); |
1081 | 1081 | ||
1082 | DateList::ConstIterator dit; | 1082 | DateList::ConstIterator dit; |
1083 | int curCol = 0; | 1083 | int curCol = 0; |
1084 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1084 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1085 | QDate currentDate = *dit; | 1085 | QDate currentDate = *dit; |
1086 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1086 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1087 | // << endl; | 1087 | // << endl; |
1088 | 1088 | ||
1089 | dayEvents = calendar()->events(currentDate,true); | 1089 | dayEvents = calendar()->events(currentDate,true); |
1090 | 1090 | ||
1091 | // Default values, which can never be reached | 1091 | // Default values, which can never be reached |
1092 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1092 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1093 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1093 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1094 | 1094 | ||
1095 | unsigned int numEvent; | 1095 | unsigned int numEvent; |
1096 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1096 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1097 | Event *event = dayEvents.at(numEvent); | 1097 | Event *event = dayEvents.at(numEvent); |
1098 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1098 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1099 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1099 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1100 | continue; | 1100 | continue; |
1101 | // kdDebug() << " Event: " << event->summary() << endl; | 1101 | // kdDebug() << " Event: " << event->summary() << endl; |
1102 | 1102 | ||
1103 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1103 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1104 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1104 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1105 | 1105 | ||
1106 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1106 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1107 | 1107 | ||
1108 | if (event->doesFloat()) { | 1108 | if (event->doesFloat()) { |
1109 | if (event->recurrence()->doesRecur()) { | 1109 | if (event->recurrence()->doesRecur()) { |
1110 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1110 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1111 | } else { | 1111 | } else { |
1112 | if (beginX <= 0 && curCol == 0) { | 1112 | if (beginX <= 0 && curCol == 0) { |
1113 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1113 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1114 | } else if (beginX == curCol) { | 1114 | } else if (beginX == curCol) { |
1115 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1115 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | } else if (event->isMultiDay()) { | 1118 | } else if (event->isMultiDay()) { |
1119 | if ( event->doesRecur () ) { | 1119 | if ( event->doesRecur () ) { |
1120 | QDate dateit = currentDate; | 1120 | QDate dateit = currentDate; |
1121 | int count = 0; | 1121 | int count = 0; |
1122 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1122 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1123 | while (! event->recursOn( dateit ) && count <= max ) { | 1123 | while (! event->recursOn( dateit ) && count <= max ) { |
1124 | ++count; | 1124 | ++count; |
1125 | dateit = dateit.addDays( -1 ); | 1125 | dateit = dateit.addDays( -1 ); |
1126 | } | 1126 | } |
1127 | bool ok; | 1127 | bool ok; |
1128 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1128 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1129 | if ( ok ) | 1129 | if ( ok ) |
1130 | { | 1130 | { |
1131 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1131 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1132 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1132 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1133 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1133 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1134 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1134 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1135 | 1135 | ||
1136 | } | 1136 | } |
1137 | } | 1137 | } |
1138 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1138 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1139 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1139 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1140 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1140 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1141 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1141 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1142 | //qDebug("insert!!! "); | 1142 | //qDebug("insert!!! "); |
1143 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1143 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1144 | } | 1144 | } |
1145 | if (beginX == curCol) { | 1145 | if (beginX == curCol) { |
1146 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1146 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1147 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1147 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1148 | } else if (endX == curCol) { | 1148 | } else if (endX == curCol) { |
1149 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1149 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1150 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1150 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1151 | } else { | 1151 | } else { |
1152 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1152 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1153 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1153 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1154 | } | 1154 | } |
1155 | } else { | 1155 | } else { |
1156 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1156 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1157 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1157 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1158 | if (endY < startY) endY = startY; | 1158 | if (endY < startY) endY = startY; |
1159 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1159 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1160 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1160 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1161 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1161 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1162 | } | 1162 | } |
1163 | } | 1163 | } |
1164 | // ---------- [display Todos -------------- | 1164 | // ---------- [display Todos -------------- |
1165 | unsigned int numTodo; | 1165 | unsigned int numTodo; |
1166 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1166 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1167 | Todo *todo = todos.at(numTodo); | 1167 | Todo *todo = todos.at(numTodo); |
1168 | 1168 | ||
1169 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1169 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1170 | 1170 | ||
1171 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1171 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1172 | // Already completed items can be displayed on their original due date | 1172 | // Already completed items can be displayed on their original due date |
1173 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1173 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1174 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1174 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1175 | bool fillIn = false; | 1175 | bool fillIn = false; |
1176 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1176 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1177 | fillIn = true; | 1177 | fillIn = true; |
1178 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1178 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1179 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1179 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1180 | if ( fillIn ) { | 1180 | if ( fillIn ) { |
1181 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1181 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1182 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1182 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1183 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1183 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1184 | } | 1184 | } |
1185 | else { | 1185 | else { |
1186 | QDateTime dt; | 1186 | QDateTime dt; |
1187 | if ( todo->hasCompletedDate() ) | 1187 | if ( todo->hasCompletedDate() ) |
1188 | dt = todo->completed(); | 1188 | dt = todo->completed(); |
1189 | else | 1189 | else |
1190 | dt = todo->dtDue();; | 1190 | dt = todo->dtDue();; |
1191 | 1191 | ||
1192 | 1192 | ||
1193 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1193 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1194 | int hi = (18/KOPrefs::instance()->mHourSize); | 1194 | int hi = (18/KOPrefs::instance()->mHourSize); |
1195 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1195 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1196 | int startY = endY -hi; | 1196 | int startY = endY -hi; |
1197 | 1197 | ||
1198 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1198 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1199 | 1199 | ||
1200 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1200 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1201 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1201 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1202 | } | 1202 | } |
1203 | } | 1203 | } |
1204 | } | 1204 | } |
1205 | // ---------- display Todos] -------------- | 1205 | // ---------- display Todos] -------------- |
1206 | 1206 | ||
1207 | ++curCol; | 1207 | ++curCol; |
1208 | } | 1208 | } |
1209 | mAgenda->hideUnused(); | 1209 | mAgenda->hideUnused(); |
1210 | mAllDayAgenda->hideUnused(); | 1210 | mAllDayAgenda->hideUnused(); |
1211 | mAgenda->checkScrollBoundaries(); | 1211 | mAgenda->checkScrollBoundaries(); |
1212 | 1212 | ||
1213 | deleteSelectedDateTime(); | 1213 | deleteSelectedDateTime(); |
1214 | 1214 | ||
1215 | createDayLabels(); | 1215 | createDayLabels(); |
1216 | emit incidenceSelected( 0 ); | 1216 | emit incidenceSelected( 0 ); |
1217 | 1217 | ||
1218 | if ( globalFlagBlockAgenda == 2 ) { | 1218 | if ( globalFlagBlockAgenda == 2 ) { |
1219 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1219 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1220 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1220 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1221 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1221 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1222 | setStartHour( QTime::currentTime ().hour() ); | 1222 | setStartHour( QTime::currentTime ().hour() ); |
1223 | // qApp->processEvents(); | 1223 | // qApp->processEvents(); |
1224 | } | 1224 | } |
1225 | qApp->processEvents(); | 1225 | qApp->processEvents(); |
1226 | //qDebug("qApp->processEvents(); END "); | 1226 | //qDebug("qApp->processEvents(); END "); |
1227 | globalFlagBlockAgenda = 0; | 1227 | globalFlagBlockAgenda = 0; |
1228 | 1228 | ||
1229 | // mAgenda->hideUnused(); | 1229 | // mAgenda->hideUnused(); |
1230 | //mAllDayAgenda->hideUnused(); | 1230 | //mAllDayAgenda->hideUnused(); |
1231 | mAllDayAgenda->drawContentsToPainter(); | 1231 | mAllDayAgenda->drawContentsToPainter(); |
1232 | mAgenda->drawContentsToPainter(); | 1232 | mAgenda->drawContentsToPainter(); |
1233 | repaintAgenda(); | 1233 | repaintAgenda(); |
1234 | // mAgenda->finishUpdate(); | 1234 | // mAgenda->finishUpdate(); |
1235 | //mAllDayAgenda->finishUpdate(); | 1235 | //mAllDayAgenda->finishUpdate(); |
1236 | 1236 | ||
1237 | // repaintAgenda(); | 1237 | // repaintAgenda(); |
1238 | //qApp->processEvents(); | 1238 | //qApp->processEvents(); |
1239 | // globalFlagBlockAgenda = 0; | 1239 | // globalFlagBlockAgenda = 0; |
1240 | } | 1240 | } |
1241 | void KOAgendaView::repaintAgenda() | 1241 | void KOAgendaView::repaintAgenda() |
1242 | { | 1242 | { |
1243 | // mAllDayAgenda->drawContentsToPainter(); | 1243 | // mAllDayAgenda->drawContentsToPainter(); |
1244 | // mAllDayAgenda->viewport()->repaint( false ); | 1244 | // mAllDayAgenda->viewport()->repaint( false ); |
1245 | // mAgenda->drawContentsToPainter(); | 1245 | // mAgenda->drawContentsToPainter(); |
1246 | // mAgenda->viewport()->repaint( false ); | 1246 | // mAgenda->viewport()->repaint( false ); |
1247 | // qApp->processEvents(); | 1247 | // qApp->processEvents(); |
1248 | 1248 | ||
1249 | //qDebug("KOAgendaView::repaintAgenda() "); | 1249 | //qDebug("KOAgendaView::repaintAgenda() "); |
1250 | //qApp->processEvents(); | 1250 | //qApp->processEvents(); |
1251 | mAgenda->viewport()->repaint( false ); | 1251 | mAgenda->viewport()->repaint( false ); |
1252 | mAllDayAgenda->viewport()->repaint( false ); | 1252 | mAllDayAgenda->viewport()->repaint( false ); |
1253 | mAgenda->finishUpdate(); | 1253 | mAgenda->finishUpdate(); |
1254 | mAllDayAgenda->finishUpdate(); | 1254 | mAllDayAgenda->finishUpdate(); |
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | 1257 | ||
1258 | void KOAgendaView::clearView() | 1258 | void KOAgendaView::clearView() |
1259 | { | 1259 | { |
1260 | // kdDebug() << "ClearView" << endl; | 1260 | // kdDebug() << "ClearView" << endl; |
1261 | mAllDayAgenda->clear(); | 1261 | mAllDayAgenda->clear(); |
1262 | mAgenda->clear(); | 1262 | mAgenda->clear(); |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1265 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1266 | const QDate &td) | 1266 | const QDate &td) |
1267 | { | 1267 | { |
1268 | #ifndef KORG_NOPRINTER | 1268 | #ifndef KORG_NOPRINTER |
1269 | if (fd == td) | 1269 | if (fd == td) |
1270 | calPrinter->preview(CalPrinter::Day, fd, td); | 1270 | calPrinter->preview(CalPrinter::Day, fd, td); |
1271 | else | 1271 | else |
1272 | calPrinter->preview(CalPrinter::Week, fd, td); | 1272 | calPrinter->preview(CalPrinter::Week, fd, td); |
1273 | #endif | 1273 | #endif |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | // void KOAgendaView::updateMovedTodo() | 1276 | // void KOAgendaView::updateMovedTodo() |
1277 | // { | 1277 | // { |
1278 | // // updateConfig(); | 1278 | // // updateConfig(); |
1279 | // // emit updateTodoViews(); | 1279 | // // emit updateTodoViews(); |
1280 | // } | 1280 | // } |
1281 | 1281 | ||
1282 | void KOAgendaView::newEvent(int gx, int gy) | 1282 | void KOAgendaView::newEvent(int gx, int gy) |
1283 | { | 1283 | { |
1284 | if (!mSelectedDates.count()) return; | 1284 | if (!mSelectedDates.count()) return; |
1285 | 1285 | ||
1286 | QDate day = mSelectedDates[gx]; | 1286 | QDate day = mSelectedDates[gx]; |
1287 | 1287 | ||
1288 | QTime time = mAgenda->gyToTime(gy); | 1288 | QTime time = mAgenda->gyToTime(gy); |
1289 | QDateTime dt(day,time); | 1289 | QDateTime dt(day,time); |
1290 | // if ( dt < QDateTime::currentDateTime () ) | 1290 | // if ( dt < QDateTime::currentDateTime () ) |
1291 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1291 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1292 | emit newEventSignal(dt); | 1292 | emit newEventSignal(dt); |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1295 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1296 | { | 1296 | { |
1297 | if (!mSelectedDates.count()) return; | 1297 | if (!mSelectedDates.count()) return; |
1298 | 1298 | ||
1299 | QDate dayStart = mSelectedDates[gxStart]; | 1299 | QDate dayStart = mSelectedDates[gxStart]; |
1300 | QDate dayEnd = mSelectedDates[gxEnd]; | 1300 | QDate dayEnd = mSelectedDates[gxEnd]; |
1301 | 1301 | ||
1302 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1302 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1303 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1303 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1304 | 1304 | ||
1305 | QDateTime dtStart(dayStart,timeStart); | 1305 | QDateTime dtStart(dayStart,timeStart); |
1306 | QDateTime dtEnd(dayEnd,timeEnd); | 1306 | QDateTime dtEnd(dayEnd,timeEnd); |
1307 | 1307 | ||
1308 | emit newEventSignal(dtStart,dtEnd); | 1308 | emit newEventSignal(dtStart,dtEnd); |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | void KOAgendaView::newEventAllDay(int gx, int ) | 1311 | void KOAgendaView::newEventAllDay(int gx, int ) |
1312 | { | 1312 | { |
1313 | if (!mSelectedDates.count()) return; | 1313 | if (!mSelectedDates.count()) return; |
1314 | 1314 | ||
1315 | QDate day = mSelectedDates[gx]; | 1315 | QDate day = mSelectedDates[gx]; |
1316 | 1316 | ||
1317 | emit newEventSignal(day); | 1317 | emit newEventSignal(day); |
1318 | } | 1318 | } |
1319 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1319 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1320 | { | 1320 | { |
1321 | if (!mSelectedDates.count()) return; | 1321 | if (!mSelectedDates.count()) return; |
1322 | 1322 | ||
1323 | QDateTime day (mSelectedDates[gx] ); | 1323 | QDateTime day (mSelectedDates[gx] ); |
1324 | emit newTodoSignal(day, true); | 1324 | emit newTodoSignal(day, true); |
1325 | } | 1325 | } |
1326 | void KOAgendaView::newTodo(int gx, int gy ) | 1326 | void KOAgendaView::newTodo(int gx, int gy ) |
1327 | { | 1327 | { |
1328 | if (!mSelectedDates.count()) return; | 1328 | if (!mSelectedDates.count()) return; |
1329 | QDate dayStart = mSelectedDates[gx]; | 1329 | QDate dayStart = mSelectedDates[gx]; |
1330 | QTime timeStart = mAgenda->gyToTime(gy); | 1330 | QTime timeStart = mAgenda->gyToTime(gy); |
1331 | QDateTime dt (dayStart,timeStart); | 1331 | QDateTime dt (dayStart,timeStart); |
1332 | emit newTodoSignal( dt, false ); | 1332 | emit newTodoSignal( dt, false ); |
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1335 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1336 | { | 1336 | { |
1337 | uint i; | 1337 | uint i; |
1338 | for(i=0;i<mMinY.size();++i) { | 1338 | for(i=0;i<mMinY.size();++i) { |
1339 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1339 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1340 | else mEventIndicatorTop->enableColumn(i,false); | 1340 | else mEventIndicatorTop->enableColumn(i,false); |
1341 | } | 1341 | } |
1342 | 1342 | ||
1343 | mEventIndicatorTop->update(); | 1343 | mEventIndicatorTop->update(); |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1346 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1347 | { | 1347 | { |
1348 | uint i; | 1348 | uint i; |
1349 | for(i=0;i<mMaxY.size();++i) { | 1349 | for(i=0;i<mMaxY.size();++i) { |
1350 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1350 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1351 | else mEventIndicatorBottom->enableColumn(i,false); | 1351 | else mEventIndicatorBottom->enableColumn(i,false); |
1352 | } | 1352 | } |
1353 | 1353 | ||
1354 | mEventIndicatorBottom->update(); | 1354 | mEventIndicatorBottom->update(); |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | void KOAgendaView::startDrag(Event *event) | 1357 | void KOAgendaView::startDrag(Event *event) |
1358 | { | 1358 | { |
1359 | #ifndef KORG_NODND | 1359 | #ifndef KORG_NODND |
1360 | DndFactory factory( calendar() ); | 1360 | DndFactory factory( calendar() ); |
1361 | ICalDrag *vd = factory.createDrag(event,this); | 1361 | ICalDrag *vd = factory.createDrag(event,this); |
1362 | if (vd->drag()) { | 1362 | if (vd->drag()) { |
1363 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1363 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1364 | } | 1364 | } |
1365 | #endif | 1365 | #endif |
1366 | } | 1366 | } |
1367 | 1367 | ||
1368 | void KOAgendaView::readSettings() | 1368 | void KOAgendaView::readSettings() |
1369 | { | 1369 | { |
1370 | readSettings(KOGlobals::config()); | 1370 | readSettings(KOGlobals::config()); |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | void KOAgendaView::readSettings(KConfig *config) | 1373 | void KOAgendaView::readSettings(KConfig *config) |
1374 | { | 1374 | { |
1375 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1375 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1376 | 1376 | ||
1377 | config->setGroup("Views"); | 1377 | config->setGroup("Views"); |
1378 | 1378 | ||
1379 | //#ifndef KORG_NOSPLITTER | 1379 | //#ifndef KORG_NOSPLITTER |
1380 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1380 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1381 | if (sizes.count() == 2) { | 1381 | if (sizes.count() == 2) { |
1382 | if ( sizes[0] < 20 ) { | 1382 | if ( sizes[0] < 20 ) { |
1383 | sizes[1] = sizes[1] +20 - sizes[0]; | 1383 | sizes[1] = sizes[1] +20 - sizes[0]; |
1384 | sizes[0] = 20; | 1384 | sizes[0] = 20; |
1385 | } | 1385 | } |
1386 | mSplitterAgenda->setSizes(sizes); | 1386 | mSplitterAgenda->setSizes(sizes); |
1387 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1387 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1388 | } | 1388 | } |
1389 | //#endif | 1389 | //#endif |
1390 | 1390 | ||
1391 | // updateConfig(); | 1391 | // updateConfig(); |
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | void KOAgendaView::writeSettings(KConfig *config) | 1394 | void KOAgendaView::writeSettings(KConfig *config) |
1395 | { | 1395 | { |
1396 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1396 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1397 | 1397 | ||
1398 | config->setGroup("Views"); | 1398 | config->setGroup("Views"); |
1399 | 1399 | ||
1400 | //#ifndef KORG_NOSPLITTER | 1400 | //#ifndef KORG_NOSPLITTER |
1401 | QValueList<int> list = mSplitterAgenda->sizes(); | 1401 | QValueList<int> list = mSplitterAgenda->sizes(); |
1402 | config->writeEntry("Separator AgendaView",list); | 1402 | config->writeEntry("Separator AgendaView",list); |
1403 | //qDebug("write %d %d ", list[0],list[1] ); | 1403 | //qDebug("write %d %d ", list[0],list[1] ); |
1404 | //#endif | 1404 | //#endif |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | void KOAgendaView::setHolidayMasks() | 1407 | void KOAgendaView::setHolidayMasks() |
1408 | { | 1408 | { |
1409 | mHolidayMask.resize(mSelectedDates.count()); | 1409 | mHolidayMask.resize(mSelectedDates.count()); |
1410 | 1410 | ||
1411 | uint i; | 1411 | uint i; |
1412 | for(i=0;i<mSelectedDates.count();++i) { | 1412 | for(i=0;i<mSelectedDates.count();++i) { |
1413 | QDate date = mSelectedDates[i]; | 1413 | QDate date = mSelectedDates[i]; |
1414 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1414 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1415 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1415 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1416 | bool showHoliday = false; | 1416 | bool showHoliday = false; |
1417 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1417 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1418 | QPtrList<Event> events = calendar()->events( date, true ); | 1418 | QPtrList<Event> events = calendar()->events( date, true ); |
1419 | Event *event; | 1419 | Event *event; |
1420 | for( event = events.first(); event; event = events.next() ) { | 1420 | for( event = events.first(); event; event = events.next() ) { |
1421 | if ( event->categories().contains("Holiday") || | 1421 | if ( event->isHoliday()) { |
1422 | event->categories().contains(i18n("Holiday"))) { | ||
1423 | showHoliday = true; | 1422 | showHoliday = true; |
1424 | break; | 1423 | break; |
1425 | } | 1424 | } |
1426 | } | 1425 | } |
1427 | 1426 | ||
1428 | } | 1427 | } |
1429 | 1428 | ||
1430 | #ifndef KORG_NOPLUGINS | 1429 | #ifndef KORG_NOPLUGINS |
1431 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1430 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1432 | !KOCore::self()->holiday(date).isEmpty(); | 1431 | !KOCore::self()->holiday(date).isEmpty(); |
1433 | #endif | 1432 | #endif |
1434 | bool showDay = showSaturday || showSunday || showHoliday; | 1433 | bool showDay = showSaturday || showSunday || showHoliday; |
1435 | 1434 | ||
1436 | if (showDay) { | 1435 | if (showDay) { |
1437 | mHolidayMask.at(i) = true; | 1436 | mHolidayMask.at(i) = true; |
1438 | } else { | 1437 | } else { |
1439 | mHolidayMask.at(i) = false; | 1438 | mHolidayMask.at(i) = false; |
1440 | } | 1439 | } |
1441 | } | 1440 | } |
1442 | 1441 | ||
1443 | mAgenda->setHolidayMask(&mHolidayMask); | 1442 | mAgenda->setHolidayMask(&mHolidayMask); |
1444 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1443 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1445 | } | 1444 | } |
1446 | 1445 | ||
1447 | void KOAgendaView::setContentsPos(int y) | 1446 | void KOAgendaView::setContentsPos(int y) |
1448 | { | 1447 | { |
1449 | mAgenda->setContentsPos(0,y); | 1448 | mAgenda->setContentsPos(0,y); |
1450 | } | 1449 | } |
1451 | 1450 | ||
1452 | void KOAgendaView::setExpandedButton( bool expanded ) | 1451 | void KOAgendaView::setExpandedButton( bool expanded ) |
1453 | { | 1452 | { |
1454 | if ( expanded ) { | 1453 | if ( expanded ) { |
1455 | mExpandButton->setPixmap( mExpandedPixmap ); | 1454 | mExpandButton->setPixmap( mExpandedPixmap ); |
1456 | } else { | 1455 | } else { |
1457 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 1456 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
1458 | } | 1457 | } |
1459 | } | 1458 | } |
1460 | 1459 | ||
1461 | void KOAgendaView::clearSelection() | 1460 | void KOAgendaView::clearSelection() |
1462 | { | 1461 | { |
1463 | mAgenda->deselectItem(); | 1462 | mAgenda->deselectItem(); |
1464 | mAllDayAgenda->deselectItem(); | 1463 | mAllDayAgenda->deselectItem(); |
1465 | } | 1464 | } |
1466 | 1465 | ||
1467 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1466 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1468 | int gxEnd, int gyEnd) | 1467 | int gxEnd, int gyEnd) |
1469 | { | 1468 | { |
1470 | mTimeSpanInAllDay = true; | 1469 | mTimeSpanInAllDay = true; |
1471 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1470 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1472 | } | 1471 | } |
1473 | 1472 | ||
1474 | 1473 | ||
1475 | 1474 | ||
1476 | 1475 | ||
1477 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1476 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1478 | int gxEnd, int gyEnd) | 1477 | int gxEnd, int gyEnd) |
1479 | { | 1478 | { |
1480 | if (!mSelectedDates.count()) return; | 1479 | if (!mSelectedDates.count()) return; |
1481 | 1480 | ||
1482 | QDate dayStart = mSelectedDates[gxStart]; | 1481 | QDate dayStart = mSelectedDates[gxStart]; |
1483 | QDate dayEnd = mSelectedDates[gxEnd]; | 1482 | QDate dayEnd = mSelectedDates[gxEnd]; |
1484 | 1483 | ||
1485 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1484 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1486 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1485 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1487 | 1486 | ||
1488 | QDateTime dtStart(dayStart,timeStart); | 1487 | QDateTime dtStart(dayStart,timeStart); |
1489 | QDateTime dtEnd(dayEnd,timeEnd); | 1488 | QDateTime dtEnd(dayEnd,timeEnd); |
1490 | 1489 | ||
1491 | mTimeSpanBegin = dtStart; | 1490 | mTimeSpanBegin = dtStart; |
1492 | mTimeSpanEnd = dtEnd; | 1491 | mTimeSpanEnd = dtEnd; |
1493 | 1492 | ||
1494 | } | 1493 | } |
1495 | 1494 | ||
1496 | void KOAgendaView::deleteSelectedDateTime() | 1495 | void KOAgendaView::deleteSelectedDateTime() |
1497 | { | 1496 | { |
1498 | mTimeSpanBegin.setDate(QDate()); | 1497 | mTimeSpanBegin.setDate(QDate()); |
1499 | mTimeSpanEnd.setDate(QDate()); | 1498 | mTimeSpanEnd.setDate(QDate()); |
1500 | mTimeSpanInAllDay = false; | 1499 | mTimeSpanInAllDay = false; |
1501 | } | 1500 | } |
1502 | 1501 | ||
1503 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1502 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1504 | { | 1503 | { |
1505 | e->ignore(); | 1504 | e->ignore(); |
1506 | } | 1505 | } |
1507 | 1506 | ||
1508 | void KOAgendaView::scrollOneHourUp() | 1507 | void KOAgendaView::scrollOneHourUp() |
1509 | { | 1508 | { |
1510 | 1509 | ||
1511 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1510 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1512 | } | 1511 | } |
1513 | void KOAgendaView::scrollOneHourDown() | 1512 | void KOAgendaView::scrollOneHourDown() |
1514 | { | 1513 | { |
1515 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1514 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1516 | } | 1515 | } |
1517 | 1516 | ||
1518 | void KOAgendaView::setStartHour( int h ) | 1517 | void KOAgendaView::setStartHour( int h ) |
1519 | { | 1518 | { |
1520 | mAgenda->setStartHour( h ); | 1519 | mAgenda->setStartHour( h ); |
1521 | 1520 | ||
1522 | } | 1521 | } |
1523 | void KOAgendaView::setInitStartHour() | 1522 | void KOAgendaView::setInitStartHour() |
1524 | { | 1523 | { |
1525 | 1524 | ||
1526 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1525 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1527 | setStartHour( QTime::currentTime ().hour() ); | 1526 | setStartHour( QTime::currentTime ().hour() ); |
1528 | else | 1527 | else |
1529 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1528 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1530 | 1529 | ||
1531 | } | 1530 | } |
1532 | 1531 | ||
1533 | 1532 | ||
1534 | void KOAgendaView::updateTodo( Todo * t, int ) | 1533 | void KOAgendaView::updateTodo( Todo * t, int ) |
1535 | { | 1534 | { |
1536 | if ( !isVisible() ) | 1535 | if ( !isVisible() ) |
1537 | return; | 1536 | return; |
1538 | bool remove = false; | 1537 | bool remove = false; |
1539 | bool removeAD = false; | 1538 | bool removeAD = false; |
1540 | QDate da; | 1539 | QDate da; |
1541 | if ( t->hasCompletedDate() ) | 1540 | if ( t->hasCompletedDate() ) |
1542 | da = t->completed().date(); | 1541 | da = t->completed().date(); |
1543 | else | 1542 | else |
1544 | da = t->dtDue().date(); | 1543 | da = t->dtDue().date(); |
1545 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1544 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1546 | remove = true; | 1545 | remove = true; |
1547 | removeAD = true; | 1546 | removeAD = true; |
1548 | } | 1547 | } |
1549 | else { | 1548 | else { |
1550 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1549 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1551 | if ( overdue && | 1550 | if ( overdue && |
1552 | QDate::currentDate() >= mSelectedDates.first() && | 1551 | QDate::currentDate() >= mSelectedDates.first() && |
1553 | QDate::currentDate() <= mSelectedDates.last()) { | 1552 | QDate::currentDate() <= mSelectedDates.last()) { |
1554 | removeAD = false; | 1553 | removeAD = false; |
1555 | remove = true; | 1554 | remove = true; |
1556 | } | 1555 | } |
1557 | else { | 1556 | else { |
1558 | 1557 | ||
1559 | if ( da < mSelectedDates.first() || | 1558 | if ( da < mSelectedDates.first() || |
1560 | da > mSelectedDates.last() ) { | 1559 | da > mSelectedDates.last() ) { |
1561 | remove = true; | 1560 | remove = true; |
1562 | removeAD = true; | 1561 | removeAD = true; |
1563 | } else { | 1562 | } else { |
1564 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1563 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1565 | removeAD = !remove; | 1564 | removeAD = !remove; |
1566 | } | 1565 | } |
1567 | } | 1566 | } |
1568 | } | 1567 | } |
1569 | int days = mSelectedDates.first().daysTo( da ); | 1568 | int days = mSelectedDates.first().daysTo( da ); |
1570 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1569 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1571 | mAgenda->updateTodo( t , days, remove); | 1570 | mAgenda->updateTodo( t , days, remove); |
1572 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1571 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1573 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1572 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1574 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1573 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1575 | 1574 | ||
1576 | } | 1575 | } |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index d7a4112..36cd990 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,931 +1,931 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name ), mCalendar( 0 ) | 106 | : QFrame( parent, name ), mCalendar( 0 ) |
107 | 107 | ||
108 | #if 0 | 108 | #if 0 |
109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
110 | QFrame(parent, name) | 110 | QFrame(parent, name) |
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
114 | mPendingUpdateBeforeRepaint = false; | 114 | mPendingUpdateBeforeRepaint = false; |
115 | mouseDown = false; | 115 | mouseDown = false; |
116 | // initialize dynamic arrays | 116 | // initialize dynamic arrays |
117 | bDays.resize ( NUMDAYS ); | 117 | bDays.resize ( NUMDAYS ); |
118 | days = new QDate[NUMDAYS]; | 118 | days = new QDate[NUMDAYS]; |
119 | daylbls = new QString[NUMDAYS]; | 119 | daylbls = new QString[NUMDAYS]; |
120 | events = new int[NUMDAYS]; | 120 | events = new int[NUMDAYS]; |
121 | mToolTip = new DynamicTip(this); | 121 | mToolTip = new DynamicTip(this); |
122 | 122 | ||
123 | // set default values used for drawing the matrix | 123 | // set default values used for drawing the matrix |
124 | mDefaultBackColor = palette().active().base(); | 124 | mDefaultBackColor = palette().active().base(); |
125 | mDefaultTextColor = palette().active().foreground(); | 125 | mDefaultTextColor = palette().active().foreground(); |
126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
128 | mSelectedDaysColor = QColor("white"); | 128 | mSelectedDaysColor = QColor("white"); |
129 | mTodayMarginWidth = 2; | 129 | mTodayMarginWidth = 2; |
130 | mSelEnd = mSelStart = NOSELECTION; | 130 | mSelEnd = mSelStart = NOSELECTION; |
131 | 131 | ||
132 | setAcceptDrops(true); | 132 | setAcceptDrops(true); |
133 | //setFont( QFont("Arial", 10) ); | 133 | //setFont( QFont("Arial", 10) ); |
134 | 134 | ||
135 | mUpdateTimer = new QTimer( this ); | 135 | mUpdateTimer = new QTimer( this ); |
136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
137 | mRepaintTimer = new QTimer( this ); | 137 | mRepaintTimer = new QTimer( this ); |
138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
139 | mDayChanged = false; | 139 | mDayChanged = false; |
140 | updateView(); | 140 | updateView(); |
141 | } | 141 | } |
142 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 142 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
143 | { | 143 | { |
144 | 144 | ||
145 | int tmp = getDayIndexFrom(p.x(), p.y()); | 145 | int tmp = getDayIndexFrom(p.x(), p.y()); |
146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
147 | return QString(); | 147 | return QString(); |
148 | QDate mDate = days[tmp]; | 148 | QDate mDate = days[tmp]; |
149 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 149 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
150 | Event *event; | 150 | Event *event; |
151 | QStringList mToolTip; | 151 | QStringList mToolTip; |
152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
153 | QString mToolTipText; | 153 | QString mToolTipText; |
154 | QString text; | 154 | QString text; |
155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
156 | if (event->isMultiDay()) { | 156 | if (event->isMultiDay()) { |
157 | QString prefix = "<->";multiday = 2; | 157 | QString prefix = "<->";multiday = 2; |
158 | QString time; | 158 | QString time; |
159 | if ( event->doesRecur() ) { | 159 | if ( event->doesRecur() ) { |
160 | if ( event->recursOn( mDate) ) { | 160 | if ( event->recursOn( mDate) ) { |
161 | prefix ="->" ;multiday = 1; | 161 | prefix ="->" ;multiday = 1; |
162 | } | 162 | } |
163 | else { | 163 | else { |
164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
165 | if ( event->recursOn( mDate.addDays( -days)) ) { | 165 | if ( event->recursOn( mDate.addDays( -days)) ) { |
166 | prefix ="<-" ;multiday = 3; | 166 | prefix ="<-" ;multiday = 3; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } else { | 169 | } else { |
170 | if (mDate == event->dtStart().date()) { | 170 | if (mDate == event->dtStart().date()) { |
171 | prefix ="->" ;multiday = 1; | 171 | prefix ="->" ;multiday = 1; |
172 | } else if (mDate == event->dtEnd().date()) { | 172 | } else if (mDate == event->dtEnd().date()) { |
173 | prefix ="<-" ;multiday = 3; | 173 | prefix ="<-" ;multiday = 3; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | if ( !event->doesFloat() ) { | 176 | if ( !event->doesFloat() ) { |
177 | if ( mDate == event->dtStart().date () ) | 177 | if ( mDate == event->dtStart().date () ) |
178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
179 | else if ( mDate == event->dtEnd().date () ) | 179 | else if ( mDate == event->dtEnd().date () ) |
180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
181 | 181 | ||
182 | } | 182 | } |
183 | text = time + event->summary(); | 183 | text = time + event->summary(); |
184 | mToolTipText += prefix + text; | 184 | mToolTipText += prefix + text; |
185 | } else { | 185 | } else { |
186 | if (event->doesFloat()) { | 186 | if (event->doesFloat()) { |
187 | text = event->summary(); | 187 | text = event->summary(); |
188 | mToolTipText += text; | 188 | mToolTipText += text; |
189 | } | 189 | } |
190 | else { | 190 | else { |
191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
192 | text += " " + event->summary(); | 192 | text += " " + event->summary(); |
193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | if ( !event->location().isEmpty() ) | 196 | if ( !event->location().isEmpty() ) |
197 | mToolTipText += " (" + event->location() + ")"; | 197 | mToolTipText += " (" + event->location() + ")"; |
198 | #if QT_VERSION >= 0x030000 | 198 | #if QT_VERSION >= 0x030000 |
199 | mToolTipText.replace( '<' , "<" ); | 199 | mToolTipText.replace( '<' , "<" ); |
200 | mToolTipText.replace( '>' , ">" ); | 200 | mToolTipText.replace( '>' , ">" ); |
201 | #else | 201 | #else |
202 | if ( mToolTipText.find ('<') >= 0 ) { | 202 | if ( mToolTipText.find ('<') >= 0 ) { |
203 | mToolTipText.replace( QRegExp("<") , "<" ); | 203 | mToolTipText.replace( QRegExp("<") , "<" ); |
204 | } | 204 | } |
205 | if ( mToolTipText.find ('>') >= 0 ) { | 205 | if ( mToolTipText.find ('>') >= 0 ) { |
206 | mToolTipText.replace( QRegExp(">") , ">" ); | 206 | mToolTipText.replace( QRegExp(">") , ">" ); |
207 | } | 207 | } |
208 | #endif | 208 | #endif |
209 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 209 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
210 | mToolTip.append( mToolTipText ); | 210 | mToolTip.append( mToolTipText ); |
211 | } | 211 | } |
212 | mToolTip.sort(); | 212 | mToolTip.sort(); |
213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
214 | } | 214 | } |
215 | void KODayMatrix::setCalendar( Calendar *cal ) | 215 | void KODayMatrix::setCalendar( Calendar *cal ) |
216 | { | 216 | { |
217 | mCalendar = cal; | 217 | mCalendar = cal; |
218 | 218 | ||
219 | setAcceptDrops( mCalendar ); | 219 | setAcceptDrops( mCalendar ); |
220 | 220 | ||
221 | updateEvents(); | 221 | updateEvents(); |
222 | } | 222 | } |
223 | 223 | ||
224 | QColor KODayMatrix::getShadedColor(QColor color) | 224 | QColor KODayMatrix::getShadedColor(QColor color) |
225 | { | 225 | { |
226 | QColor shaded; | 226 | QColor shaded; |
227 | int h=0; | 227 | int h=0; |
228 | int s=0; | 228 | int s=0; |
229 | int v=0; | 229 | int v=0; |
230 | color.hsv(&h,&s,&v); | 230 | color.hsv(&h,&s,&v); |
231 | s = s/4; | 231 | s = s/4; |
232 | v = 192+v/4; | 232 | v = 192+v/4; |
233 | shaded.setHsv(h,s,v); | 233 | shaded.setHsv(h,s,v); |
234 | 234 | ||
235 | return shaded; | 235 | return shaded; |
236 | } | 236 | } |
237 | 237 | ||
238 | KODayMatrix::~KODayMatrix() | 238 | KODayMatrix::~KODayMatrix() |
239 | { | 239 | { |
240 | // delete mKODaymatrixWhatsThis; | 240 | // delete mKODaymatrixWhatsThis; |
241 | delete [] days; | 241 | delete [] days; |
242 | delete [] daylbls; | 242 | delete [] daylbls; |
243 | delete [] events; | 243 | delete [] events; |
244 | delete mToolTip; | 244 | delete mToolTip; |
245 | } | 245 | } |
246 | 246 | ||
247 | /* | 247 | /* |
248 | void KODayMatrix::setStartDate(QDate start) | 248 | void KODayMatrix::setStartDate(QDate start) |
249 | { | 249 | { |
250 | updateView(start); | 250 | updateView(start); |
251 | } | 251 | } |
252 | */ | 252 | */ |
253 | 253 | ||
254 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 254 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
255 | { | 255 | { |
256 | 256 | ||
257 | if (mSelStart == NOSELECTION) { | 257 | if (mSelStart == NOSELECTION) { |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | 260 | ||
261 | //cope with selection being out of matrix limits at top (< 0) | 261 | //cope with selection being out of matrix limits at top (< 0) |
262 | int i0 = mSelStart; | 262 | int i0 = mSelStart; |
263 | if (i0 < 0) { | 263 | if (i0 < 0) { |
264 | for (int i = i0; i < 0; i++) { | 264 | for (int i = i0; i < 0; i++) { |
265 | selDays.append(days[0].addDays(i)); | 265 | selDays.append(days[0].addDays(i)); |
266 | } | 266 | } |
267 | i0 = 0; | 267 | i0 = 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 270 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
271 | if (mSelEnd > NUMDAYS-1) { | 271 | if (mSelEnd > NUMDAYS-1) { |
272 | for (int i = i0; i <= NUMDAYS-1; i++) { | 272 | for (int i = i0; i <= NUMDAYS-1; i++) { |
273 | selDays.append(days[i]); | 273 | selDays.append(days[i]); |
274 | } | 274 | } |
275 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 275 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
276 | selDays.append(days[0].addDays(i)); | 276 | selDays.append(days[0].addDays(i)); |
277 | } | 277 | } |
278 | 278 | ||
279 | // apply normal routine to selection being entirely within matrix limits | 279 | // apply normal routine to selection being entirely within matrix limits |
280 | } else { | 280 | } else { |
281 | for (int i = i0; i <= mSelEnd; i++) { | 281 | for (int i = i0; i <= mSelEnd; i++) { |
282 | selDays.append(days[i]); | 282 | selDays.append(days[i]); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 287 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
288 | { | 288 | { |
289 | mSelStart = startdate.daysTo(start); | 289 | mSelStart = startdate.daysTo(start); |
290 | if ( mSelStart < 0 ) | 290 | if ( mSelStart < 0 ) |
291 | mSelStart = 0; | 291 | mSelStart = 0; |
292 | mSelEnd = startdate.daysTo(end); | 292 | mSelEnd = startdate.daysTo(end); |
293 | //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd ); | 293 | //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd ); |
294 | if ( mSelEnd < 0 ) | 294 | if ( mSelEnd < 0 ) |
295 | clearSelection(); | 295 | clearSelection(); |
296 | } | 296 | } |
297 | void KODayMatrix::clearSelection() | 297 | void KODayMatrix::clearSelection() |
298 | { | 298 | { |
299 | mSelEnd = mSelStart = NOSELECTION; | 299 | mSelEnd = mSelStart = NOSELECTION; |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | void KODayMatrix::recalculateToday() | 303 | void KODayMatrix::recalculateToday() |
304 | { | 304 | { |
305 | today = -1; | 305 | today = -1; |
306 | for (int i=0; i<NUMDAYS; i++) { | 306 | for (int i=0; i<NUMDAYS; i++) { |
307 | events[i] = 0; | 307 | events[i] = 0; |
308 | days[i] = startdate.addDays(i); | 308 | days[i] = startdate.addDays(i); |
309 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 309 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
310 | 310 | ||
311 | // if today is in the currently displayed month, hilight today | 311 | // if today is in the currently displayed month, hilight today |
312 | if (days[i].year() == QDate::currentDate().year() && | 312 | if (days[i].year() == QDate::currentDate().year() && |
313 | days[i].month() == QDate::currentDate().month() && | 313 | days[i].month() == QDate::currentDate().month() && |
314 | days[i].day() == QDate::currentDate().day()) { | 314 | days[i].day() == QDate::currentDate().day()) { |
315 | today = i; | 315 | today = i; |
316 | } | 316 | } |
317 | } | 317 | } |
318 | // qDebug(QString("Today is visible at %1.").arg(today)); | 318 | // qDebug(QString("Today is visible at %1.").arg(today)); |
319 | } | 319 | } |
320 | 320 | ||
321 | void KODayMatrix::updateView() | 321 | void KODayMatrix::updateView() |
322 | { | 322 | { |
323 | updateView(startdate); | 323 | updateView(startdate); |
324 | } | 324 | } |
325 | void KODayMatrix::repaintViewTimed() | 325 | void KODayMatrix::repaintViewTimed() |
326 | { | 326 | { |
327 | mRepaintTimer->stop(); | 327 | mRepaintTimer->stop(); |
328 | repaint(false); | 328 | repaint(false); |
329 | } | 329 | } |
330 | void KODayMatrix::updateViewTimed() | 330 | void KODayMatrix::updateViewTimed() |
331 | { | 331 | { |
332 | mUpdateTimer->stop(); | 332 | mUpdateTimer->stop(); |
333 | if ( !mCalendar ) { | 333 | if ( !mCalendar ) { |
334 | qDebug("NOT CAL "); | 334 | qDebug("NOT CAL "); |
335 | return; | 335 | return; |
336 | } | 336 | } |
337 | //qDebug("KODayMatrix::updateViewTimed "); | 337 | //qDebug("KODayMatrix::updateViewTimed "); |
338 | for(int i = 0; i < NUMDAYS; i++) { | 338 | for(int i = 0; i < NUMDAYS; i++) { |
339 | // if events are set for the day then remember to draw it bold | 339 | // if events are set for the day then remember to draw it bold |
340 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 340 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
341 | Event *event; | 341 | Event *event; |
342 | int numEvents = eventlist.count(); | 342 | int numEvents = eventlist.count(); |
343 | QString holiStr = ""; | 343 | QString holiStr = ""; |
344 | bDays.clearBit(i); | 344 | bDays.clearBit(i); |
345 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 345 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
346 | ushort recurType = event->recurrence()->doesRecur(); | 346 | ushort recurType = event->recurrence()->doesRecur(); |
347 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 347 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
348 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 348 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
349 | numEvents--; | 349 | numEvents--; |
350 | } | 350 | } |
351 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 351 | if ( event->isHoliday()) { |
352 | if ( !holiStr.isEmpty() ) | 352 | if ( !holiStr.isEmpty() ) |
353 | holiStr += "\n"; | 353 | holiStr += "\n"; |
354 | holiStr += event->summary(); | 354 | holiStr += event->summary(); |
355 | if ( !event->location().isEmpty() ) | 355 | if ( !event->location().isEmpty() ) |
356 | holiStr += " (" + event->location() + ")"; | 356 | holiStr += " (" + event->location() + ")"; |
357 | } | 357 | } |
358 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { | 358 | if ( event->isBirthday()) { |
359 | if ( !holiStr.isEmpty() ) | 359 | if ( !holiStr.isEmpty() ) |
360 | holiStr += "\n"; | 360 | holiStr += "\n"; |
361 | holiStr += i18n("Birthday") + ": "+event->summary(); | 361 | holiStr += i18n("Birthday") + ": "+event->summary(); |
362 | if ( !event->location().isEmpty() ) | 362 | if ( !event->location().isEmpty() ) |
363 | holiStr += " (" + event->location() + ")"; | 363 | holiStr += " (" + event->location() + ")"; |
364 | bDays.setBit(i); | 364 | bDays.setBit(i); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | events[i] = numEvents; | 367 | events[i] = numEvents; |
368 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 368 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
369 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 369 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
370 | !holiStr.isEmpty()) { | 370 | !holiStr.isEmpty()) { |
371 | mHolidays[i] = holiStr; | 371 | mHolidays[i] = holiStr; |
372 | } else { | 372 | } else { |
373 | mHolidays[i] = QString::null; | 373 | mHolidays[i] = QString::null; |
374 | } | 374 | } |
375 | } | 375 | } |
376 | if ( ! mPendingUpdateBeforeRepaint ) | 376 | if ( ! mPendingUpdateBeforeRepaint ) |
377 | repaint(false); | 377 | repaint(false); |
378 | } | 378 | } |
379 | void KODayMatrix::updateView(QDate actdate) | 379 | void KODayMatrix::updateView(QDate actdate) |
380 | { | 380 | { |
381 | 381 | ||
382 | if ( ! actdate.isValid() ) { | 382 | if ( ! actdate.isValid() ) { |
383 | //qDebug("date not valid "); | 383 | //qDebug("date not valid "); |
384 | return; | 384 | return; |
385 | } | 385 | } |
386 | mDayChanged = false; | 386 | mDayChanged = false; |
387 | //flag to indicate if the starting day of the matrix has changed by this call | 387 | //flag to indicate if the starting day of the matrix has changed by this call |
388 | //mDayChanged = false; | 388 | //mDayChanged = false; |
389 | // if a new startdate is to be set then apply Cornelius's calculation | 389 | // if a new startdate is to be set then apply Cornelius's calculation |
390 | // of the first day to be shown | 390 | // of the first day to be shown |
391 | if (actdate != startdate) { | 391 | if (actdate != startdate) { |
392 | // reset index of selection according to shift of starting date from startdate to actdate | 392 | // reset index of selection according to shift of starting date from startdate to actdate |
393 | if (mSelStart != NOSELECTION) { | 393 | if (mSelStart != NOSELECTION) { |
394 | int tmp = actdate.daysTo(startdate); | 394 | int tmp = actdate.daysTo(startdate); |
395 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 395 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
396 | // shift selection if new one would be visible at least partly ! | 396 | // shift selection if new one would be visible at least partly ! |
397 | 397 | ||
398 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 398 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
399 | // nested if is required for next X display pushed from a different month - correction required | 399 | // nested if is required for next X display pushed from a different month - correction required |
400 | // otherwise, for month forward and backward, it must be avoided | 400 | // otherwise, for month forward and backward, it must be avoided |
401 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 401 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
402 | mSelStart = mSelStart + tmp; | 402 | mSelStart = mSelStart + tmp; |
403 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 403 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
404 | mSelEnd = mSelEnd + tmp; | 404 | mSelEnd = mSelEnd + tmp; |
405 | } | 405 | } |
406 | } | 406 | } |
407 | startdate = actdate; | 407 | startdate = actdate; |
408 | mDayChanged = true; | 408 | mDayChanged = true; |
409 | recalculateToday(); | 409 | recalculateToday(); |
410 | } | 410 | } |
411 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 411 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
412 | if ( !isVisible() ) { | 412 | if ( !isVisible() ) { |
413 | mPendingUpdateBeforeRepaint = true; | 413 | mPendingUpdateBeforeRepaint = true; |
414 | } else { | 414 | } else { |
415 | #ifdef DESKTOP_VERSION | 415 | #ifdef DESKTOP_VERSION |
416 | //mRepaintTimer->start( 100 ); | 416 | //mRepaintTimer->start( 100 ); |
417 | mUpdateTimer->start( 100 ); | 417 | mUpdateTimer->start( 100 ); |
418 | #else | 418 | #else |
419 | mRepaintTimer->start( 350 ); | 419 | mRepaintTimer->start( 350 ); |
420 | mUpdateTimer->start( 1200 ); | 420 | mUpdateTimer->start( 1200 ); |
421 | #endif | 421 | #endif |
422 | } | 422 | } |
423 | } | 423 | } |
424 | void KODayMatrix::updateEvents() | 424 | void KODayMatrix::updateEvents() |
425 | { | 425 | { |
426 | if ( !mCalendar ) return; | 426 | if ( !mCalendar ) return; |
427 | 427 | ||
428 | for( int i = 0; i < NUMDAYS; i++ ) { | 428 | for( int i = 0; i < NUMDAYS; i++ ) { |
429 | // if events are set for the day then remember to draw it bold | 429 | // if events are set for the day then remember to draw it bold |
430 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 430 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
431 | int numEvents = eventlist.count(); | 431 | int numEvents = eventlist.count(); |
432 | Event *event; | 432 | Event *event; |
433 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 433 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
434 | ushort recurType = event->doesRecur(); | 434 | ushort recurType = event->doesRecur(); |
435 | 435 | ||
436 | if ( ( recurType == Recurrence::rDaily && | 436 | if ( ( recurType == Recurrence::rDaily && |
437 | !KOPrefs::instance()->mDailyRecur ) || | 437 | !KOPrefs::instance()->mDailyRecur ) || |
438 | ( recurType == Recurrence::rWeekly && | 438 | ( recurType == Recurrence::rWeekly && |
439 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 439 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
440 | numEvents--; | 440 | numEvents--; |
441 | } | 441 | } |
442 | } | 442 | } |
443 | events[ i ] = numEvents; | 443 | events[ i ] = numEvents; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | const QDate& KODayMatrix::getDate(int offset) | 447 | const QDate& KODayMatrix::getDate(int offset) |
448 | { | 448 | { |
449 | if (offset < 0 || offset > NUMDAYS-1) { | 449 | if (offset < 0 || offset > NUMDAYS-1) { |
450 | qDebug("Wrong offset2 %d", offset); | 450 | qDebug("Wrong offset2 %d", offset); |
451 | return days[0]; | 451 | return days[0]; |
452 | } | 452 | } |
453 | return days[offset]; | 453 | return days[offset]; |
454 | } | 454 | } |
455 | 455 | ||
456 | QString KODayMatrix::getHolidayLabel(int offset) | 456 | QString KODayMatrix::getHolidayLabel(int offset) |
457 | { | 457 | { |
458 | if (offset < 0 || offset > NUMDAYS-1) { | 458 | if (offset < 0 || offset > NUMDAYS-1) { |
459 | qDebug("Wrong offset1 %d", offset); | 459 | qDebug("Wrong offset1 %d", offset); |
460 | return QString(); | 460 | return QString(); |
461 | } | 461 | } |
462 | return mHolidays[offset]; | 462 | return mHolidays[offset]; |
463 | } | 463 | } |
464 | 464 | ||
465 | int KODayMatrix::getDayIndexFrom(int x, int y) | 465 | int KODayMatrix::getDayIndexFrom(int x, int y) |
466 | { | 466 | { |
467 | int colModulo = (width()-2) % 7; | 467 | int colModulo = (width()-2) % 7; |
468 | int rowModulo = (height()-2) % 6; | 468 | int rowModulo = (height()-2) % 6; |
469 | #if 0 | 469 | #if 0 |
470 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 470 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
471 | 6 - x/daysize.width() : x/daysize.width()); | 471 | 6 - x/daysize.width() : x/daysize.width()); |
472 | #endif | 472 | #endif |
473 | int xVal = (x-colModulo/2-2)/daysize.width(); | 473 | int xVal = (x-colModulo/2-2)/daysize.width(); |
474 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 474 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
475 | 475 | ||
476 | 476 | ||
477 | return 7*(yVal) + xVal; | 477 | return 7*(yVal) + xVal; |
478 | 478 | ||
479 | } | 479 | } |
480 | 480 | ||
481 | // ---------------------------------------------------------------------------- | 481 | // ---------------------------------------------------------------------------- |
482 | // M O U S E E V E N T H A N D L I N G | 482 | // M O U S E E V E N T H A N D L I N G |
483 | // ---------------------------------------------------------------------------- | 483 | // ---------------------------------------------------------------------------- |
484 | 484 | ||
485 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 485 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
486 | { | 486 | { |
487 | 487 | ||
488 | if ( e->button() == LeftButton ) | 488 | if ( e->button() == LeftButton ) |
489 | mouseDown = true; | 489 | mouseDown = true; |
490 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 490 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
491 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 491 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
492 | mSelInit = mSelStart; | 492 | mSelInit = mSelStart; |
493 | mSelEnd = mSelStart; | 493 | mSelEnd = mSelStart; |
494 | repaint(false); | 494 | repaint(false); |
495 | } | 495 | } |
496 | 496 | ||
497 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 497 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
498 | { | 498 | { |
499 | if ( e->button() == LeftButton ) | 499 | if ( e->button() == LeftButton ) |
500 | if ( ! mouseDown ) { | 500 | if ( ! mouseDown ) { |
501 | return; | 501 | return; |
502 | } | 502 | } |
503 | else | 503 | else |
504 | mouseDown = false; | 504 | mouseDown = false; |
505 | int tmp = getDayIndexFrom(e->x(), e->y()); | 505 | int tmp = getDayIndexFrom(e->x(), e->y()); |
506 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 506 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
507 | 507 | ||
508 | if (mSelInit > tmp) { | 508 | if (mSelInit > tmp) { |
509 | mSelEnd = mSelInit; | 509 | mSelEnd = mSelInit; |
510 | if (tmp != mSelStart) { | 510 | if (tmp != mSelStart) { |
511 | mSelStart = tmp; | 511 | mSelStart = tmp; |
512 | repaint(false); | 512 | repaint(false); |
513 | } | 513 | } |
514 | } else { | 514 | } else { |
515 | mSelStart = mSelInit; | 515 | mSelStart = mSelInit; |
516 | 516 | ||
517 | //repaint only if selection has changed | 517 | //repaint only if selection has changed |
518 | if (tmp != mSelEnd) { | 518 | if (tmp != mSelEnd) { |
519 | mSelEnd = tmp; | 519 | mSelEnd = tmp; |
520 | repaint(false); | 520 | repaint(false); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | 523 | ||
524 | DateList daylist; | 524 | DateList daylist; |
525 | if ( mSelStart < 0 ) | 525 | if ( mSelStart < 0 ) |
526 | mSelStart = 0; | 526 | mSelStart = 0; |
527 | for (int i = mSelStart; i <= mSelEnd; i++) { | 527 | for (int i = mSelStart; i <= mSelEnd; i++) { |
528 | daylist.append(days[i]); | 528 | daylist.append(days[i]); |
529 | } | 529 | } |
530 | emit selected((const DateList)daylist); | 530 | emit selected((const DateList)daylist); |
531 | 531 | ||
532 | } | 532 | } |
533 | 533 | ||
534 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 534 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
535 | { | 535 | { |
536 | if ( ! mouseDown ) { | 536 | if ( ! mouseDown ) { |
537 | return; | 537 | return; |
538 | } | 538 | } |
539 | int tmp = getDayIndexFrom(e->x(), e->y()); | 539 | int tmp = getDayIndexFrom(e->x(), e->y()); |
540 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 540 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
541 | 541 | ||
542 | if (mSelInit > tmp) { | 542 | if (mSelInit > tmp) { |
543 | mSelEnd = mSelInit; | 543 | mSelEnd = mSelInit; |
544 | if (tmp != mSelStart) { | 544 | if (tmp != mSelStart) { |
545 | mSelStart = tmp; | 545 | mSelStart = tmp; |
546 | repaint(false); | 546 | repaint(false); |
547 | } | 547 | } |
548 | } else { | 548 | } else { |
549 | mSelStart = mSelInit; | 549 | mSelStart = mSelInit; |
550 | 550 | ||
551 | //repaint only if selection has changed | 551 | //repaint only if selection has changed |
552 | if (tmp != mSelEnd) { | 552 | if (tmp != mSelEnd) { |
553 | mSelEnd = tmp; | 553 | mSelEnd = tmp; |
554 | repaint(false); | 554 | repaint(false); |
555 | } | 555 | } |
556 | } | 556 | } |
557 | } | 557 | } |
558 | 558 | ||
559 | // ---------------------------------------------------------------------------- | 559 | // ---------------------------------------------------------------------------- |
560 | // D R A G ' N D R O P H A N D L I N G | 560 | // D R A G ' N D R O P H A N D L I N G |
561 | // ---------------------------------------------------------------------------- | 561 | // ---------------------------------------------------------------------------- |
562 | 562 | ||
563 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 563 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
564 | { | 564 | { |
565 | #ifndef KORG_NODND | 565 | #ifndef KORG_NODND |
566 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 566 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
567 | e->ignore(); | 567 | e->ignore(); |
568 | return; | 568 | return; |
569 | } | 569 | } |
570 | 570 | ||
571 | // some visual feedback | 571 | // some visual feedback |
572 | // oldPalette = palette(); | 572 | // oldPalette = palette(); |
573 | // setPalette(my_HilitePalette); | 573 | // setPalette(my_HilitePalette); |
574 | // update(); | 574 | // update(); |
575 | #endif | 575 | #endif |
576 | } | 576 | } |
577 | 577 | ||
578 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 578 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
579 | { | 579 | { |
580 | #ifndef KORG_NODND | 580 | #ifndef KORG_NODND |
581 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 581 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
582 | e->ignore(); | 582 | e->ignore(); |
583 | return; | 583 | return; |
584 | } | 584 | } |
585 | 585 | ||
586 | e->accept(); | 586 | e->accept(); |
587 | #endif | 587 | #endif |
588 | } | 588 | } |
589 | 589 | ||
590 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 590 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
591 | { | 591 | { |
592 | #ifndef KORG_NODND | 592 | #ifndef KORG_NODND |
593 | // setPalette(oldPalette); | 593 | // setPalette(oldPalette); |
594 | // update(); | 594 | // update(); |
595 | #endif | 595 | #endif |
596 | } | 596 | } |
597 | 597 | ||
598 | void KODayMatrix::dropEvent(QDropEvent *e) | 598 | void KODayMatrix::dropEvent(QDropEvent *e) |
599 | { | 599 | { |
600 | #ifndef KORG_NODND | 600 | #ifndef KORG_NODND |
601 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 601 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
602 | 602 | ||
603 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 603 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
604 | e->ignore(); | 604 | e->ignore(); |
605 | return; | 605 | return; |
606 | } | 606 | } |
607 | 607 | ||
608 | DndFactory factory( mCalendar ); | 608 | DndFactory factory( mCalendar ); |
609 | Event *event = factory.createDrop(e); | 609 | Event *event = factory.createDrop(e); |
610 | 610 | ||
611 | if (event) { | 611 | if (event) { |
612 | e->acceptAction(); | 612 | e->acceptAction(); |
613 | 613 | ||
614 | Event *existingEvent = mCalendar->event(event->uid()); | 614 | Event *existingEvent = mCalendar->event(event->uid()); |
615 | 615 | ||
616 | if(existingEvent) { | 616 | if(existingEvent) { |
617 | // uniquify event | 617 | // uniquify event |
618 | event->recreate(); | 618 | event->recreate(); |
619 | /* | 619 | /* |
620 | KMessageBox::sorry(this, | 620 | KMessageBox::sorry(this, |
621 | i18n("Event already exists in this calendar."), | 621 | i18n("Event already exists in this calendar."), |
622 | i18n("Drop Event")); | 622 | i18n("Drop Event")); |
623 | delete event; | 623 | delete event; |
624 | return; | 624 | return; |
625 | */ | 625 | */ |
626 | } | 626 | } |
627 | // kdDebug() << "Drop new Event" << endl; | 627 | // kdDebug() << "Drop new Event" << endl; |
628 | // Adjust date | 628 | // Adjust date |
629 | QDateTime start = event->dtStart(); | 629 | QDateTime start = event->dtStart(); |
630 | QDateTime end = event->dtEnd(); | 630 | QDateTime end = event->dtEnd(); |
631 | int duration = start.daysTo(end); | 631 | int duration = start.daysTo(end); |
632 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 632 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
633 | 633 | ||
634 | start.setDate(days[idx]); | 634 | start.setDate(days[idx]); |
635 | end.setDate(days[idx].addDays(duration)); | 635 | end.setDate(days[idx].addDays(duration)); |
636 | 636 | ||
637 | event->setDtStart(start); | 637 | event->setDtStart(start); |
638 | event->setDtEnd(end); | 638 | event->setDtEnd(end); |
639 | mCalendar->addEvent(event); | 639 | mCalendar->addEvent(event); |
640 | 640 | ||
641 | emit eventDropped(event); | 641 | emit eventDropped(event); |
642 | } else { | 642 | } else { |
643 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 643 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
644 | e->ignore(); | 644 | e->ignore(); |
645 | } | 645 | } |
646 | #endif | 646 | #endif |
647 | } | 647 | } |
648 | 648 | ||
649 | // ---------------------------------------------------------------------------- | 649 | // ---------------------------------------------------------------------------- |
650 | // P A I N T E V E N T H A N D L I N G | 650 | // P A I N T E V E N T H A N D L I N G |
651 | // ---------------------------------------------------------------------------- | 651 | // ---------------------------------------------------------------------------- |
652 | 652 | ||
653 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 653 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
654 | { | 654 | { |
655 | QRect sz = frameRect(); | 655 | QRect sz = frameRect(); |
656 | if ( sz.width() <= 0 || sz.height() <= 0 ) | 656 | if ( sz.width() <= 0 || sz.height() <= 0 ) |
657 | return; | 657 | return; |
658 | if ( mPendingUpdateBeforeRepaint ) { | 658 | if ( mPendingUpdateBeforeRepaint ) { |
659 | updateViewTimed(); | 659 | updateViewTimed(); |
660 | mPendingUpdateBeforeRepaint = false; | 660 | mPendingUpdateBeforeRepaint = false; |
661 | } | 661 | } |
662 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { | 662 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { |
663 | myPix.resize(sz.size() ); | 663 | myPix.resize(sz.size() ); |
664 | } | 664 | } |
665 | QPainter p(&myPix); | 665 | QPainter p(&myPix); |
666 | p.setFont(font()); | 666 | p.setFont(font()); |
667 | 667 | ||
668 | 668 | ||
669 | int dheight = daysize.height(); | 669 | int dheight = daysize.height(); |
670 | int dwidth = daysize.width(); | 670 | int dwidth = daysize.width(); |
671 | int row,col; | 671 | int row,col; |
672 | int selw, selh; | 672 | int selw, selh; |
673 | int xyOff = frameWidth(); | 673 | int xyOff = frameWidth(); |
674 | int colModulo = sz.width() % 7; | 674 | int colModulo = sz.width() % 7; |
675 | int rowModulo = sz.height() % 6; | 675 | int rowModulo = sz.height() % 6; |
676 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 676 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
677 | 677 | ||
678 | bool isRTL = KOGlobals::self()->reverseLayout(); | 678 | bool isRTL = KOGlobals::self()->reverseLayout(); |
679 | 679 | ||
680 | // draw background and topleft frame | 680 | // draw background and topleft frame |
681 | p.fillRect(pevent->rect(), mDefaultBackColor); | 681 | p.fillRect(pevent->rect(), mDefaultBackColor); |
682 | p.setPen(mDefaultTextColor); | 682 | p.setPen(mDefaultTextColor); |
683 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 683 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
684 | int mSelStartT = mSelStart; | 684 | int mSelStartT = mSelStart; |
685 | int mSelEndT = mSelEnd; | 685 | int mSelEndT = mSelEnd; |
686 | if ( mSelEndT >= NUMDAYS ) | 686 | if ( mSelEndT >= NUMDAYS ) |
687 | mSelEndT = NUMDAYS-1; | 687 | mSelEndT = NUMDAYS-1; |
688 | // draw selected days with highlighted background color | 688 | // draw selected days with highlighted background color |
689 | if (mSelStart != NOSELECTION) { | 689 | if (mSelStart != NOSELECTION) { |
690 | bool skip = false; | 690 | bool skip = false; |
691 | if ( ! mouseDown ) { | 691 | if ( ! mouseDown ) { |
692 | int mo = days[20].month(); | 692 | int mo = days[20].month(); |
693 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 693 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
694 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 694 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
695 | int startMo = days[mSelStartT].month(); | 695 | int startMo = days[mSelStartT].month(); |
696 | int endMo = days[mSelEndT].month(); | 696 | int endMo = days[mSelEndT].month(); |
697 | if ( startMo == 12 && mo == 1 && endMo == 1 ) | 697 | if ( startMo == 12 && mo == 1 && endMo == 1 ) |
698 | startMo = 1; | 698 | startMo = 1; |
699 | if ( endMo == 1 && mo == 12 ) | 699 | if ( endMo == 1 && mo == 12 ) |
700 | endMo = 12; | 700 | endMo = 12; |
701 | if ( (startMo > mo || endMo < mo) ) { | 701 | if ( (startMo > mo || endMo < mo) ) { |
702 | skip = true; | 702 | skip = true; |
703 | } else { | 703 | } else { |
704 | if ( days[mSelStartT].month() != mo ) { | 704 | if ( days[mSelStartT].month() != mo ) { |
705 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 705 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
706 | mSelStartT += add +1; | 706 | mSelStartT += add +1; |
707 | } | 707 | } |
708 | if ( days[mSelEndT].month() != mo ) { | 708 | if ( days[mSelEndT].month() != mo ) { |
709 | int sub = days[mSelEndT].day(); | 709 | int sub = days[mSelEndT].day(); |
710 | mSelEndT -= sub ; | 710 | mSelEndT -= sub ; |
711 | } | 711 | } |
712 | } | 712 | } |
713 | } | 713 | } |
714 | if ( ! skip ) { | 714 | if ( ! skip ) { |
715 | row = mSelStartT/7; | 715 | row = mSelStartT/7; |
716 | col = mSelStartT -row*7; | 716 | col = mSelStartT -row*7; |
717 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 717 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
718 | int addCol = 0; | 718 | int addCol = 0; |
719 | int addRow = 0; | 719 | int addRow = 0; |
720 | int addRow2 = 0; | 720 | int addRow2 = 0; |
721 | int addCol2 = 0; | 721 | int addCol2 = 0; |
722 | if (row == mSelEndT/7) { | 722 | if (row == mSelEndT/7) { |
723 | if ( rowModulo ) { | 723 | if ( rowModulo ) { |
724 | if ( row >= 6 - rowModulo ) | 724 | if ( row >= 6 - rowModulo ) |
725 | addRow = row - 5 + rowModulo; | 725 | addRow = row - 5 + rowModulo; |
726 | } | 726 | } |
727 | if ( colModulo ) { | 727 | if ( colModulo ) { |
728 | int colt1 = mSelEndT%7; | 728 | int colt1 = mSelEndT%7; |
729 | //qDebug("colt1 %d ", colt1 ); | 729 | //qDebug("colt1 %d ", colt1 ); |
730 | if ( colt1 >= 7 - colModulo ) | 730 | if ( colt1 >= 7 - colModulo ) |
731 | addCol = colt1 - 7 + colModulo+1; | 731 | addCol = colt1 - 7 + colModulo+1; |
732 | int colt = mSelStartT%7; | 732 | int colt = mSelStartT%7; |
733 | if ( colt >= 7 - colModulo ) | 733 | if ( colt >= 7 - colModulo ) |
734 | addCol2 = colt - 7 + colModulo; | 734 | addCol2 = colt - 7 + colModulo; |
735 | addCol -= addCol2; | 735 | addCol -= addCol2; |
736 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 736 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
737 | } | 737 | } |
738 | // Single row selection | 738 | // Single row selection |
739 | if ( row == 0) | 739 | if ( row == 0) |
740 | addRow = 1; | 740 | addRow = 1; |
741 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 741 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
742 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 742 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
743 | } else { | 743 | } else { |
744 | // draw first row to the right | 744 | // draw first row to the right |
745 | if ( colModulo ) { | 745 | if ( colModulo ) { |
746 | if ( col >= 7 - colModulo ) | 746 | if ( col >= 7 - colModulo ) |
747 | addCol2 = col - 7 + colModulo; | 747 | addCol2 = col - 7 + colModulo; |
748 | } | 748 | } |
749 | if ( rowModulo ) { | 749 | if ( rowModulo ) { |
750 | if ( row >= 6 - rowModulo ) | 750 | if ( row >= 6 - rowModulo ) |
751 | addRow = row - 5 + rowModulo; | 751 | addRow = row - 5 + rowModulo; |
752 | } | 752 | } |
753 | if ( row == 0) | 753 | if ( row == 0) |
754 | addRow = 1; | 754 | addRow = 1; |
755 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, | 755 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, |
756 | dheight+1, selcol); | 756 | dheight+1, selcol); |
757 | // draw full block till last line | 757 | // draw full block till last line |
758 | selh = mSelEndT/7-row; | 758 | selh = mSelEndT/7-row; |
759 | addRow = 0; | 759 | addRow = 0; |
760 | if ( rowModulo ) { | 760 | if ( rowModulo ) { |
761 | if ( mSelEndT/7 >= 6 - rowModulo ) | 761 | if ( mSelEndT/7 >= 6 - rowModulo ) |
762 | addRow = mSelEndT/7 - 5 + rowModulo; | 762 | addRow = mSelEndT/7 - 5 + rowModulo; |
763 | } | 763 | } |
764 | if (selh > 1) { | 764 | if (selh > 1) { |
765 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 765 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
766 | } | 766 | } |
767 | // draw last block from left to mSelEndT | 767 | // draw last block from left to mSelEndT |
768 | selw = mSelEndT-7*(mSelEndT/7)+1; | 768 | selw = mSelEndT-7*(mSelEndT/7)+1; |
769 | //qDebug("esl %d ",selw ); | 769 | //qDebug("esl %d ",selw ); |
770 | int add = 0; | 770 | int add = 0; |
771 | if ( colModulo ) { | 771 | if ( colModulo ) { |
772 | add = 7 - colModulo; | 772 | add = 7 - colModulo; |
773 | if ( selw > add ) | 773 | if ( selw > add ) |
774 | add = selw - add; | 774 | add = selw - add; |
775 | else | 775 | else |
776 | add = 0; | 776 | add = 0; |
777 | } | 777 | } |
778 | //qDebug("add %d ", add); | 778 | //qDebug("add %d ", add); |
779 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 779 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
780 | selw*dwidth+add, dheight+1, selcol); | 780 | selw*dwidth+add, dheight+1, selcol); |
781 | } | 781 | } |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | // iterate over all days in the matrix and draw the day label in appropriate colors | 785 | // iterate over all days in the matrix and draw the day label in appropriate colors |
786 | QColor actcol = mDefaultTextColorShaded; | 786 | QColor actcol = mDefaultTextColorShaded; |
787 | p.setPen(actcol); | 787 | p.setPen(actcol); |
788 | QPen tmppen; | 788 | QPen tmppen; |
789 | for(int i = 0; i < NUMDAYS; i++) { | 789 | for(int i = 0; i < NUMDAYS; i++) { |
790 | row = i/7; | 790 | row = i/7; |
791 | col = isRTL ? 6-(i-row*7) : i-row*7; | 791 | col = isRTL ? 6-(i-row*7) : i-row*7; |
792 | 792 | ||
793 | // if it is the first day of a month switch color from normal to shaded and vice versa | 793 | // if it is the first day of a month switch color from normal to shaded and vice versa |
794 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 794 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
795 | if (actcol == mDefaultTextColorShaded) { | 795 | if (actcol == mDefaultTextColorShaded) { |
796 | actcol = mDefaultTextColor; | 796 | actcol = mDefaultTextColor; |
797 | } else { | 797 | } else { |
798 | actcol = mDefaultTextColorShaded; | 798 | actcol = mDefaultTextColorShaded; |
799 | } | 799 | } |
800 | p.setPen(actcol); | 800 | p.setPen(actcol); |
801 | } | 801 | } |
802 | if (actcol == mDefaultTextColorShaded) { | 802 | if (actcol == mDefaultTextColorShaded) { |
803 | if ( ! mouseDown ) { | 803 | if ( ! mouseDown ) { |
804 | continue; | 804 | continue; |
805 | } | 805 | } |
806 | } | 806 | } |
807 | //Reset pen color after selected days block | 807 | //Reset pen color after selected days block |
808 | if (i == mSelEndT+1) { | 808 | if (i == mSelEndT+1) { |
809 | p.setPen(actcol); | 809 | p.setPen(actcol); |
810 | } | 810 | } |
811 | 811 | ||
812 | // if today then draw rectangle around day | 812 | // if today then draw rectangle around day |
813 | if (today == i) { | 813 | if (today == i) { |
814 | tmppen = p.pen(); | 814 | tmppen = p.pen(); |
815 | QPen mTodayPen(p.pen()); | 815 | QPen mTodayPen(p.pen()); |
816 | if ( daysize.width() < 20 ) | 816 | if ( daysize.width() < 20 ) |
817 | mTodayPen.setWidth(1); | 817 | mTodayPen.setWidth(1); |
818 | else | 818 | else |
819 | mTodayPen.setWidth(mTodayMarginWidth); | 819 | mTodayPen.setWidth(mTodayMarginWidth); |
820 | //draw red rectangle for holidays | 820 | //draw red rectangle for holidays |
821 | if (!mHolidays[i].isNull()) { | 821 | if (!mHolidays[i].isNull()) { |
822 | if (actcol == mDefaultTextColor) { | 822 | if (actcol == mDefaultTextColor) { |
823 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 823 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
824 | } else { | 824 | } else { |
825 | mTodayPen.setColor(mHolidayColorShaded); | 825 | mTodayPen.setColor(mHolidayColorShaded); |
826 | } | 826 | } |
827 | } | 827 | } |
828 | //draw gray rectangle for today if in selection | 828 | //draw gray rectangle for today if in selection |
829 | if (i >= mSelStartT && i <= mSelEndT) { | 829 | if (i >= mSelStartT && i <= mSelEndT) { |
830 | QColor grey("grey"); | 830 | QColor grey("grey"); |
831 | mTodayPen.setColor(grey); | 831 | mTodayPen.setColor(grey); |
832 | } | 832 | } |
833 | p.setPen(mTodayPen); | 833 | p.setPen(mTodayPen); |
834 | 834 | ||
835 | 835 | ||
836 | int addCol = 0; | 836 | int addCol = 0; |
837 | int addRow = 0; | 837 | int addRow = 0; |
838 | if (rowModulo) { | 838 | if (rowModulo) { |
839 | if ( row >= 6 - rowModulo ) | 839 | if ( row >= 6 - rowModulo ) |
840 | addRow = row - 5 + rowModulo; | 840 | addRow = row - 5 + rowModulo; |
841 | } | 841 | } |
842 | if ( colModulo ) { | 842 | if ( colModulo ) { |
843 | if ( col >= 7 - colModulo ) | 843 | if ( col >= 7 - colModulo ) |
844 | addCol = col - 6 + colModulo-1; | 844 | addCol = col - 6 + colModulo-1; |
845 | } | 845 | } |
846 | if ( col == 0 ) | 846 | if ( col == 0 ) |
847 | addCol = 1; | 847 | addCol = 1; |
848 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); | 848 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); |
849 | p.setPen(tmppen); | 849 | p.setPen(tmppen); |
850 | } | 850 | } |
851 | 851 | ||
852 | // if any events are on that day then draw it using a bold font | 852 | // if any events are on that day then draw it using a bold font |
853 | if (events[i] > 0) { | 853 | if (events[i] > 0) { |
854 | QFont myFont = font(); | 854 | QFont myFont = font(); |
855 | myFont.setBold(true); | 855 | myFont.setBold(true); |
856 | p.setFont(myFont); | 856 | p.setFont(myFont); |
857 | } | 857 | } |
858 | 858 | ||
859 | // if it is a holiday then use the default holiday color | 859 | // if it is a holiday then use the default holiday color |
860 | if (!mHolidays[i].isNull()) { | 860 | if (!mHolidays[i].isNull()) { |
861 | if ( bDays.testBit(i) ) { | 861 | if ( bDays.testBit(i) ) { |
862 | p.setPen(Qt::green); | 862 | p.setPen(Qt::green); |
863 | } else { | 863 | } else { |
864 | if (actcol == mDefaultTextColor) { | 864 | if (actcol == mDefaultTextColor) { |
865 | p.setPen(KOPrefs::instance()->mHolidayColor); | 865 | p.setPen(KOPrefs::instance()->mHolidayColor); |
866 | } else { | 866 | } else { |
867 | p.setPen(mHolidayColorShaded); | 867 | p.setPen(mHolidayColorShaded); |
868 | } | 868 | } |
869 | } | 869 | } |
870 | } | 870 | } |
871 | 871 | ||
872 | // draw selected days with special color | 872 | // draw selected days with special color |
873 | // DO NOT specially highlight holidays in selection ! | 873 | // DO NOT specially highlight holidays in selection ! |
874 | if (i >= mSelStartT && i <= mSelEndT) { | 874 | if (i >= mSelStartT && i <= mSelEndT) { |
875 | ;//p.setPen(mSelectedDaysColor); | 875 | ;//p.setPen(mSelectedDaysColor); |
876 | } | 876 | } |
877 | 877 | ||
878 | int addCol = 0; | 878 | int addCol = 0; |
879 | int addRow = 0; | 879 | int addRow = 0; |
880 | if ( colModulo ) { | 880 | if ( colModulo ) { |
881 | if ( col >= 7 - colModulo ) | 881 | if ( col >= 7 - colModulo ) |
882 | addCol = col - 7 + colModulo; | 882 | addCol = col - 7 + colModulo; |
883 | } | 883 | } |
884 | if ( rowModulo ) { | 884 | if ( rowModulo ) { |
885 | if ( row >= 6 - rowModulo ) | 885 | if ( row >= 6 - rowModulo ) |
886 | addRow = row - 5 + rowModulo; | 886 | addRow = row - 5 + rowModulo; |
887 | } | 887 | } |
888 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 888 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
889 | ++addCol;//++addCol; | 889 | ++addCol;//++addCol; |
890 | if ( row == 0) | 890 | if ( row == 0) |
891 | addRow = 1; | 891 | addRow = 1; |
892 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 892 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
893 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 893 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
894 | 894 | ||
895 | // reset color to actual color | 895 | // reset color to actual color |
896 | if (!mHolidays[i].isNull()) { | 896 | if (!mHolidays[i].isNull()) { |
897 | p.setPen(actcol); | 897 | p.setPen(actcol); |
898 | } | 898 | } |
899 | // reset bold font to plain font | 899 | // reset bold font to plain font |
900 | if (events[i] > 0) { | 900 | if (events[i] > 0) { |
901 | QFont myFont = font(); | 901 | QFont myFont = font(); |
902 | myFont.setBold(false); | 902 | myFont.setBold(false); |
903 | p.setFont(myFont); | 903 | p.setFont(myFont); |
904 | } | 904 | } |
905 | } | 905 | } |
906 | int off = xyOff; | 906 | int off = xyOff; |
907 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); | 907 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); |
908 | //qDebug("ffffffffff %d ", off); | 908 | //qDebug("ffffffffff %d ", off); |
909 | } | 909 | } |
910 | 910 | ||
911 | // ---------------------------------------------------------------------------- | 911 | // ---------------------------------------------------------------------------- |
912 | // R E SI Z E E V E N T H A N D L I N G | 912 | // R E SI Z E E V E N T H A N D L I N G |
913 | // ---------------------------------------------------------------------------- | 913 | // ---------------------------------------------------------------------------- |
914 | 914 | ||
915 | void KODayMatrix::resizeEvent(QResizeEvent *) | 915 | void KODayMatrix::resizeEvent(QResizeEvent *) |
916 | { | 916 | { |
917 | QRect sz = frameRect(); | 917 | QRect sz = frameRect(); |
918 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 918 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
919 | daysize.setWidth(sz.width() / 7); | 919 | daysize.setWidth(sz.width() / 7); |
920 | } | 920 | } |
921 | 921 | ||
922 | QSize KODayMatrix::sizeHint() const | 922 | QSize KODayMatrix::sizeHint() const |
923 | { | 923 | { |
924 | 924 | ||
925 | QFontMetrics fm ( font() ); | 925 | QFontMetrics fm ( font() ); |
926 | int wid = fm.width( "30") *7+3; | 926 | int wid = fm.width( "30") *7+3; |
927 | int hei = fm.height() * 6+3; | 927 | int hei = fm.height() * 6+3; |
928 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 928 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
929 | return QSize ( wid, hei ); | 929 | return QSize ( wid, hei ); |
930 | 930 | ||
931 | } | 931 | } |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 004ff50..76982b4 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1287 +1,1286 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | } | 86 | } |
87 | KNoScrollListBox::~KNoScrollListBox() | 87 | KNoScrollListBox::~KNoScrollListBox() |
88 | { | 88 | { |
89 | 89 | ||
90 | } | 90 | } |
91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
92 | { | 92 | { |
93 | QListBoxItem* item = itemAt ( p ); | 93 | QListBoxItem* item = itemAt ( p ); |
94 | if ( ! item ) { | 94 | if ( ! item ) { |
95 | return i18n("Click in the cell\nto add an event!"); | 95 | return i18n("Click in the cell\nto add an event!"); |
96 | } | 96 | } |
97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
98 | KOPrefs::instance()->mWTshowDetails, | 98 | KOPrefs::instance()->mWTshowDetails, |
99 | KOPrefs::instance()->mWTshowCreated, | 99 | KOPrefs::instance()->mWTshowCreated, |
100 | KOPrefs::instance()->mWTshowChanged); | 100 | KOPrefs::instance()->mWTshowChanged); |
101 | } | 101 | } |
102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
103 | { | 103 | { |
104 | 104 | ||
105 | switch(e->key()) { | 105 | switch(e->key()) { |
106 | case Key_Right: | 106 | case Key_Right: |
107 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 107 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
108 | { | 108 | { |
109 | e->ignore(); | 109 | e->ignore(); |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | scrollBy(10,0); | 112 | scrollBy(10,0); |
113 | break; | 113 | break; |
114 | case Key_Left: | 114 | case Key_Left: |
115 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 115 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
116 | { | 116 | { |
117 | e->ignore(); | 117 | e->ignore(); |
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | scrollBy(-10,0); | 120 | scrollBy(-10,0); |
121 | break; | 121 | break; |
122 | case Key_Up: | 122 | case Key_Up: |
123 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 123 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | setCurrentItem((currentItem()+count()-1)%count()); | 127 | setCurrentItem((currentItem()+count()-1)%count()); |
128 | if(!itemVisible(currentItem())) { | 128 | if(!itemVisible(currentItem())) { |
129 | if((unsigned int) currentItem() == (count()-1)) { | 129 | if((unsigned int) currentItem() == (count()-1)) { |
130 | setTopItem(currentItem()-numItemsVisible()+1); | 130 | setTopItem(currentItem()-numItemsVisible()+1); |
131 | } else { | 131 | } else { |
132 | setTopItem(topItem()-1); | 132 | setTopItem(topItem()-1); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | break; | 135 | break; |
136 | case Key_Down: | 136 | case Key_Down: |
137 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 137 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
138 | e->ignore(); | 138 | e->ignore(); |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | setCurrentItem((currentItem()+1)%count()); | 141 | setCurrentItem((currentItem()+1)%count()); |
142 | if(!itemVisible(currentItem())) { | 142 | if(!itemVisible(currentItem())) { |
143 | if(currentItem() == 0) { | 143 | if(currentItem() == 0) { |
144 | setTopItem(0); | 144 | setTopItem(0); |
145 | } else { | 145 | } else { |
146 | setTopItem(topItem()+1); | 146 | setTopItem(topItem()+1); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | break; | 149 | break; |
150 | case Key_I: | 150 | case Key_I: |
151 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 151 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); |
152 | e->ignore(); | 152 | e->ignore(); |
153 | break; | 153 | break; |
154 | case Key_Shift: | 154 | case Key_Shift: |
155 | emit shiftDown(); | 155 | emit shiftDown(); |
156 | break; | 156 | break; |
157 | default: | 157 | default: |
158 | e->ignore(); | 158 | e->ignore(); |
159 | break; | 159 | break; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | void KNoScrollListBox::oneDown() | 163 | void KNoScrollListBox::oneDown() |
164 | { | 164 | { |
165 | setCurrentItem((currentItem()+1)%count()); | 165 | setCurrentItem((currentItem()+1)%count()); |
166 | if(!itemVisible(currentItem())) { | 166 | if(!itemVisible(currentItem())) { |
167 | if(currentItem() == 0) { | 167 | if(currentItem() == 0) { |
168 | setTopItem(0); | 168 | setTopItem(0); |
169 | } else { | 169 | } else { |
170 | setTopItem(topItem()+1); | 170 | setTopItem(topItem()+1); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | } | 173 | } |
174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
175 | { | 175 | { |
176 | switch(e->key()) { | 176 | switch(e->key()) { |
177 | case Key_Shift: | 177 | case Key_Shift: |
178 | emit shiftUp(); | 178 | emit shiftUp(); |
179 | break; | 179 | break; |
180 | default: | 180 | default: |
181 | break; | 181 | break; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
186 | { | 186 | { |
187 | QListBox::mousePressEvent(e); | 187 | QListBox::mousePressEvent(e); |
188 | 188 | ||
189 | if(e->button() == RightButton) { | 189 | if(e->button() == RightButton) { |
190 | emit rightClick(); | 190 | emit rightClick(); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
195 | : QListBoxItem() | 195 | : QListBoxItem() |
196 | { | 196 | { |
197 | setText( s ); | 197 | setText( s ); |
198 | mMultiday = 0; | 198 | mMultiday = 0; |
199 | mIncidence = incidence; | 199 | mIncidence = incidence; |
200 | mDate = qd; | 200 | mDate = qd; |
201 | mRecur = false; | 201 | mRecur = false; |
202 | mAlarm = false; | 202 | mAlarm = false; |
203 | mReply = false; | 203 | mReply = false; |
204 | mInfo = false; | 204 | mInfo = false; |
205 | } | 205 | } |
206 | 206 | ||
207 | void MonthViewItem::paint(QPainter *p) | 207 | void MonthViewItem::paint(QPainter *p) |
208 | { | 208 | { |
209 | #if QT_VERSION >= 0x030000 | 209 | #if QT_VERSION >= 0x030000 |
210 | bool sel = isSelected(); | 210 | bool sel = isSelected(); |
211 | #else | 211 | #else |
212 | bool sel = selected(); | 212 | bool sel = selected(); |
213 | #endif | 213 | #endif |
214 | 214 | ||
215 | 215 | ||
216 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 216 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
217 | { | 217 | { |
218 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 218 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
219 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 219 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
220 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 220 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
221 | } | 221 | } |
222 | int x = 1; | 222 | int x = 1; |
223 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 223 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
224 | int size = PIXMAP_SIZE; | 224 | int size = PIXMAP_SIZE; |
225 | if ( QApplication::desktop()->width() < 300 ) | 225 | if ( QApplication::desktop()->width() < 300 ) |
226 | size = 3; | 226 | size = 3; |
227 | int heihei = height( listBox () ); | 227 | int heihei = height( listBox () ); |
228 | int y = (heihei - size -1 ) /2; | 228 | int y = (heihei - size -1 ) /2; |
229 | 229 | ||
230 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 230 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
231 | if ( mInfo ) { | 231 | if ( mInfo ) { |
232 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 232 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
233 | x += size + 1; | 233 | x += size + 1; |
234 | } | 234 | } |
235 | if ( mRecur ) { | 235 | if ( mRecur ) { |
236 | p->fillRect ( x, y,size,size, Qt::blue ); | 236 | p->fillRect ( x, y,size,size, Qt::blue ); |
237 | x += size + 1; | 237 | x += size + 1; |
238 | } | 238 | } |
239 | if ( mAlarm ) { | 239 | if ( mAlarm ) { |
240 | p->fillRect ( x, y,size,size, Qt::red ); | 240 | p->fillRect ( x, y,size,size, Qt::red ); |
241 | x += size + 1; | 241 | x += size + 1; |
242 | } | 242 | } |
243 | if ( mReply ) { | 243 | if ( mReply ) { |
244 | p->fillRect ( x, y,size,size, Qt::yellow ); | 244 | p->fillRect ( x, y,size,size, Qt::yellow ); |
245 | x += size + 1; | 245 | x += size + 1; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | if ( mMultiday ) { | 248 | if ( mMultiday ) { |
249 | int yyy = y+(size/2); | 249 | int yyy = y+(size/2); |
250 | int sizeM = size+2; | 250 | int sizeM = size+2; |
251 | p->setBrush( QBrush::SolidPattern ); | 251 | p->setBrush( QBrush::SolidPattern ); |
252 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 252 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
253 | if ( mMultiday == 2 || mMultiday == 3 ) { | 253 | if ( mMultiday == 2 || mMultiday == 3 ) { |
254 | QPointArray pa ( 3 ); | 254 | QPointArray pa ( 3 ); |
255 | pa.setPoint (0, x, yyy ); | 255 | pa.setPoint (0, x, yyy ); |
256 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 256 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
257 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 257 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
258 | p->drawPolygon( pa ); | 258 | p->drawPolygon( pa ); |
259 | } | 259 | } |
260 | if ( mMultiday == 2 || mMultiday == 1 ) { | 260 | if ( mMultiday == 2 || mMultiday == 1 ) { |
261 | QPointArray pa ( 3 ); | 261 | QPointArray pa ( 3 ); |
262 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 262 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
263 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 263 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
264 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 264 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
265 | p->drawPolygon( pa ); | 265 | p->drawPolygon( pa ); |
266 | } | 266 | } |
267 | if ( mMultiday == 1 ) { | 267 | if ( mMultiday == 1 ) { |
268 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 268 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
269 | 269 | ||
270 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 270 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
271 | } | 271 | } |
272 | if ( mMultiday == 3 ) { | 272 | if ( mMultiday == 3 ) { |
273 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 273 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
274 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 274 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
275 | 275 | ||
276 | } | 276 | } |
277 | x += sizeM/2 + 1; | 277 | x += sizeM/2 + 1; |
278 | x += sizeM + 1; | 278 | x += sizeM + 1; |
279 | } | 279 | } |
280 | 280 | ||
281 | if ( mIncidence->type() == "Todo" ){ | 281 | if ( mIncidence->type() == "Todo" ){ |
282 | Todo* td = ( Todo* ) mIncidence; | 282 | Todo* td = ( Todo* ) mIncidence; |
283 | if ( td->isCompleted() ) { | 283 | if ( td->isCompleted() ) { |
284 | int half = size/2; | 284 | int half = size/2; |
285 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 285 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
286 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 286 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
287 | x += half+half + 4; | 287 | x += half+half + 4; |
288 | 288 | ||
289 | } else { | 289 | } else { |
290 | int val = td->percentComplete()/20; | 290 | int val = td->percentComplete()/20; |
291 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); | 291 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); |
292 | p->drawRect ( x, y-1,7,size+2); | 292 | p->drawRect ( x, y-1,7,size+2); |
293 | x += size + 3; | 293 | x += size + 3; |
294 | } | 294 | } |
295 | } | 295 | } |
296 | QFontMetrics fm = p->fontMetrics(); | 296 | QFontMetrics fm = p->fontMetrics(); |
297 | int yPos; | 297 | int yPos; |
298 | int pmheight = size; | 298 | int pmheight = size; |
299 | if( pmheight < fm.height() ) | 299 | if( pmheight < fm.height() ) |
300 | yPos = fm.ascent() + fm.leading()/2; | 300 | yPos = fm.ascent() + fm.leading()/2; |
301 | else | 301 | else |
302 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 302 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
303 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 303 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
304 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 304 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
305 | p->drawText( x, yPos, text() ); | 305 | p->drawText( x, yPos, text() ); |
306 | if ( mIncidence->cancelled() ) { | 306 | if ( mIncidence->cancelled() ) { |
307 | int wid = fm.width( text() ); | 307 | int wid = fm.width( text() ); |
308 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 308 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
309 | } | 309 | } |
310 | 310 | ||
311 | } | 311 | } |
312 | 312 | ||
313 | int MonthViewItem::height(const QListBox *lb) const | 313 | int MonthViewItem::height(const QListBox *lb) const |
314 | { | 314 | { |
315 | if ( lb ) | 315 | if ( lb ) |
316 | return lb->fontMetrics().lineSpacing()+1; | 316 | return lb->fontMetrics().lineSpacing()+1; |
317 | return 10; | 317 | return 10; |
318 | } | 318 | } |
319 | 319 | ||
320 | int MonthViewItem::width(const QListBox *lb) const | 320 | int MonthViewItem::width(const QListBox *lb) const |
321 | { | 321 | { |
322 | int size = PIXMAP_SIZE; | 322 | int size = PIXMAP_SIZE; |
323 | if ( QApplication::desktop()->width() < 300 ) | 323 | if ( QApplication::desktop()->width() < 300 ) |
324 | size = 3; | 324 | size = 3; |
325 | int x = 1; | 325 | int x = 1; |
326 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 326 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
327 | if ( mInfo ) { | 327 | if ( mInfo ) { |
328 | x += size + 1; | 328 | x += size + 1; |
329 | } | 329 | } |
330 | if( mRecur ) { | 330 | if( mRecur ) { |
331 | x += size+1; | 331 | x += size+1; |
332 | } | 332 | } |
333 | if( mAlarm ) { | 333 | if( mAlarm ) { |
334 | x += size+1; | 334 | x += size+1; |
335 | } | 335 | } |
336 | if( mReply ) { | 336 | if( mReply ) { |
337 | x += size+1; | 337 | x += size+1; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | if( mMultiday ) { | 340 | if( mMultiday ) { |
341 | x += size+1+2+size/2; | 341 | x += size+1+2+size/2; |
342 | } | 342 | } |
343 | 343 | ||
344 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 344 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 348 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
349 | : QWidget( par ), | 349 | : QWidget( par ), |
350 | mMonthView( parent ) | 350 | mMonthView( parent ) |
351 | { | 351 | { |
352 | 352 | ||
353 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 353 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
354 | 354 | ||
355 | // mLabel = new QLabel( this );QPushButton | 355 | // mLabel = new QLabel( this );QPushButton |
356 | mLabel = new QPushButton( this ); | 356 | mLabel = new QPushButton( this ); |
357 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 357 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
358 | //mLabel->setLineWidth( 1 ); | 358 | //mLabel->setLineWidth( 1 ); |
359 | //mLabel->setAlignment( AlignCenter ); | 359 | //mLabel->setAlignment( AlignCenter ); |
360 | mLabel->setFlat( true ); | 360 | mLabel->setFlat( true ); |
361 | mLabel->setFocusPolicy(NoFocus); | 361 | mLabel->setFocusPolicy(NoFocus); |
362 | mItemList = new KNoScrollListBox( this ); | 362 | mItemList = new KNoScrollListBox( this ); |
363 | mItemList->setMinimumSize( 10, 10 ); | 363 | mItemList->setMinimumSize( 10, 10 ); |
364 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 364 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
365 | mItemList->setLineWidth( 1 ); | 365 | mItemList->setLineWidth( 1 ); |
366 | topLayout->addWidget( mItemList ); | 366 | topLayout->addWidget( mItemList ); |
367 | mLabel->raise(); | 367 | mLabel->raise(); |
368 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 368 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
369 | mStandardPalette = palette(); | 369 | mStandardPalette = palette(); |
370 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 370 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
371 | 371 | ||
372 | enableScrollBars( false ); | 372 | enableScrollBars( false ); |
373 | updateConfig(); | 373 | updateConfig(); |
374 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 374 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
375 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 375 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
376 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 376 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
377 | SLOT( defaultAction( QListBoxItem * ) ) ); | 377 | SLOT( defaultAction( QListBoxItem * ) ) ); |
378 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 378 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
379 | const QPoint &) ), | 379 | const QPoint &) ), |
380 | SLOT( contextMenu( QListBoxItem * ) ) ); | 380 | SLOT( contextMenu( QListBoxItem * ) ) ); |
381 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 381 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
382 | SLOT( selection( QListBoxItem * ) ) ); | 382 | SLOT( selection( QListBoxItem * ) ) ); |
383 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 383 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
384 | SLOT( cellClicked( QListBoxItem * ) ) ); | 384 | SLOT( cellClicked( QListBoxItem * ) ) ); |
385 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 385 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
386 | SLOT( selection( QListBoxItem * ) ) ); | 386 | SLOT( selection( QListBoxItem * ) ) ); |
387 | } | 387 | } |
388 | #ifdef DESKTOP_VERSION | 388 | #ifdef DESKTOP_VERSION |
389 | QToolTipGroup *MonthViewCell::toolTipGroup() | 389 | QToolTipGroup *MonthViewCell::toolTipGroup() |
390 | { | 390 | { |
391 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 391 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
392 | return mToolTipGroup; | 392 | return mToolTipGroup; |
393 | } | 393 | } |
394 | #endif | 394 | #endif |
395 | 395 | ||
396 | void MonthViewCell::setDate( const QDate &date ) | 396 | void MonthViewCell::setDate( const QDate &date ) |
397 | { | 397 | { |
398 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 398 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
399 | mDate = date; | 399 | mDate = date; |
400 | 400 | ||
401 | 401 | ||
402 | 402 | ||
403 | //resizeEvent( 0 ); | 403 | //resizeEvent( 0 ); |
404 | } | 404 | } |
405 | 405 | ||
406 | QDate MonthViewCell::date() const | 406 | QDate MonthViewCell::date() const |
407 | { | 407 | { |
408 | return mDate; | 408 | return mDate; |
409 | } | 409 | } |
410 | 410 | ||
411 | void MonthViewCell::setPrimary( bool primary ) | 411 | void MonthViewCell::setPrimary( bool primary ) |
412 | { | 412 | { |
413 | mPrimary = primary; | 413 | mPrimary = primary; |
414 | //setMyPalette(); | 414 | //setMyPalette(); |
415 | } | 415 | } |
416 | void MonthViewCell::setMyPalette() | 416 | void MonthViewCell::setMyPalette() |
417 | { | 417 | { |
418 | 418 | ||
419 | if ( mHoliday) { | 419 | if ( mHoliday) { |
420 | setPalette( mHolidayPalette ); | 420 | setPalette( mHolidayPalette ); |
421 | } else { | 421 | } else { |
422 | if ( mPrimary ) { | 422 | if ( mPrimary ) { |
423 | setPalette( mPrimaryPalette ); | 423 | setPalette( mPrimaryPalette ); |
424 | } else { | 424 | } else { |
425 | setPalette( mNonPrimaryPalette ); | 425 | setPalette( mNonPrimaryPalette ); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | QPalette pal = palette(); | 428 | QPalette pal = palette(); |
429 | 429 | ||
430 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 430 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
431 | } | 431 | } |
432 | QPalette MonthViewCell::getPalette () | 432 | QPalette MonthViewCell::getPalette () |
433 | { | 433 | { |
434 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 434 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
435 | return mStandardPalette; | 435 | return mStandardPalette; |
436 | if ( mHoliday) { | 436 | if ( mHoliday) { |
437 | return mHolidayPalette ; | 437 | return mHolidayPalette ; |
438 | } else { | 438 | } else { |
439 | if ( mPrimary ) { | 439 | if ( mPrimary ) { |
440 | return mPrimaryPalette ; | 440 | return mPrimaryPalette ; |
441 | } | 441 | } |
442 | } | 442 | } |
443 | return mNonPrimaryPalette; | 443 | return mNonPrimaryPalette; |
444 | } | 444 | } |
445 | bool MonthViewCell::isPrimary() const | 445 | bool MonthViewCell::isPrimary() const |
446 | { | 446 | { |
447 | return mPrimary; | 447 | return mPrimary; |
448 | } | 448 | } |
449 | 449 | ||
450 | void MonthViewCell::setHoliday( bool holiday ) | 450 | void MonthViewCell::setHoliday( bool holiday ) |
451 | { | 451 | { |
452 | mHoliday = holiday; | 452 | mHoliday = holiday; |
453 | //setMyPalette(); | 453 | //setMyPalette(); |
454 | } | 454 | } |
455 | 455 | ||
456 | void MonthViewCell::setHoliday( const QString &holiday ) | 456 | void MonthViewCell::setHoliday( const QString &holiday ) |
457 | { | 457 | { |
458 | mHolidayString = holiday; | 458 | mHolidayString = holiday; |
459 | 459 | ||
460 | if ( !holiday.isEmpty() ) { | 460 | if ( !holiday.isEmpty() ) { |
461 | setHoliday( true ); | 461 | setHoliday( true ); |
462 | } | 462 | } |
463 | } | 463 | } |
464 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 464 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
465 | { | 465 | { |
466 | 466 | ||
467 | e->ignore(); | 467 | e->ignore(); |
468 | 468 | ||
469 | } | 469 | } |
470 | 470 | ||
471 | void MonthViewCell::startUpdateCell() | 471 | void MonthViewCell::startUpdateCell() |
472 | { | 472 | { |
473 | 473 | ||
474 | mItemList->setFocusPolicy(NoFocus); | 474 | mItemList->setFocusPolicy(NoFocus); |
475 | if ( !mMonthView->isUpdatePossible() ) | 475 | if ( !mMonthView->isUpdatePossible() ) |
476 | return; | 476 | return; |
477 | 477 | ||
478 | /* | 478 | /* |
479 | if ( !isVisible() ){ | 479 | if ( !isVisible() ){ |
480 | return; | 480 | return; |
481 | } | 481 | } |
482 | */ | 482 | */ |
483 | // qDebug("MonthViewCell::updateCell() "); | 483 | // qDebug("MonthViewCell::updateCell() "); |
484 | setPrimary( mDate.month()%2 ); | 484 | setPrimary( mDate.month()%2 ); |
485 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 485 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
486 | if ( mDate == QDate::currentDate() ) { | 486 | if ( mDate == QDate::currentDate() ) { |
487 | mItemList->setLineWidth( 3 ); | 487 | mItemList->setLineWidth( 3 ); |
488 | } else { | 488 | } else { |
489 | mItemList->setLineWidth( 1 ); | 489 | mItemList->setLineWidth( 1 ); |
490 | } | 490 | } |
491 | mItemList->clear(); | 491 | mItemList->clear(); |
492 | 492 | ||
493 | #ifdef DESKTOP_VERSION | 493 | #ifdef DESKTOP_VERSION |
494 | QToolTip::remove(this); | 494 | QToolTip::remove(this); |
495 | #endif | 495 | #endif |
496 | mToolTip.clear(); | 496 | mToolTip.clear(); |
497 | //qApp->processEvents(); | 497 | //qApp->processEvents(); |
498 | if ( !mHolidayString.isEmpty() ) { | 498 | if ( !mHolidayString.isEmpty() ) { |
499 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 499 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
500 | item->setPalette( mHolidayPalette ); | 500 | item->setPalette( mHolidayPalette ); |
501 | mItemList->insertItem( item ); | 501 | mItemList->insertItem( item ); |
502 | mToolTip.append ( mHolidayString ); | 502 | mToolTip.append ( mHolidayString ); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | void MonthViewCell::insertEvent(Event *event) | 506 | void MonthViewCell::insertEvent(Event *event) |
507 | { | 507 | { |
508 | QString mToolTipText; | 508 | QString mToolTipText; |
509 | mItemList->setFocusPolicy(WheelFocus); | 509 | mItemList->setFocusPolicy(WheelFocus); |
510 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 510 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
511 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 511 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
512 | return; | 512 | return; |
513 | else | 513 | else |
514 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 514 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
515 | return; | 515 | return; |
516 | } | 516 | } |
517 | 517 | ||
518 | if ( event->categories().contains("Holiday") || | 518 | if ( event->isHoliday()) { |
519 | event->categories().contains(i18n("Holiday"))) { | ||
520 | setHoliday( true ); | 519 | setHoliday( true ); |
521 | if ( mDate.dayOfWeek() == 7 ) | 520 | if ( mDate.dayOfWeek() == 7 ) |
522 | mItemList->setLineWidth( 3 ); | 521 | mItemList->setLineWidth( 3 ); |
523 | } | 522 | } |
524 | QString text; | 523 | QString text; |
525 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 524 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
526 | if (event->isMultiDay()) { | 525 | if (event->isMultiDay()) { |
527 | QString prefix = "<->";multiday = 2; | 526 | QString prefix = "<->";multiday = 2; |
528 | QString time; | 527 | QString time; |
529 | if ( event->doesRecur() ) { | 528 | if ( event->doesRecur() ) { |
530 | if ( event->recursOn( mDate) ) { | 529 | if ( event->recursOn( mDate) ) { |
531 | prefix ="->" ;multiday = 1; | 530 | prefix ="->" ;multiday = 1; |
532 | } | 531 | } |
533 | else { | 532 | else { |
534 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 533 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
535 | if ( event->recursOn( mDate.addDays( -days)) ) { | 534 | if ( event->recursOn( mDate.addDays( -days)) ) { |
536 | prefix ="<-" ;multiday = 3; | 535 | prefix ="<-" ;multiday = 3; |
537 | } | 536 | } |
538 | } | 537 | } |
539 | 538 | ||
540 | } else { | 539 | } else { |
541 | if (mDate == event->dtStart().date()) { | 540 | if (mDate == event->dtStart().date()) { |
542 | prefix ="->" ;multiday = 1; | 541 | prefix ="->" ;multiday = 1; |
543 | } else if (mDate == event->dtEnd().date()) { | 542 | } else if (mDate == event->dtEnd().date()) { |
544 | prefix ="<-" ;multiday = 3; | 543 | prefix ="<-" ;multiday = 3; |
545 | } | 544 | } |
546 | } | 545 | } |
547 | if ( !event->doesFloat() ) { | 546 | if ( !event->doesFloat() ) { |
548 | if ( mDate == event->dtStart().date () ) | 547 | if ( mDate == event->dtStart().date () ) |
549 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 548 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
550 | else if ( mDate == event->dtEnd().date () ) | 549 | else if ( mDate == event->dtEnd().date () ) |
551 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 550 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
552 | 551 | ||
553 | } | 552 | } |
554 | text = time + event->summary(); | 553 | text = time + event->summary(); |
555 | mToolTipText += prefix + text; | 554 | mToolTipText += prefix + text; |
556 | } else { | 555 | } else { |
557 | if (event->doesFloat()) { | 556 | if (event->doesFloat()) { |
558 | text = event->summary(); | 557 | text = event->summary(); |
559 | mToolTipText += text; | 558 | mToolTipText += text; |
560 | } | 559 | } |
561 | else { | 560 | else { |
562 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 561 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
563 | text += " " + event->summary(); | 562 | text += " " + event->summary(); |
564 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 563 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
565 | } | 564 | } |
566 | } | 565 | } |
567 | 566 | ||
568 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 567 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
569 | QPalette pal; | 568 | QPalette pal; |
570 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 569 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
571 | QStringList categories = event->categories(); | 570 | QStringList categories = event->categories(); |
572 | QString cat = categories.first(); | 571 | QString cat = categories.first(); |
573 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 572 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
574 | pal = getPalette(); | 573 | pal = getPalette(); |
575 | if (cat.isEmpty()) { | 574 | if (cat.isEmpty()) { |
576 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 575 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
577 | } else { | 576 | } else { |
578 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 577 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
579 | } | 578 | } |
580 | 579 | ||
581 | } else { | 580 | } else { |
582 | if (cat.isEmpty()) { | 581 | if (cat.isEmpty()) { |
583 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 582 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
584 | } else { | 583 | } else { |
585 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 584 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
586 | } | 585 | } |
587 | } | 586 | } |
588 | 587 | ||
589 | } else { | 588 | } else { |
590 | pal = mStandardPalette ; | 589 | pal = mStandardPalette ; |
591 | } | 590 | } |
592 | item->setPalette( pal ); | 591 | item->setPalette( pal ); |
593 | item->setRecur( event->recurrence()->doesRecur() ); | 592 | item->setRecur( event->recurrence()->doesRecur() ); |
594 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 593 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
595 | item->setMoreInfo( event->description().length() > 0 ); | 594 | item->setMoreInfo( event->description().length() > 0 ); |
596 | #ifdef DESKTOP_VERSION | 595 | #ifdef DESKTOP_VERSION |
597 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 596 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
598 | KOPrefs::instance()->email()); | 597 | KOPrefs::instance()->email()); |
599 | if ( me != 0 ) { | 598 | if ( me != 0 ) { |
600 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 599 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
601 | item->setReply(true && multiday < 2); | 600 | item->setReply(true && multiday < 2); |
602 | else | 601 | else |
603 | item->setReply(false); | 602 | item->setReply(false); |
604 | } else | 603 | } else |
605 | item->setReply(false); | 604 | item->setReply(false); |
606 | #endif | 605 | #endif |
607 | item->setMultiDay( multiday ); | 606 | item->setMultiDay( multiday ); |
608 | mItemList->insertItem( item ); | 607 | mItemList->insertItem( item ); |
609 | mToolTip.append( mToolTipText ); | 608 | mToolTip.append( mToolTipText ); |
610 | } | 609 | } |
611 | void MonthViewCell::insertTodo(Todo *todo) | 610 | void MonthViewCell::insertTodo(Todo *todo) |
612 | { | 611 | { |
613 | mItemList->setFocusPolicy(WheelFocus); | 612 | mItemList->setFocusPolicy(WheelFocus); |
614 | QString text; | 613 | QString text; |
615 | if (todo->hasDueDate()) { | 614 | if (todo->hasDueDate()) { |
616 | if (!todo->doesFloat()) { | 615 | if (!todo->doesFloat()) { |
617 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 616 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
618 | text += " "; | 617 | text += " "; |
619 | } | 618 | } |
620 | } | 619 | } |
621 | text += todo->summary(); | 620 | text += todo->summary(); |
622 | 621 | ||
623 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 622 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
624 | //item->setPalette( mStandardPalette ); | 623 | //item->setPalette( mStandardPalette ); |
625 | QPalette pal; | 624 | QPalette pal; |
626 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 625 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
627 | QStringList categories = todo->categories(); | 626 | QStringList categories = todo->categories(); |
628 | QString cat = categories.first(); | 627 | QString cat = categories.first(); |
629 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 628 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
630 | pal = getPalette(); | 629 | pal = getPalette(); |
631 | if (cat.isEmpty()) { | 630 | if (cat.isEmpty()) { |
632 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 631 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
633 | } else { | 632 | } else { |
634 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 633 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
635 | } | 634 | } |
636 | 635 | ||
637 | } else { | 636 | } else { |
638 | if (cat.isEmpty()) { | 637 | if (cat.isEmpty()) { |
639 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 638 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
640 | } else { | 639 | } else { |
641 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 640 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
642 | } | 641 | } |
643 | } | 642 | } |
644 | 643 | ||
645 | } else { | 644 | } else { |
646 | pal = mStandardPalette ; | 645 | pal = mStandardPalette ; |
647 | } | 646 | } |
648 | item->setPalette( pal ); | 647 | item->setPalette( pal ); |
649 | item->setRecur( todo->recurrence()->doesRecur() ); | 648 | item->setRecur( todo->recurrence()->doesRecur() ); |
650 | item->setAlarm( todo->isAlarmEnabled() ); | 649 | item->setAlarm( todo->isAlarmEnabled() ); |
651 | item->setMoreInfo( todo->description().length() > 0 ); | 650 | item->setMoreInfo( todo->description().length() > 0 ); |
652 | mItemList->insertItem( item ); | 651 | mItemList->insertItem( item ); |
653 | mToolTip.append( text ); | 652 | mToolTip.append( text ); |
654 | } | 653 | } |
655 | void MonthViewCell::finishUpdateCell() | 654 | void MonthViewCell::finishUpdateCell() |
656 | { | 655 | { |
657 | #ifdef DESKTOP_VERSION | 656 | #ifdef DESKTOP_VERSION |
658 | if (mToolTip.count() > 0 ) { | 657 | if (mToolTip.count() > 0 ) { |
659 | mToolTip.sort(); | 658 | mToolTip.sort(); |
660 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 659 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
661 | } | 660 | } |
662 | #endif | 661 | #endif |
663 | mItemList->sort(); | 662 | mItemList->sort(); |
664 | //setMyPalette(); | 663 | //setMyPalette(); |
665 | setMyPalette(); | 664 | setMyPalette(); |
666 | QString text; | 665 | QString text; |
667 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 666 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
668 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 667 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
669 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 668 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
670 | mLabel->resize( mLabelBigSize ); | 669 | mLabel->resize( mLabelBigSize ); |
671 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 670 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
672 | } else { | 671 | } else { |
673 | mLabel->resize( mLabelSize ); | 672 | mLabel->resize( mLabelSize ); |
674 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 673 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
675 | } | 674 | } |
676 | 675 | ||
677 | mLabel->setText( text ); | 676 | mLabel->setText( text ); |
678 | resizeEvent( 0 ); | 677 | resizeEvent( 0 ); |
679 | } | 678 | } |
680 | void MonthViewCell::updateCell() | 679 | void MonthViewCell::updateCell() |
681 | { | 680 | { |
682 | //qDebug("MonthViewCell::updateCell() "); | 681 | //qDebug("MonthViewCell::updateCell() "); |
683 | if ( !mMonthView->isUpdatePossible() ) | 682 | if ( !mMonthView->isUpdatePossible() ) |
684 | return; | 683 | return; |
685 | startUpdateCell(); | 684 | startUpdateCell(); |
686 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 685 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
687 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 686 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
688 | Event *event; | 687 | Event *event; |
689 | for( event = events.first(); event; event = events.next() ) { // for event | 688 | for( event = events.first(); event; event = events.next() ) { // for event |
690 | insertEvent(event); | 689 | insertEvent(event); |
691 | } | 690 | } |
692 | // insert due todos | 691 | // insert due todos |
693 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 692 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
694 | Todo *todo; | 693 | Todo *todo; |
695 | for(todo = todos.first(); todo; todo = todos.next()) { | 694 | for(todo = todos.first(); todo; todo = todos.next()) { |
696 | insertTodo( todo ); | 695 | insertTodo( todo ); |
697 | } | 696 | } |
698 | finishUpdateCell(); | 697 | finishUpdateCell(); |
699 | // if ( isVisible()) | 698 | // if ( isVisible()) |
700 | //qApp->processEvents(); | 699 | //qApp->processEvents(); |
701 | } | 700 | } |
702 | 701 | ||
703 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 702 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
704 | { | 703 | { |
705 | 704 | ||
706 | if ( bigFont ) { | 705 | if ( bigFont ) { |
707 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 706 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
708 | int ps = fo.pointSize() + 2; | 707 | int ps = fo.pointSize() + 2; |
709 | if ( ps < 18 ) | 708 | if ( ps < 18 ) |
710 | ps += 2; | 709 | ps += 2; |
711 | fo.setPointSize( ps ); | 710 | fo.setPointSize( ps ); |
712 | setFont( fo ); | 711 | setFont( fo ); |
713 | } else | 712 | } else |
714 | setFont( KOPrefs::instance()->mMonthViewFont ); | 713 | setFont( KOPrefs::instance()->mMonthViewFont ); |
715 | 714 | ||
716 | QFontMetrics fm( font() ); | 715 | QFontMetrics fm( font() ); |
717 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 716 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
718 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 717 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
719 | mHolidayPalette = mStandardPalette; | 718 | mHolidayPalette = mStandardPalette; |
720 | mPrimaryPalette = mStandardPalette; | 719 | mPrimaryPalette = mStandardPalette; |
721 | mNonPrimaryPalette = mStandardPalette; | 720 | mNonPrimaryPalette = mStandardPalette; |
722 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 721 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
723 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 722 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
724 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 723 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
725 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 724 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
726 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 725 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
727 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 726 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
728 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 727 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
729 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 728 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
730 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 729 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
731 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 730 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
732 | } | 731 | } |
733 | //updateCell(); | 732 | //updateCell(); |
734 | } | 733 | } |
735 | 734 | ||
736 | void MonthViewCell::enableScrollBars( bool enabled ) | 735 | void MonthViewCell::enableScrollBars( bool enabled ) |
737 | { | 736 | { |
738 | if ( enabled ) { | 737 | if ( enabled ) { |
739 | mItemList->setVScrollBarMode(QScrollView::Auto); | 738 | mItemList->setVScrollBarMode(QScrollView::Auto); |
740 | mItemList->setHScrollBarMode(QScrollView::Auto); | 739 | mItemList->setHScrollBarMode(QScrollView::Auto); |
741 | } else { | 740 | } else { |
742 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 741 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
743 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 742 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
744 | } | 743 | } |
745 | } | 744 | } |
746 | 745 | ||
747 | Incidence *MonthViewCell::selectedIncidence() | 746 | Incidence *MonthViewCell::selectedIncidence() |
748 | { | 747 | { |
749 | int index = mItemList->currentItem(); | 748 | int index = mItemList->currentItem(); |
750 | if ( index < 0 ) return 0; | 749 | if ( index < 0 ) return 0; |
751 | 750 | ||
752 | MonthViewItem *item = | 751 | MonthViewItem *item = |
753 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 752 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
754 | 753 | ||
755 | if ( !item ) return 0; | 754 | if ( !item ) return 0; |
756 | 755 | ||
757 | return item->incidence(); | 756 | return item->incidence(); |
758 | } | 757 | } |
759 | 758 | ||
760 | QDate MonthViewCell::selectedIncidenceDate() | 759 | QDate MonthViewCell::selectedIncidenceDate() |
761 | { | 760 | { |
762 | QDate qd; | 761 | QDate qd; |
763 | int index = mItemList->currentItem(); | 762 | int index = mItemList->currentItem(); |
764 | if ( index < 0 ) return qd; | 763 | if ( index < 0 ) return qd; |
765 | 764 | ||
766 | MonthViewItem *item = | 765 | MonthViewItem *item = |
767 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 766 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
768 | 767 | ||
769 | if ( !item ) return qd; | 768 | if ( !item ) return qd; |
770 | 769 | ||
771 | return item->incidenceDate(); | 770 | return item->incidenceDate(); |
772 | } | 771 | } |
773 | 772 | ||
774 | void MonthViewCell::deselect() | 773 | void MonthViewCell::deselect() |
775 | { | 774 | { |
776 | mItemList->clearSelection(); | 775 | mItemList->clearSelection(); |
777 | enableScrollBars( false ); | 776 | enableScrollBars( false ); |
778 | // updateCell(); | 777 | // updateCell(); |
779 | } | 778 | } |
780 | void MonthViewCell::select() | 779 | void MonthViewCell::select() |
781 | { | 780 | { |
782 | ;// updateCell(); | 781 | ;// updateCell(); |
783 | } | 782 | } |
784 | 783 | ||
785 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 784 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
786 | { | 785 | { |
787 | if ( !mMonthView->isUpdatePossible() ) | 786 | if ( !mMonthView->isUpdatePossible() ) |
788 | return; | 787 | return; |
789 | 788 | ||
790 | int size = height() - mLabel->height() - 2; | 789 | int size = height() - mLabel->height() - 2; |
791 | if ( size > 0 ) | 790 | if ( size > 0 ) |
792 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 791 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
793 | size = width() - mLabel->width() -2; | 792 | size = width() - mLabel->width() -2; |
794 | if ( size > 0 ) | 793 | if ( size > 0 ) |
795 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 794 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
796 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 795 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
797 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 796 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
798 | } | 797 | } |
799 | 798 | ||
800 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 799 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
801 | { | 800 | { |
802 | if ( !item ) return; | 801 | if ( !item ) return; |
803 | 802 | ||
804 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 803 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
805 | Incidence *incidence = eventItem->incidence(); | 804 | Incidence *incidence = eventItem->incidence(); |
806 | if ( incidence ) mMonthView->defaultAction( incidence ); | 805 | if ( incidence ) mMonthView->defaultAction( incidence ); |
807 | } | 806 | } |
808 | void MonthViewCell::showDay() | 807 | void MonthViewCell::showDay() |
809 | { | 808 | { |
810 | emit showDaySignal( date() ); | 809 | emit showDaySignal( date() ); |
811 | } | 810 | } |
812 | void MonthViewCell::newEvent() | 811 | void MonthViewCell::newEvent() |
813 | { | 812 | { |
814 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 813 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
815 | emit newEventSignal( dt ); | 814 | emit newEventSignal( dt ); |
816 | } | 815 | } |
817 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 816 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
818 | { | 817 | { |
819 | static QListBoxItem * lastClicked = 0; | 818 | static QListBoxItem * lastClicked = 0; |
820 | if ( item == 0 ) { | 819 | if ( item == 0 ) { |
821 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 820 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
822 | emit newEventSignal( dt ); | 821 | emit newEventSignal( dt ); |
823 | return; | 822 | return; |
824 | } | 823 | } |
825 | /* | 824 | /* |
826 | if ( lastClicked ) | 825 | if ( lastClicked ) |
827 | if ( ! item ) { | 826 | if ( ! item ) { |
828 | if ( lastClicked->listBox() != item->listBox() ) | 827 | if ( lastClicked->listBox() != item->listBox() ) |
829 | lastClicked->listBox()->clearSelection(); | 828 | lastClicked->listBox()->clearSelection(); |
830 | } | 829 | } |
831 | */ | 830 | */ |
832 | 831 | ||
833 | mMonthView->setSelectedCell( this ); | 832 | mMonthView->setSelectedCell( this ); |
834 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 833 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
835 | select(); | 834 | select(); |
836 | } | 835 | } |
837 | 836 | ||
838 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 837 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
839 | { | 838 | { |
840 | if ( !item ) return; | 839 | if ( !item ) return; |
841 | 840 | ||
842 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 841 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
843 | Incidence *incidence = eventItem->incidence(); | 842 | Incidence *incidence = eventItem->incidence(); |
844 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 843 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
845 | } | 844 | } |
846 | 845 | ||
847 | void MonthViewCell::selection( QListBoxItem *item ) | 846 | void MonthViewCell::selection( QListBoxItem *item ) |
848 | { | 847 | { |
849 | if ( !item ) return; | 848 | if ( !item ) return; |
850 | 849 | ||
851 | mMonthView->setSelectedCell( this ); | 850 | mMonthView->setSelectedCell( this ); |
852 | } | 851 | } |
853 | 852 | ||
854 | 853 | ||
855 | // ******************************************************************************* | 854 | // ******************************************************************************* |
856 | // ******************************************************************************* | 855 | // ******************************************************************************* |
857 | // ******************************************************************************* | 856 | // ******************************************************************************* |
858 | 857 | ||
859 | 858 | ||
860 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 859 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
861 | : KOEventView( calendar, parent, name ), | 860 | : KOEventView( calendar, parent, name ), |
862 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 861 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
863 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 862 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
864 | { | 863 | { |
865 | mShortDayLabelsM = false; | 864 | mShortDayLabelsM = false; |
866 | mShortDayLabelsW = false; | 865 | mShortDayLabelsW = false; |
867 | skipResize = false; | 866 | skipResize = false; |
868 | clPending = true; | 867 | clPending = true; |
869 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 868 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
870 | mWidStack = new QWidgetStack( this ); | 869 | mWidStack = new QWidgetStack( this ); |
871 | QVBoxLayout* hb = new QVBoxLayout( this ); | 870 | QVBoxLayout* hb = new QVBoxLayout( this ); |
872 | mMonthView = new QWidget( mWidStack ); | 871 | mMonthView = new QWidget( mWidStack ); |
873 | mWeekView = new QWidget( mWidStack ); | 872 | mWeekView = new QWidget( mWidStack ); |
874 | #if QT_VERSION >= 0x030000 | 873 | #if QT_VERSION >= 0x030000 |
875 | mWidStack->addWidget(mMonthView ); | 874 | mWidStack->addWidget(mMonthView ); |
876 | mWidStack->addWidget(mWeekView ); | 875 | mWidStack->addWidget(mWeekView ); |
877 | #else | 876 | #else |
878 | mWidStack->addWidget( mMonthView, 1 ); | 877 | mWidStack->addWidget( mMonthView, 1 ); |
879 | mWidStack->addWidget( mWeekView , 1 ); | 878 | mWidStack->addWidget( mWeekView , 1 ); |
880 | #endif | 879 | #endif |
881 | hb->addWidget( mNavigatorBar ); | 880 | hb->addWidget( mNavigatorBar ); |
882 | hb->addWidget( mWidStack ); | 881 | hb->addWidget( mWidStack ); |
883 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 882 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
884 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 883 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
885 | if ( mShowWeekView ) | 884 | if ( mShowWeekView ) |
886 | mWeekStartsMonday = true; | 885 | mWeekStartsMonday = true; |
887 | updatePossible = false; | 886 | updatePossible = false; |
888 | //updatePossible = true; | 887 | //updatePossible = true; |
889 | mCells.setAutoDelete( true ); | 888 | mCells.setAutoDelete( true ); |
890 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 889 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
891 | mDayLabels.resize( mDaysPerWeek ); | 890 | mDayLabels.resize( mDaysPerWeek ); |
892 | mDayLabelsW.resize( mDaysPerWeek ); | 891 | mDayLabelsW.resize( mDaysPerWeek ); |
893 | QFont bfont = font(); | 892 | QFont bfont = font(); |
894 | if ( QApplication::desktop()->width() < 650 ) { | 893 | if ( QApplication::desktop()->width() < 650 ) { |
895 | bfont.setPointSize( bfont.pointSize() - 2 ); | 894 | bfont.setPointSize( bfont.pointSize() - 2 ); |
896 | } | 895 | } |
897 | bfont.setBold( true ); | 896 | bfont.setBold( true ); |
898 | int i; | 897 | int i; |
899 | 898 | ||
900 | for( i = 0; i < mDaysPerWeek; i++ ) { | 899 | for( i = 0; i < mDaysPerWeek; i++ ) { |
901 | QLabel *label = new QLabel( mMonthView ); | 900 | QLabel *label = new QLabel( mMonthView ); |
902 | label->setFont(bfont); | 901 | label->setFont(bfont); |
903 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 902 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
904 | label->setLineWidth(1); | 903 | label->setLineWidth(1); |
905 | label->setAlignment(AlignCenter); | 904 | label->setAlignment(AlignCenter); |
906 | mDayLabels.insert( i, label ); | 905 | mDayLabels.insert( i, label ); |
907 | label = new QLabel( mWeekView ); | 906 | label = new QLabel( mWeekView ); |
908 | label->setFont(bfont); | 907 | label->setFont(bfont); |
909 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 908 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
910 | label->setLineWidth(1); | 909 | label->setLineWidth(1); |
911 | label->setAlignment(AlignCenter); | 910 | label->setAlignment(AlignCenter); |
912 | mDayLabelsW.insert( i, label ); | 911 | mDayLabelsW.insert( i, label ); |
913 | } | 912 | } |
914 | 913 | ||
915 | bfont.setBold( false ); | 914 | bfont.setBold( false ); |
916 | mWeekLabels.resize( mNumWeeks+1 ); | 915 | mWeekLabels.resize( mNumWeeks+1 ); |
917 | mWeekLabelsW.resize( 2 ); | 916 | mWeekLabelsW.resize( 2 ); |
918 | for( i = 0; i < mNumWeeks+1; i++ ) { | 917 | for( i = 0; i < mNumWeeks+1; i++ ) { |
919 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 918 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
920 | label->setFocusPolicy(NoFocus); | 919 | label->setFocusPolicy(NoFocus); |
921 | label->setFont(bfont); | 920 | label->setFont(bfont); |
922 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 921 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
923 | label->setFlat(true); | 922 | label->setFlat(true); |
924 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 923 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
925 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 924 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
926 | //label->setLineWidth(1); | 925 | //label->setLineWidth(1); |
927 | //label->setAlignment(AlignCenter); | 926 | //label->setAlignment(AlignCenter); |
928 | mWeekLabels.insert( i, label ); | 927 | mWeekLabels.insert( i, label ); |
929 | } | 928 | } |
930 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 929 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
931 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 930 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
932 | 931 | ||
933 | for( i = 0; i < 1+1; i++ ) { | 932 | for( i = 0; i < 1+1; i++ ) { |
934 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 933 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
935 | label->setFocusPolicy(NoFocus); | 934 | label->setFocusPolicy(NoFocus); |
936 | label->setFont(bfont); | 935 | label->setFont(bfont); |
937 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 936 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
938 | label->setFlat(true); | 937 | label->setFlat(true); |
939 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 938 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
940 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 939 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
941 | //label->setLineWidth(1); | 940 | //label->setLineWidth(1); |
942 | //label->setAlignment(AlignCenter); | 941 | //label->setAlignment(AlignCenter); |
943 | mWeekLabelsW.insert( i, label ); | 942 | mWeekLabelsW.insert( i, label ); |
944 | } | 943 | } |
945 | mWeekLabelsW[1]->setText( i18n("W")); | 944 | mWeekLabelsW[1]->setText( i18n("W")); |
946 | 945 | ||
947 | 946 | ||
948 | int row, col; | 947 | int row, col; |
949 | mCells.resize( mNumCells ); | 948 | mCells.resize( mNumCells ); |
950 | for( row = 0; row < mNumWeeks; ++row ) { | 949 | for( row = 0; row < mNumWeeks; ++row ) { |
951 | for( col = 0; col < mDaysPerWeek; ++col ) { | 950 | for( col = 0; col < mDaysPerWeek; ++col ) { |
952 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 951 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
953 | mCells.insert( row * mDaysPerWeek + col, cell ); | 952 | mCells.insert( row * mDaysPerWeek + col, cell ); |
954 | 953 | ||
955 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 954 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
956 | SLOT( defaultAction( Incidence * ) ) ); | 955 | SLOT( defaultAction( Incidence * ) ) ); |
957 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 956 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
958 | SIGNAL( newEventSignal( QDateTime ) ) ); | 957 | SIGNAL( newEventSignal( QDateTime ) ) ); |
959 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 958 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
960 | SIGNAL( showDaySignal( QDate ) ) ); | 959 | SIGNAL( showDaySignal( QDate ) ) ); |
961 | } | 960 | } |
962 | } | 961 | } |
963 | mCellsW.resize( mDaysPerWeek ); | 962 | mCellsW.resize( mDaysPerWeek ); |
964 | for( col = 0; col < mDaysPerWeek; ++col ) { | 963 | for( col = 0; col < mDaysPerWeek; ++col ) { |
965 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 964 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
966 | mCellsW.insert( col, cell ); | 965 | mCellsW.insert( col, cell ); |
967 | 966 | ||
968 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 967 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
969 | SLOT( defaultAction( Incidence * ) ) ); | 968 | SLOT( defaultAction( Incidence * ) ) ); |
970 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 969 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
971 | SIGNAL( newEventSignal( QDateTime ) ) ); | 970 | SIGNAL( newEventSignal( QDateTime ) ) ); |
972 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 971 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
973 | SIGNAL( showDaySignal( QDate ) ) ); | 972 | SIGNAL( showDaySignal( QDate ) ) ); |
974 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 973 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
975 | } | 974 | } |
976 | 975 | ||
977 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 976 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
978 | mContextMenu = eventPopup(); | 977 | mContextMenu = eventPopup(); |
979 | // updateConfig(); //useless here... | 978 | // updateConfig(); //useless here... |
980 | // ... but we need mWidthLongDayLabel computed | 979 | // ... but we need mWidthLongDayLabel computed |
981 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 980 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
982 | mWidthLongDayLabel = 0; | 981 | mWidthLongDayLabel = 0; |
983 | for (int i = 0; i < 7; i++) { | 982 | for (int i = 0; i < 7; i++) { |
984 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 983 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
985 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 984 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
986 | } | 985 | } |
987 | 986 | ||
988 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 987 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
989 | 988 | ||
990 | #if 0 | 989 | #if 0 |
991 | if ( mShowWeekView ) | 990 | if ( mShowWeekView ) |
992 | mWidStack->raiseWidget( mWeekView ); | 991 | mWidStack->raiseWidget( mWeekView ); |
993 | else | 992 | else |
994 | mWidStack->raiseWidget( mMonthView ); | 993 | mWidStack->raiseWidget( mMonthView ); |
995 | #endif | 994 | #endif |
996 | 995 | ||
997 | emit incidenceSelected( 0 ); | 996 | emit incidenceSelected( 0 ); |
998 | #ifndef DESKTOP_VERSION | 997 | #ifndef DESKTOP_VERSION |
999 | resize( QApplication::desktop()->size() ); | 998 | resize( QApplication::desktop()->size() ); |
1000 | #else | 999 | #else |
1001 | resize(640, 480 ); | 1000 | resize(640, 480 ); |
1002 | updatePossible = true; | 1001 | updatePossible = true; |
1003 | #endif | 1002 | #endif |
1004 | computeLayout(); | 1003 | computeLayout(); |
1005 | 1004 | ||
1006 | if ( mShowWeekView ) | 1005 | if ( mShowWeekView ) |
1007 | mWidStack->raiseWidget( mWeekView ); | 1006 | mWidStack->raiseWidget( mWeekView ); |
1008 | else | 1007 | else |
1009 | mWidStack->raiseWidget( mMonthView ); | 1008 | mWidStack->raiseWidget( mMonthView ); |
1010 | } | 1009 | } |
1011 | 1010 | ||
1012 | KOMonthView::~KOMonthView() | 1011 | KOMonthView::~KOMonthView() |
1013 | { | 1012 | { |
1014 | delete mContextMenu; | 1013 | delete mContextMenu; |
1015 | } | 1014 | } |
1016 | 1015 | ||
1017 | void KOMonthView::selectInternalWeekNum ( int n ) | 1016 | void KOMonthView::selectInternalWeekNum ( int n ) |
1018 | { | 1017 | { |
1019 | switchView(); | 1018 | switchView(); |
1020 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1019 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1021 | emit selectMonth (); | 1020 | emit selectMonth (); |
1022 | else | 1021 | else |
1023 | emit selectWeekNum ( n ); | 1022 | emit selectWeekNum ( n ); |
1024 | } | 1023 | } |
1025 | 1024 | ||
1026 | int KOMonthView::currentWeek() | 1025 | int KOMonthView::currentWeek() |
1027 | { | 1026 | { |
1028 | if ( mShowWeekView ) | 1027 | if ( mShowWeekView ) |
1029 | return mWeekLabelsW[0]->getWeekNum(); | 1028 | return mWeekLabelsW[0]->getWeekNum(); |
1030 | return mWeekLabels[0]->getWeekNum(); | 1029 | return mWeekLabels[0]->getWeekNum(); |
1031 | } | 1030 | } |
1032 | void KOMonthView::switchView() | 1031 | void KOMonthView::switchView() |
1033 | { | 1032 | { |
1034 | if ( selectedCell( ) ) | 1033 | if ( selectedCell( ) ) |
1035 | selectedCell()->deselect(); | 1034 | selectedCell()->deselect(); |
1036 | mShowWeekView = !mShowWeekView; | 1035 | mShowWeekView = !mShowWeekView; |
1037 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1036 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1038 | if ( clPending ) { | 1037 | if ( clPending ) { |
1039 | computeLayout(); | 1038 | computeLayout(); |
1040 | updateConfig(); | 1039 | updateConfig(); |
1041 | } | 1040 | } |
1042 | if ( mShowWeekView ) | 1041 | if ( mShowWeekView ) |
1043 | mWidStack->raiseWidget( mWeekView ); | 1042 | mWidStack->raiseWidget( mWeekView ); |
1044 | else | 1043 | else |
1045 | mWidStack->raiseWidget( mMonthView ); | 1044 | mWidStack->raiseWidget( mMonthView ); |
1046 | clPending = false; | 1045 | clPending = false; |
1047 | } | 1046 | } |
1048 | 1047 | ||
1049 | int KOMonthView::maxDatesHint() | 1048 | int KOMonthView::maxDatesHint() |
1050 | { | 1049 | { |
1051 | return mNumCells; | 1050 | return mNumCells; |
1052 | } | 1051 | } |
1053 | 1052 | ||
1054 | int KOMonthView::currentDateCount() | 1053 | int KOMonthView::currentDateCount() |
1055 | { | 1054 | { |
1056 | return mNumCells; | 1055 | return mNumCells; |
1057 | } | 1056 | } |
1058 | 1057 | ||
1059 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1058 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1060 | { | 1059 | { |
1061 | QPtrList<Incidence> selected; | 1060 | QPtrList<Incidence> selected; |
1062 | 1061 | ||
1063 | if ( mSelectedCell ) { | 1062 | if ( mSelectedCell ) { |
1064 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1063 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1065 | if ( incidence ) selected.append( incidence ); | 1064 | if ( incidence ) selected.append( incidence ); |
1066 | } | 1065 | } |
1067 | 1066 | ||
1068 | return selected; | 1067 | return selected; |
1069 | } | 1068 | } |
1070 | 1069 | ||
1071 | DateList KOMonthView::selectedDates() | 1070 | DateList KOMonthView::selectedDates() |
1072 | { | 1071 | { |
1073 | DateList selected; | 1072 | DateList selected; |
1074 | 1073 | ||
1075 | if ( mSelectedCell ) { | 1074 | if ( mSelectedCell ) { |
1076 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1075 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1077 | if ( qd.isValid() ) selected.append( qd ); | 1076 | if ( qd.isValid() ) selected.append( qd ); |
1078 | } | 1077 | } |
1079 | 1078 | ||
1080 | return selected; | 1079 | return selected; |
1081 | } | 1080 | } |
1082 | 1081 | ||
1083 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1082 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1084 | const QDate &td) | 1083 | const QDate &td) |
1085 | { | 1084 | { |
1086 | #ifndef KORG_NOPRINTER | 1085 | #ifndef KORG_NOPRINTER |
1087 | calPrinter->preview(CalPrinter::Month, fd, td); | 1086 | calPrinter->preview(CalPrinter::Month, fd, td); |
1088 | #endif | 1087 | #endif |
1089 | } | 1088 | } |
1090 | 1089 | ||
1091 | void KOMonthView::updateConfig() | 1090 | void KOMonthView::updateConfig() |
1092 | { | 1091 | { |
1093 | 1092 | ||
1094 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1093 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1095 | 1094 | ||
1096 | if ( mShowWeekView ) { | 1095 | if ( mShowWeekView ) { |
1097 | mWeekStartsMonday = true; | 1096 | mWeekStartsMonday = true; |
1098 | } | 1097 | } |
1099 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1098 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1100 | mWidthLongDayLabel = 0; | 1099 | mWidthLongDayLabel = 0; |
1101 | 1100 | ||
1102 | for (int i = 0; i < 7; i++) { | 1101 | for (int i = 0; i < 7; i++) { |
1103 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1102 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1104 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1103 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1105 | } | 1104 | } |
1106 | bool temp = mShowSatSunComp ; | 1105 | bool temp = mShowSatSunComp ; |
1107 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1106 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1108 | if ( ! mShowWeekView ) { | 1107 | if ( ! mShowWeekView ) { |
1109 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1108 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1110 | computeLayout(); | 1109 | computeLayout(); |
1111 | } | 1110 | } |
1112 | updateDayLabels(); | 1111 | updateDayLabels(); |
1113 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1112 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1114 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1113 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1115 | //resizeEvent( 0 ); | 1114 | //resizeEvent( 0 ); |
1116 | for (uint i = 0; i < mCells.count(); ++i) { | 1115 | for (uint i = 0; i < mCells.count(); ++i) { |
1117 | mCells[i]->updateConfig(); | 1116 | mCells[i]->updateConfig(); |
1118 | } | 1117 | } |
1119 | 1118 | ||
1120 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1119 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1121 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1120 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1122 | } | 1121 | } |
1123 | #ifdef DESKTOP_VERSION | 1122 | #ifdef DESKTOP_VERSION |
1124 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1123 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1125 | #endif | 1124 | #endif |
1126 | updateView(); | 1125 | updateView(); |
1127 | } | 1126 | } |
1128 | 1127 | ||
1129 | void KOMonthView::updateDayLabels() | 1128 | void KOMonthView::updateDayLabels() |
1130 | { | 1129 | { |
1131 | 1130 | ||
1132 | QPtrVector<QLabel> *mDayLabelsT; | 1131 | QPtrVector<QLabel> *mDayLabelsT; |
1133 | 1132 | ||
1134 | mDayLabelsT = &mDayLabelsW; | 1133 | mDayLabelsT = &mDayLabelsW; |
1135 | for (int i = 0; i < 7; i++) { | 1134 | for (int i = 0; i < 7; i++) { |
1136 | if (mWeekStartsMonday) { | 1135 | if (mWeekStartsMonday) { |
1137 | bool show = mShortDayLabelsW; | 1136 | bool show = mShortDayLabelsW; |
1138 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1137 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1139 | show = true; | 1138 | show = true; |
1140 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1139 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1141 | } else { | 1140 | } else { |
1142 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); | 1141 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); |
1143 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); | 1142 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); |
1144 | 1143 | ||
1145 | } | 1144 | } |
1146 | } | 1145 | } |
1147 | mDayLabelsT = &mDayLabels; | 1146 | mDayLabelsT = &mDayLabels; |
1148 | for (int i = 0; i < 7; i++) { | 1147 | for (int i = 0; i < 7; i++) { |
1149 | if (mWeekStartsMonday) { | 1148 | if (mWeekStartsMonday) { |
1150 | bool show = mShortDayLabelsM; | 1149 | bool show = mShortDayLabelsM; |
1151 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1150 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1152 | show = true; | 1151 | show = true; |
1153 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1152 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1154 | } else { | 1153 | } else { |
1155 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1154 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1156 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1155 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1157 | 1156 | ||
1158 | } | 1157 | } |
1159 | } | 1158 | } |
1160 | 1159 | ||
1161 | } | 1160 | } |
1162 | 1161 | ||
1163 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1162 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1164 | { | 1163 | { |
1165 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1164 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1166 | 1165 | ||
1167 | QPtrVector<MonthViewCell> *cells; | 1166 | QPtrVector<MonthViewCell> *cells; |
1168 | QPtrVector<QLabel> *dayLabels; | 1167 | QPtrVector<QLabel> *dayLabels; |
1169 | QPtrVector<KOWeekButton> *weekLabels; | 1168 | QPtrVector<KOWeekButton> *weekLabels; |
1170 | int weekNum = 6; | 1169 | int weekNum = 6; |
1171 | if ( mShowWeekView ) { | 1170 | if ( mShowWeekView ) { |
1172 | weekNum = 1; | 1171 | weekNum = 1; |
1173 | cells = &mCellsW; | 1172 | cells = &mCellsW; |
1174 | dayLabels = &mDayLabelsW; | 1173 | dayLabels = &mDayLabelsW; |
1175 | weekLabels = &mWeekLabelsW; | 1174 | weekLabels = &mWeekLabelsW; |
1176 | } else { | 1175 | } else { |
1177 | cells = &mCells; | 1176 | cells = &mCells; |
1178 | dayLabels = &mDayLabels; | 1177 | dayLabels = &mDayLabels; |
1179 | weekLabels = &mWeekLabels; | 1178 | weekLabels = &mWeekLabels; |
1180 | } | 1179 | } |
1181 | 1180 | ||
1182 | mStartDate = start; | 1181 | mStartDate = start; |
1183 | 1182 | ||
1184 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1183 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1185 | 1184 | ||
1186 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1185 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1187 | mStartDate = mStartDate.addDays( -1 ); | 1186 | mStartDate = mStartDate.addDays( -1 ); |
1188 | } | 1187 | } |
1189 | 1188 | ||
1190 | bool primary = false; | 1189 | bool primary = false; |
1191 | uint i; | 1190 | uint i; |
1192 | for( i = 0; i < (*cells).size(); ++i ) { | 1191 | for( i = 0; i < (*cells).size(); ++i ) { |
1193 | QDate date = mStartDate.addDays( i ); | 1192 | QDate date = mStartDate.addDays( i ); |
1194 | (*cells)[i]->setDate( date ); | 1193 | (*cells)[i]->setDate( date ); |
1195 | 1194 | ||
1196 | #ifndef KORG_NOPLUGINS | 1195 | #ifndef KORG_NOPLUGINS |
1197 | // add holiday, if present | 1196 | // add holiday, if present |
1198 | QString hstring(KOCore::self()->holiday(date)); | 1197 | QString hstring(KOCore::self()->holiday(date)); |
1199 | (*cells)[i]->setHoliday( hstring ); | 1198 | (*cells)[i]->setHoliday( hstring ); |
1200 | #endif | 1199 | #endif |
1201 | 1200 | ||
1202 | } | 1201 | } |
1203 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1202 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1204 | for( i = 0; i < weekNum; ++i ) { | 1203 | for( i = 0; i < weekNum; ++i ) { |
1205 | int wno; | 1204 | int wno; |
1206 | // remember, according to ISO 8601, the first week of the year is the | 1205 | // remember, according to ISO 8601, the first week of the year is the |
1207 | // first week that contains a thursday. Thus we must subtract off 4, | 1206 | // first week that contains a thursday. Thus we must subtract off 4, |
1208 | // not just 1. | 1207 | // not just 1. |
1209 | int dayOfYear = date.dayOfYear(); | 1208 | int dayOfYear = date.dayOfYear(); |
1210 | if (dayOfYear % 7 != 0) | 1209 | if (dayOfYear % 7 != 0) |
1211 | wno = dayOfYear / 7 + 1; | 1210 | wno = dayOfYear / 7 + 1; |
1212 | else | 1211 | else |
1213 | wno =dayOfYear / 7; | 1212 | wno =dayOfYear / 7; |
1214 | (*weekLabels)[i]->setWeekNum( wno ); | 1213 | (*weekLabels)[i]->setWeekNum( wno ); |
1215 | date = date.addDays( 7 ); | 1214 | date = date.addDays( 7 ); |
1216 | } | 1215 | } |
1217 | updateView(); | 1216 | updateView(); |
1218 | } | 1217 | } |
1219 | 1218 | ||
1220 | void KOMonthView::showEvents(QPtrList<Event>) | 1219 | void KOMonthView::showEvents(QPtrList<Event>) |
1221 | { | 1220 | { |
1222 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1221 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1223 | } | 1222 | } |
1224 | 1223 | ||
1225 | void KOMonthView::changeEventDisplay(Event *, int) | 1224 | void KOMonthView::changeEventDisplay(Event *, int) |
1226 | { | 1225 | { |
1227 | // this should be re-written to be much more efficient, but this | 1226 | // this should be re-written to be much more efficient, but this |
1228 | // quick-and-dirty-hack gets the job done for right now. | 1227 | // quick-and-dirty-hack gets the job done for right now. |
1229 | updateView(); | 1228 | updateView(); |
1230 | } | 1229 | } |
1231 | 1230 | ||
1232 | void KOMonthView::updateView() | 1231 | void KOMonthView::updateView() |
1233 | { | 1232 | { |
1234 | 1233 | ||
1235 | if ( !updatePossible ) | 1234 | if ( !updatePossible ) |
1236 | return; | 1235 | return; |
1237 | //QTime ti; | 1236 | //QTime ti; |
1238 | //ti.start(); | 1237 | //ti.start(); |
1239 | clearSelection(); | 1238 | clearSelection(); |
1240 | QPtrVector<MonthViewCell> *cells; | 1239 | QPtrVector<MonthViewCell> *cells; |
1241 | if ( mShowWeekView ) { | 1240 | if ( mShowWeekView ) { |
1242 | cells = &mCellsW; | 1241 | cells = &mCellsW; |
1243 | } else { | 1242 | } else { |
1244 | cells = &mCells; | 1243 | cells = &mCells; |
1245 | } | 1244 | } |
1246 | #if 1 | 1245 | #if 1 |
1247 | int i; | 1246 | int i; |
1248 | int timeSpan = (*cells).size()-1; | 1247 | int timeSpan = (*cells).size()-1; |
1249 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1248 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1250 | timeSpan = 6; | 1249 | timeSpan = 6; |
1251 | for( i = 0; i < timeSpan + 1; ++i ) { | 1250 | for( i = 0; i < timeSpan + 1; ++i ) { |
1252 | (*cells)[i]->startUpdateCell(); | 1251 | (*cells)[i]->startUpdateCell(); |
1253 | } | 1252 | } |
1254 | 1253 | ||
1255 | QPtrList<Event> events = calendar()->events(); | 1254 | QPtrList<Event> events = calendar()->events(); |
1256 | Event *event; | 1255 | Event *event; |
1257 | QDateTime dt; | 1256 | QDateTime dt; |
1258 | bool ok; | 1257 | bool ok; |
1259 | QDate endDate = mStartDate.addDays( timeSpan ); | 1258 | QDate endDate = mStartDate.addDays( timeSpan ); |
1260 | for( event = events.first(); event; event = events.next() ) { // for event | 1259 | for( event = events.first(); event; event = events.next() ) { // for event |
1261 | if ( event->doesRecur() ) { | 1260 | if ( event->doesRecur() ) { |
1262 | bool last; | 1261 | bool last; |
1263 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1262 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1264 | QDateTime incidenceEnd; | 1263 | QDateTime incidenceEnd; |
1265 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1264 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1266 | bool invalid = false; | 1265 | bool invalid = false; |
1267 | while( true ) { | 1266 | while( true ) { |
1268 | if ( incidenceStart.isValid() ) { | 1267 | if ( incidenceStart.isValid() ) { |
1269 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1268 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1270 | int st = incidenceStart.date().daysTo( endDate ); | 1269 | int st = incidenceStart.date().daysTo( endDate ); |
1271 | if ( st >= 0 ) { // start before timeend | 1270 | if ( st >= 0 ) { // start before timeend |
1272 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1271 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1273 | if ( end >= 0 ) { // end after timestart --- got one! | 1272 | if ( end >= 0 ) { // end after timestart --- got one! |
1274 | //normalize | 1273 | //normalize |
1275 | st = timeSpan - st; | 1274 | st = timeSpan - st; |
1276 | if ( st < 0 ) st = 0; | 1275 | if ( st < 0 ) st = 0; |
1277 | if ( end > timeSpan ) end = timeSpan; | 1276 | if ( end > timeSpan ) end = timeSpan; |
1278 | int iii; | 1277 | int iii; |
1279 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1278 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1280 | for ( iii = st;iii<= end;++iii) | 1279 | for ( iii = st;iii<= end;++iii) |
1281 | (*cells)[iii]->insertEvent( event ); | 1280 | (*cells)[iii]->insertEvent( event ); |
1282 | } | 1281 | } |
1283 | } | 1282 | } |
1284 | } else { | 1283 | } else { |
1285 | if ( invalid ) | 1284 | if ( invalid ) |
1286 | break; | 1285 | break; |
1287 | invalid = true; | 1286 | invalid = true; |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 18dc656..66ff75d 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -1,774 +1,774 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qtextcodec.h> | 22 | #include <qtextcodec.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #ifdef DESKTOP_VERSION | 27 | #ifdef DESKTOP_VERSION |
28 | #include <qpaintdevicemetrics.h> | 28 | #include <qpaintdevicemetrics.h> |
29 | #endif | 29 | #endif |
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | 37 | ||
38 | #ifndef KORG_NOPRINTER | 38 | #ifndef KORG_NOPRINTER |
39 | #include "calprinter.h" | 39 | #include "calprinter.h" |
40 | #endif | 40 | #endif |
41 | #include "koglobals.h" | 41 | #include "koglobals.h" |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | #include "koeventviewerdialog.h" | 43 | #include "koeventviewerdialog.h" |
44 | #include <qstylesheet.h> | 44 | #include <qstylesheet.h> |
45 | #include "kowhatsnextview.h" | 45 | #include "kowhatsnextview.h" |
46 | using namespace KOrg; | 46 | using namespace KOrg; |
47 | 47 | ||
48 | void WhatsNextTextBrowser::setSource(const QString& n) | 48 | void WhatsNextTextBrowser::setSource(const QString& n) |
49 | { | 49 | { |
50 | 50 | ||
51 | if (n.startsWith("event:")) { | 51 | if (n.startsWith("event:")) { |
52 | emit showIncidence(n); | 52 | emit showIncidence(n); |
53 | return; | 53 | return; |
54 | } else if (n.startsWith("todo:")) { | 54 | } else if (n.startsWith("todo:")) { |
55 | emit showIncidence(n); | 55 | emit showIncidence(n); |
56 | return; | 56 | return; |
57 | } else { | 57 | } else { |
58 | QTextBrowser::setSource(n); | 58 | QTextBrowser::setSource(n); |
59 | } | 59 | } |
60 | } | 60 | } |
61 | void WhatsNextTextBrowser::printMe() | 61 | void WhatsNextTextBrowser::printMe() |
62 | { | 62 | { |
63 | #ifdef DESKTOP_VERSION | 63 | #ifdef DESKTOP_VERSION |
64 | QPrinter printer; | 64 | QPrinter printer; |
65 | if (!printer.setup() ) | 65 | if (!printer.setup() ) |
66 | return; | 66 | return; |
67 | QPainter p; | 67 | QPainter p; |
68 | p.begin ( &printer ); | 68 | p.begin ( &printer ); |
69 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 69 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
70 | float dx, dy; | 70 | float dx, dy; |
71 | int wid = (m.width() * 9)/10; | 71 | int wid = (m.width() * 9)/10; |
72 | dx = (float) wid/(float)contentsWidth (); | 72 | dx = (float) wid/(float)contentsWidth (); |
73 | dy = (float)(m.height()) / (float)contentsHeight (); | 73 | dy = (float)(m.height()) / (float)contentsHeight (); |
74 | float scale; | 74 | float scale; |
75 | // scale to fit the width or height of the paper | 75 | // scale to fit the width or height of the paper |
76 | if ( dx < dy ) | 76 | if ( dx < dy ) |
77 | scale = dx; | 77 | scale = dx; |
78 | else | 78 | else |
79 | scale = dy; | 79 | scale = dy; |
80 | p.translate( m.width()/10,0 ); | 80 | p.translate( m.width()/10,0 ); |
81 | p.scale( scale, scale ); | 81 | p.scale( scale, scale ); |
82 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 82 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
83 | p.end(); | 83 | p.end(); |
84 | #endif | 84 | #endif |
85 | } | 85 | } |
86 | 86 | ||
87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
88 | const char *name) | 88 | const char *name) |
89 | : KOrg::BaseView(calendar, parent, name) | 89 | : KOrg::BaseView(calendar, parent, name) |
90 | { | 90 | { |
91 | // mDateLabel = | 91 | // mDateLabel = |
92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
93 | // mDateLabel->setMargin(2); | 93 | // mDateLabel->setMargin(2); |
94 | // mDateLabel->setAlignment(AlignCenter); | 94 | // mDateLabel->setAlignment(AlignCenter); |
95 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 95 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
96 | mView = new WhatsNextTextBrowser(this); | 96 | mView = new WhatsNextTextBrowser(this); |
97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
98 | QStyleSheet* stsh = mView->styleSheet(); | 98 | QStyleSheet* stsh = mView->styleSheet(); |
99 | QStyleSheetItem * style ; | 99 | QStyleSheetItem * style ; |
100 | style = stsh->item ("h2" ); | 100 | style = stsh->item ("h2" ); |
101 | if ( style ) { | 101 | if ( style ) { |
102 | style->setMargin(QStyleSheetItem::MarginAll,0); | 102 | style->setMargin(QStyleSheetItem::MarginAll,0); |
103 | } | 103 | } |
104 | style = stsh->item ("h3" ); | 104 | style = stsh->item ("h3" ); |
105 | if ( style ) { | 105 | if ( style ) { |
106 | style->setMargin(QStyleSheetItem::MarginAll,0); | 106 | style->setMargin(QStyleSheetItem::MarginAll,0); |
107 | } | 107 | } |
108 | mEventViewer = 0; | 108 | mEventViewer = 0; |
109 | 109 | ||
110 | QBoxLayout *topLayout = new QVBoxLayout(this); | 110 | QBoxLayout *topLayout = new QVBoxLayout(this); |
111 | // topLayout->addWidget(mDateLabel); | 111 | // topLayout->addWidget(mDateLabel); |
112 | topLayout->addWidget(mView); | 112 | topLayout->addWidget(mView); |
113 | mTimer = new QTimer( this ); | 113 | mTimer = new QTimer( this ); |
114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
115 | 115 | ||
116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
118 | } | 118 | } |
119 | 119 | ||
120 | KOWhatsNextView::~KOWhatsNextView() | 120 | KOWhatsNextView::~KOWhatsNextView() |
121 | { | 121 | { |
122 | } | 122 | } |
123 | 123 | ||
124 | int KOWhatsNextView::maxDatesHint() | 124 | int KOWhatsNextView::maxDatesHint() |
125 | { | 125 | { |
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
128 | 128 | ||
129 | int KOWhatsNextView::currentDateCount() | 129 | int KOWhatsNextView::currentDateCount() |
130 | { | 130 | { |
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | 133 | ||
134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
135 | { | 135 | { |
136 | QPtrList<Incidence> eventList; | 136 | QPtrList<Incidence> eventList; |
137 | 137 | ||
138 | return eventList; | 138 | return eventList; |
139 | } | 139 | } |
140 | 140 | ||
141 | void KOWhatsNextView::printMe() | 141 | void KOWhatsNextView::printMe() |
142 | { | 142 | { |
143 | #ifdef DESKTOP_VERSION | 143 | #ifdef DESKTOP_VERSION |
144 | mView->printMe(); | 144 | mView->printMe(); |
145 | #endif | 145 | #endif |
146 | } | 146 | } |
147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
148 | const QDate &td) | 148 | const QDate &td) |
149 | { | 149 | { |
150 | #ifndef KORG_NOPRINTER | 150 | #ifndef KORG_NOPRINTER |
151 | calPrinter->preview(CalPrinter::Day, fd, td); | 151 | calPrinter->preview(CalPrinter::Day, fd, td); |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | void KOWhatsNextView::updateConfig() | 154 | void KOWhatsNextView::updateConfig() |
155 | { | 155 | { |
156 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 156 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
157 | updateView(); | 157 | updateView(); |
158 | 158 | ||
159 | } | 159 | } |
160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
161 | { | 161 | { |
162 | //qDebug("KOWhatsNextView::showEvent "); | 162 | //qDebug("KOWhatsNextView::showEvent "); |
163 | restartTimer(); | 163 | restartTimer(); |
164 | QWidget::showEvent ( e ); | 164 | QWidget::showEvent ( e ); |
165 | } | 165 | } |
166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
167 | { | 167 | { |
168 | //qDebug(" KOWhatsNextView::hideEvent"); | 168 | //qDebug(" KOWhatsNextView::hideEvent"); |
169 | mTimer->stop(); | 169 | mTimer->stop(); |
170 | QWidget::hideEvent ( e ); | 170 | QWidget::hideEvent ( e ); |
171 | } | 171 | } |
172 | void KOWhatsNextView::restartTimer() | 172 | void KOWhatsNextView::restartTimer() |
173 | { | 173 | { |
174 | //qDebug("KOWhatsNextView::restartTimer() "); | 174 | //qDebug("KOWhatsNextView::restartTimer() "); |
175 | mTimer->start( 300000 ); | 175 | mTimer->start( 300000 ); |
176 | //mTimer->start( 5000 ); | 176 | //mTimer->start( 5000 ); |
177 | } | 177 | } |
178 | void KOWhatsNextView::updateView() | 178 | void KOWhatsNextView::updateView() |
179 | { | 179 | { |
180 | //qDebug("KOWhatsNextView::updateView() "); | 180 | //qDebug("KOWhatsNextView::updateView() "); |
181 | if ( mTimer->isActive() ) | 181 | if ( mTimer->isActive() ) |
182 | restartTimer(); | 182 | restartTimer(); |
183 | //qDebug("KOWhatsNextView::updateView() "); | 183 | //qDebug("KOWhatsNextView::updateView() "); |
184 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 184 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
185 | KIconLoader kil("korganizer"); | 185 | KIconLoader kil("korganizer"); |
186 | QString ipath;// = new QString(); | 186 | QString ipath;// = new QString(); |
187 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 187 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
188 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 188 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
189 | mText = "<table width=\"100%\">\n"; | 189 | mText = "<table width=\"100%\">\n"; |
190 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 190 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
191 | #ifdef DESKTOP_VERSION | 191 | #ifdef DESKTOP_VERSION |
192 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 192 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
193 | #else | 193 | #else |
194 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 194 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
195 | #endif | 195 | #endif |
196 | // mText += "<img src=\""; | 196 | // mText += "<img src=\""; |
197 | // mText += ipath; | 197 | // mText += ipath; |
198 | // mText += "\">"; | 198 | // mText += "\">"; |
199 | mEventDate = QDate::currentDate(); | 199 | mEventDate = QDate::currentDate(); |
200 | #ifdef DESKTOP_VERSION | 200 | #ifdef DESKTOP_VERSION |
201 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 201 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
202 | #else | 202 | #else |
203 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 203 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
204 | #endif | 204 | #endif |
205 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 205 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
206 | int iii; | 206 | int iii; |
207 | mTodos.clear(); | 207 | mTodos.clear(); |
208 | QPtrList<Event> events; | 208 | QPtrList<Event> events; |
209 | QPtrList<Todo> todos = calendar()->todos(); | 209 | QPtrList<Todo> todos = calendar()->todos(); |
210 | Todo * todo; | 210 | Todo * todo; |
211 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 211 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
212 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 212 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
213 | bool itemAdded = false; | 213 | bool itemAdded = false; |
214 | for ( iii = 0; iii < daysToShow; ++iii ) { | 214 | for ( iii = 0; iii < daysToShow; ++iii ) { |
215 | QString date; | 215 | QString date; |
216 | itemAdded = false; | 216 | itemAdded = false; |
217 | events = calendar()->events( mEventDate, true ); | 217 | events = calendar()->events( mEventDate, true ); |
218 | 218 | ||
219 | if ( iii == 0 ) { // today !!! | 219 | if ( iii == 0 ) { // today !!! |
220 | todo = todos.first(); | 220 | todo = todos.first(); |
221 | while(todo) { | 221 | while(todo) { |
222 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 222 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
223 | if ( ! itemAdded ) { | 223 | if ( ! itemAdded ) { |
224 | appendDay ( iii, mEventDate ); | 224 | appendDay ( iii, mEventDate ); |
225 | //itemAdded = true; | 225 | //itemAdded = true; |
226 | 226 | ||
227 | } //bool reply=false, bool notRed = true, bool appendTable = false); | 227 | } //bool reply=false, bool notRed = true, bool appendTable = false); |
228 | appendEvent(todo, false, false, !itemAdded ); | 228 | appendEvent(todo, false, false, !itemAdded ); |
229 | itemAdded = true; | 229 | itemAdded = true; |
230 | } | 230 | } |
231 | todo = todos.next(); | 231 | todo = todos.next(); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | if (events.count() > 0) { | 236 | if (events.count() > 0) { |
237 | // mText += "<p></p>"; | 237 | // mText += "<p></p>"; |
238 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 238 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
239 | // mText += "<h2>"; | 239 | // mText += "<h2>"; |
240 | //mText += " <img src=\""; | 240 | //mText += " <img src=\""; |
241 | //mText += ipath; | 241 | //mText += ipath; |
242 | //mText += "\">"; | 242 | //mText += "\">"; |
243 | if ( ! itemAdded ) { | 243 | if ( ! itemAdded ) { |
244 | appendDay ( iii, mEventDate ); | 244 | appendDay ( iii, mEventDate ); |
245 | 245 | ||
246 | } | 246 | } |
247 | // for first day (iii == 0) | 247 | // for first day (iii == 0) |
248 | // we may have syncevents, or events in the past, which maybe should not be diaplayed | 248 | // we may have syncevents, or events in the past, which maybe should not be diaplayed |
249 | // for that reason we cannot append <table> in appendDay () for iii == 0 | 249 | // for that reason we cannot append <table> in appendDay () for iii == 0 |
250 | // we must append it in the first successful call of appendEvent() | 250 | // we must append it in the first successful call of appendEvent() |
251 | Event *ev = events.first(); | 251 | Event *ev = events.first(); |
252 | while(ev) { | 252 | while(ev) { |
253 | //qDebug("+++++event append %s", ev->summary().latin1()); | 253 | //qDebug("+++++event append %s", ev->summary().latin1()); |
254 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 254 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
255 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) | 255 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) |
256 | itemAdded = true; | 256 | itemAdded = true; |
257 | } | 257 | } |
258 | ev = events.next(); | 258 | ev = events.next(); |
259 | } | 259 | } |
260 | 260 | ||
261 | //mText += "</table>\n"; | 261 | //mText += "</table>\n"; |
262 | } | 262 | } |
263 | 263 | ||
264 | todo = todos.first(); | 264 | todo = todos.first(); |
265 | while(todo) { | 265 | while(todo) { |
266 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 266 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
267 | if ( ! itemAdded ) { | 267 | if ( ! itemAdded ) { |
268 | appendDay ( iii, mEventDate ); | 268 | appendDay ( iii, mEventDate ); |
269 | //itemAdded = true; | 269 | //itemAdded = true; |
270 | } | 270 | } |
271 | appendEvent(todo, false , iii!= 0,!itemAdded); | 271 | appendEvent(todo, false , iii!= 0,!itemAdded); |
272 | itemAdded = true; | 272 | itemAdded = true; |
273 | } | 273 | } |
274 | todo = todos.next(); | 274 | todo = todos.next(); |
275 | } | 275 | } |
276 | if ( !itemAdded && iii == 0 ) { | 276 | if ( !itemAdded && iii == 0 ) { |
277 | // appendDay ( iii, mEventDate ); | 277 | // appendDay ( iii, mEventDate ); |
278 | //mText += "<table>"; | 278 | //mText += "<table>"; |
279 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; | 279 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; |
280 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; | 280 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; |
281 | //mText +="</table>"; | 281 | //mText +="</table>"; |
282 | } | 282 | } |
283 | if ( itemAdded ) | 283 | if ( itemAdded ) |
284 | mText += "</table>\n"; | 284 | mText += "</table>\n"; |
285 | mEventDate = mEventDate.addDays( 1 ); | 285 | mEventDate = mEventDate.addDays( 1 ); |
286 | } | 286 | } |
287 | 287 | ||
288 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; | 288 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; |
289 | if (todos.count() > 0 && topmostPrios > 0 ) { | 289 | if (todos.count() > 0 && topmostPrios > 0 ) { |
290 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 290 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
291 | // mText += "<h2>"; | 291 | // mText += "<h2>"; |
292 | //<img src=\""; | 292 | //<img src=\""; |
293 | // mText += ipath; | 293 | // mText += ipath; |
294 | // mText += "\">"; | 294 | // mText += "\">"; |
295 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; | 295 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; |
296 | 296 | ||
297 | //mText += "<ul>\n"; | 297 | //mText += "<ul>\n"; |
298 | bool gotone = false; | 298 | bool gotone = false; |
299 | int priority = 1; | 299 | int priority = 1; |
300 | int priosFound = 0; | 300 | int priosFound = 0; |
301 | #ifdef DESKTOP_VERSION | 301 | #ifdef DESKTOP_VERSION |
302 | mText +="<p></p>"; | 302 | mText +="<p></p>"; |
303 | #endif | 303 | #endif |
304 | 304 | ||
305 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; | 305 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; |
306 | mText += "<ul>\n"; | 306 | mText += "<ul>\n"; |
307 | while (!gotone && priority<6) { | 307 | while (!gotone && priority<6) { |
308 | todo = todos.first(); | 308 | todo = todos.first(); |
309 | while(todo) { | 309 | while(todo) { |
310 | if (!todo->isCompleted() && (todo->priority() == priority) ) { | 310 | if (!todo->isCompleted() && (todo->priority() == priority) ) { |
311 | if ( appendTodo(todo) ) | 311 | if ( appendTodo(todo) ) |
312 | gotone = true; | 312 | gotone = true; |
313 | } | 313 | } |
314 | todo = todos.next(); | 314 | todo = todos.next(); |
315 | } | 315 | } |
316 | if ( gotone ) { | 316 | if ( gotone ) { |
317 | gotone = false; | 317 | gotone = false; |
318 | ++priosFound; | 318 | ++priosFound; |
319 | if ( priosFound == topmostPrios ) | 319 | if ( priosFound == topmostPrios ) |
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | priority++; | 322 | priority++; |
323 | // kdDebug() << "adding the todos..." << endl; | 323 | // kdDebug() << "adding the todos..." << endl; |
324 | } | 324 | } |
325 | mText += "</ul>\n"; | 325 | mText += "</ul>\n"; |
326 | } | 326 | } |
327 | 327 | ||
328 | int replys = 0; | 328 | int replys = 0; |
329 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); | 329 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); |
330 | if (events.count() > 0) { | 330 | if (events.count() > 0) { |
331 | Event *ev = events.first(); | 331 | Event *ev = events.first(); |
332 | while(ev) { | 332 | while(ev) { |
333 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 333 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
334 | if (me!=0) { | 334 | if (me!=0) { |
335 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 335 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
336 | if (replys == 0) { | 336 | if (replys == 0) { |
337 | mText += "<p></p>"; | 337 | mText += "<p></p>"; |
338 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 338 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
339 | //mText += "<h2>"; | 339 | //mText += "<h2>"; |
340 | //<img src=\""; | 340 | //<img src=\""; |
341 | // mText += ipath; | 341 | // mText += ipath; |
342 | // mText += "\">"; | 342 | // mText += "\">"; |
343 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; | 343 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; |
344 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 344 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
345 | mText += "<table>\n"; | 345 | mText += "<table>\n"; |
346 | } | 346 | } |
347 | replys++; | 347 | replys++; |
348 | appendEvent(ev,true); | 348 | appendEvent(ev,true); |
349 | } | 349 | } |
350 | } | 350 | } |
351 | ev = events.next(); | 351 | ev = events.next(); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | todos = calendar()->todos(); | 354 | todos = calendar()->todos(); |
355 | if (todos.count() > 0) { | 355 | if (todos.count() > 0) { |
356 | Todo *to = todos.first(); | 356 | Todo *to = todos.first(); |
357 | while(to) { | 357 | while(to) { |
358 | if ( !to->isCompleted() ){ | 358 | if ( !to->isCompleted() ){ |
359 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 359 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
360 | if (me!=0) { | 360 | if (me!=0) { |
361 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 361 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
362 | if (replys == 0) { | 362 | if (replys == 0) { |
363 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 363 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
364 | mText += "<table>\n"; | 364 | mText += "<table>\n"; |
365 | } | 365 | } |
366 | replys++; | 366 | replys++; |
367 | appendEvent(to, true); | 367 | appendEvent(to, true); |
368 | } | 368 | } |
369 | } | 369 | } |
370 | } | 370 | } |
371 | to = todos.next(); | 371 | to = todos.next(); |
372 | } | 372 | } |
373 | } | 373 | } |
374 | if (replys > 0 ) mText += "</table>\n"; | 374 | if (replys > 0 ) mText += "</table>\n"; |
375 | 375 | ||
376 | 376 | ||
377 | mText += "</td></tr>\n</table>\n"; | 377 | mText += "</td></tr>\n</table>\n"; |
378 | 378 | ||
379 | mView->setText(mText); | 379 | mView->setText(mText); |
380 | mView->setFocus(); | 380 | mView->setFocus(); |
381 | 381 | ||
382 | // QPixmap bPix = SmallIcon( "back" ); | 382 | // QPixmap bPix = SmallIcon( "back" ); |
383 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); | 383 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); |
384 | // QWidget* test = new QWidget(); | 384 | // QWidget* test = new QWidget(); |
385 | // test->setBackgroundMode(FixedPixmap ); | 385 | // test->setBackgroundMode(FixedPixmap ); |
386 | // test->setBackgroundPixmap ( bPix ); | 386 | // test->setBackgroundPixmap ( bPix ); |
387 | // test->resize( 300, 400 ); | 387 | // test->resize( 300, 400 ); |
388 | // test->show(); | 388 | // test->show(); |
389 | // mView->setBackgroundMode(FixedPixmap ); | 389 | // mView->setBackgroundMode(FixedPixmap ); |
390 | // mView->setBackgroundPixmap ( bPix ); | 390 | // mView->setBackgroundPixmap ( bPix ); |
391 | // qDebug("%s ",mText.latin1()); | 391 | // qDebug("%s ",mText.latin1()); |
392 | } | 392 | } |
393 | 393 | ||
394 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) | 394 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) |
395 | { | 395 | { |
396 | QString date; | 396 | QString date; |
397 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); | 397 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); |
398 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { | 398 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { |
399 | if ( i == 0 ) { | 399 | if ( i == 0 ) { |
400 | //mText += "<table>\n"; | 400 | //mText += "<table>\n"; |
401 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; | 401 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; |
402 | } | 402 | } |
403 | else if ( i == 1 ) | 403 | else if ( i == 1 ) |
404 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; | 404 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; |
405 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; | 405 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; |
406 | mText += "<h2>" + date + "</h2>\n"; | 406 | mText += "<h2>" + date + "</h2>\n"; |
407 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 407 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
408 | mText += "<table>\n"; | 408 | mText += "<table>\n"; |
409 | 409 | ||
410 | 410 | ||
411 | 411 | ||
412 | } else { | 412 | } else { |
413 | if ( i == 0 ) { | 413 | if ( i == 0 ) { |
414 | //mText += "<table>\n"; | 414 | //mText += "<table>\n"; |
415 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; | 415 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; |
416 | } | 416 | } |
417 | 417 | ||
418 | #ifdef DESKTOP_VERSION | 418 | #ifdef DESKTOP_VERSION |
419 | else if ( i == 1 ) { | 419 | else if ( i == 1 ) { |
420 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; | 420 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; |
421 | } | 421 | } |
422 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; | 422 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; |
423 | #else | 423 | #else |
424 | else if ( i == 1 ) { | 424 | else if ( i == 1 ) { |
425 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; | 425 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; |
426 | } | 426 | } |
427 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; | 427 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; |
428 | 428 | ||
429 | #endif | 429 | #endif |
430 | mText += "<h2>" + date + "</h2>\n"; | 430 | mText += "<h2>" + date + "</h2>\n"; |
431 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 431 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
432 | mText += "<table>\n"; | 432 | mText += "<table>\n"; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void KOWhatsNextView::showDates(const QDate &, const QDate &) | 437 | void KOWhatsNextView::showDates(const QDate &, const QDate &) |
438 | { | 438 | { |
439 | updateView(); | 439 | updateView(); |
440 | } | 440 | } |
441 | 441 | ||
442 | void KOWhatsNextView::showEvents(QPtrList<Event>) | 442 | void KOWhatsNextView::showEvents(QPtrList<Event>) |
443 | { | 443 | { |
444 | } | 444 | } |
445 | 445 | ||
446 | void KOWhatsNextView::changeEventDisplay(Event *, int action) | 446 | void KOWhatsNextView::changeEventDisplay(Event *, int action) |
447 | { | 447 | { |
448 | switch(action) { | 448 | switch(action) { |
449 | case KOGlobals::EVENTADDED: | 449 | case KOGlobals::EVENTADDED: |
450 | updateView(); | 450 | updateView(); |
451 | break; | 451 | break; |
452 | case KOGlobals::EVENTEDITED: | 452 | case KOGlobals::EVENTEDITED: |
453 | updateView(); | 453 | updateView(); |
454 | break; | 454 | break; |
455 | case KOGlobals::EVENTDELETED: | 455 | case KOGlobals::EVENTDELETED: |
456 | updateView(); | 456 | updateView(); |
457 | break; | 457 | break; |
458 | default: | 458 | default: |
459 | updateView(); | 459 | updateView(); |
460 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; | 460 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
464 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) | 464 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) |
465 | { | 465 | { |
466 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) | 466 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) |
467 | return false; | 467 | return false; |
468 | QDateTime cdt = QDateTime::currentDateTime(); | 468 | QDateTime cdt = QDateTime::currentDateTime(); |
469 | QDateTime noc; | 469 | QDateTime noc; |
470 | QString tempText; | 470 | QString tempText; |
471 | if ( appendTable && !notRed ) { | 471 | if ( appendTable && !notRed ) { |
472 | tempText = "<table>"; | 472 | tempText = "<table>"; |
473 | } | 473 | } |
474 | bool ok = true; | 474 | bool ok = true; |
475 | if ( reply ) { | 475 | if ( reply ) { |
476 | noc = ev->getNextOccurence( cdt, &ok ); | 476 | noc = ev->getNextOccurence( cdt, &ok ); |
477 | if (! ok && ev->type() == "Event") | 477 | if (! ok && ev->type() == "Event") |
478 | return false; | 478 | return false; |
479 | } | 479 | } |
480 | bool bDay = false; | 480 | bool bDay = false; |
481 | if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) | 481 | if ( ev->isBirthday() || ev->isAnniversary() ) |
482 | bDay = true; | 482 | bDay = true; |
483 | tempText += "<tr><td><b>"; | 483 | tempText += "<tr><td><b>"; |
484 | if (ev->type()=="Event") { | 484 | if (ev->type()=="Event") { |
485 | if (reply) { | 485 | if (reply) { |
486 | if (!ev->doesFloat()) | 486 | if (!ev->doesFloat()) |
487 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; | 487 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; |
488 | else | 488 | else |
489 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 489 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
490 | 490 | ||
491 | } else { | 491 | } else { |
492 | if (!ev->doesFloat()) { | 492 | if (!ev->doesFloat()) { |
493 | Event *event = static_cast<Event *>(ev); | 493 | Event *event = static_cast<Event *>(ev); |
494 | QDateTime st,end; | 494 | QDateTime st,end; |
495 | if ( event->recurrence()->doesRecur() ) { | 495 | if ( event->recurrence()->doesRecur() ) { |
496 | QDate recDate= mEventDate; | 496 | QDate recDate= mEventDate; |
497 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); | 497 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); |
498 | while ( ! event->recursOn( recDate ) ) { | 498 | while ( ! event->recursOn( recDate ) ) { |
499 | recDate = recDate.addDays( -1 ); | 499 | recDate = recDate.addDays( -1 ); |
500 | 500 | ||
501 | } | 501 | } |
502 | st = QDateTime ( recDate, event->dtStart().time() ); | 502 | st = QDateTime ( recDate, event->dtStart().time() ); |
503 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); | 503 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); |
504 | } | 504 | } |
505 | else { | 505 | else { |
506 | st = event->dtStart(); | 506 | st = event->dtStart(); |
507 | end = event->dtEnd(); | 507 | end = event->dtEnd(); |
508 | } | 508 | } |
509 | 509 | ||
510 | 510 | ||
511 | QString dateText; | 511 | QString dateText; |
512 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); | 512 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); |
513 | if ( st.date() < mEventDate ) | 513 | if ( st.date() < mEventDate ) |
514 | dateText = "++:++-"; | 514 | dateText = "++:++-"; |
515 | else | 515 | else |
516 | dateText = event->dtStartTimeStr() + "-"; | 516 | dateText = event->dtStartTimeStr() + "-"; |
517 | if ( end.date() > mEventDate ) | 517 | if ( end.date() > mEventDate ) |
518 | dateText += "++:++"; | 518 | dateText += "++:++"; |
519 | else | 519 | else |
520 | dateText += event->dtEndTimeStr(); | 520 | dateText += event->dtEndTimeStr(); |
521 | if ( notRed ) | 521 | if ( notRed ) |
522 | tempText += dateText; | 522 | tempText += dateText; |
523 | else { | 523 | else { |
524 | if ( end < cdt ) { | 524 | if ( end < cdt ) { |
525 | if ( !KOPrefs::instance()->mWNViewShowsPast ) | 525 | if ( !KOPrefs::instance()->mWNViewShowsPast ) |
526 | return false; | 526 | return false; |
527 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; | 527 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; |
528 | } | 528 | } |
529 | else if ( st < cdt ) | 529 | else if ( st < cdt ) |
530 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; | 530 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; |
531 | else | 531 | else |
532 | tempText += dateText; | 532 | tempText += dateText; |
533 | 533 | ||
534 | } | 534 | } |
535 | 535 | ||
536 | } else { | 536 | } else { |
537 | if ( bDay ) { | 537 | if ( bDay ) { |
538 | 538 | ||
539 | if ( ev->categories().contains( i18n("Birthday") )) | 539 | if ( ev->isBirthday()) |
540 | tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>"; | 540 | tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; |
541 | else | 541 | else |
542 | tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>"; | 542 | tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; |
543 | } else { | 543 | } else { |
544 | tempText += i18n("Allday:"); | 544 | tempText += i18n("Allday:"); |
545 | } | 545 | } |
546 | 546 | ||
547 | } | 547 | } |
548 | } | 548 | } |
549 | } else { | 549 | } else { |
550 | mTodos.append( ev ); | 550 | mTodos.append( ev ); |
551 | tempText += i18n("ToDo:"); | 551 | tempText += i18n("ToDo:"); |
552 | if (reply) { | 552 | if (reply) { |
553 | tempText += " "; | 553 | tempText += " "; |
554 | if ( noc != cdt ) { | 554 | if ( noc != cdt ) { |
555 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 555 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
556 | } | 556 | } |
557 | } else { | 557 | } else { |
558 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { | 558 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { |
559 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 559 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
560 | QString dfs = KGlobal::locale()->dateFormatShort(); | 560 | QString dfs = KGlobal::locale()->dateFormatShort(); |
561 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 561 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
562 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; | 562 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; |
563 | KGlobal::locale()->setDateFormatShort(dfs); | 563 | KGlobal::locale()->setDateFormatShort(dfs); |
564 | } else { | 564 | } else { |
565 | if (!ev->doesFloat() ) | 565 | if (!ev->doesFloat() ) |
566 | if( ( (Todo*)ev)->dtDue() < cdt ) { | 566 | if( ( (Todo*)ev)->dtDue() < cdt ) { |
567 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; | 567 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; |
568 | 568 | ||
569 | 569 | ||
570 | } else | 570 | } else |
571 | tempText +=((Todo*)ev)->dtDueTimeStr(); | 571 | tempText +=((Todo*)ev)->dtDueTimeStr(); |
572 | mTodos.append( ev ); | 572 | mTodos.append( ev ); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | } | 575 | } |
576 | tempText += "</b></td><td>"; | 576 | tempText += "</b></td><td>"; |
577 | bool needClose = false; | 577 | bool needClose = false; |
578 | if ( ev->cancelled() ) { | 578 | if ( ev->cancelled() ) { |
579 | tempText += "<font color=\"#F00000\">[c"; | 579 | tempText += "<font color=\"#F00000\">[c"; |
580 | needClose =true; | 580 | needClose =true; |
581 | 581 | ||
582 | } | 582 | } |
583 | if ( ev->isAlarmEnabled() ) { | 583 | if ( ev->isAlarmEnabled() ) { |
584 | if ( !needClose) | 584 | if ( !needClose) |
585 | tempText +="["; | 585 | tempText +="["; |
586 | tempText += "a"; | 586 | tempText += "a"; |
587 | needClose =true; | 587 | needClose =true; |
588 | 588 | ||
589 | } | 589 | } |
590 | if ( ev->description().length() > 0 ) { | 590 | if ( ev->description().length() > 0 ) { |
591 | if ( !needClose) | 591 | if ( !needClose) |
592 | tempText +="["; | 592 | tempText +="["; |
593 | tempText += "i"; | 593 | tempText += "i"; |
594 | needClose =true; | 594 | needClose =true; |
595 | } | 595 | } |
596 | if ( ev->recurrence()->doesRecur() ) { | 596 | if ( ev->recurrence()->doesRecur() ) { |
597 | if ( !needClose) | 597 | if ( !needClose) |
598 | tempText +="["; | 598 | tempText +="["; |
599 | tempText += "r"; | 599 | tempText += "r"; |
600 | needClose =true; | 600 | needClose =true; |
601 | } | 601 | } |
602 | if ( needClose ) { | 602 | if ( needClose ) { |
603 | tempText += "] "; | 603 | tempText += "] "; |
604 | } | 604 | } |
605 | if ( ev->cancelled() ) | 605 | if ( ev->cancelled() ) |
606 | tempText += "</font>"; | 606 | tempText += "</font>"; |
607 | tempText += "<a "; | 607 | tempText += "<a "; |
608 | if (ev->type()=="Event") tempText += "href=\"event:"; | 608 | if (ev->type()=="Event") tempText += "href=\"event:"; |
609 | if (ev->type()=="Todo") tempText += "href=\"todo:"; | 609 | if (ev->type()=="Todo") tempText += "href=\"todo:"; |
610 | tempText += ev->uid() + "\">"; | 610 | tempText += ev->uid() + "\">"; |
611 | if ( ev->summary().length() > 0 ) | 611 | if ( ev->summary().length() > 0 ) |
612 | tempText += ev->summary(); | 612 | tempText += ev->summary(); |
613 | else | 613 | else |
614 | tempText += i18n("-no summary-"); | 614 | tempText += i18n("-no summary-"); |
615 | if ( bDay ) { | 615 | if ( bDay ) { |
616 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); | 616 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); |
617 | if ( ok ) { | 617 | if ( ok ) { |
618 | int years = 0; | 618 | int years = 0; |
619 | if ( ev->type() =="Todo" ) { | 619 | if ( ev->type() =="Todo" ) { |
620 | years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); | 620 | years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); |
621 | } else | 621 | } else |
622 | years = noc.date().year() - ev->dtStart().date().year(); | 622 | years = noc.date().year() - ev->dtStart().date().year(); |
623 | tempText += i18n(" (%1 y.)"). arg( years ); | 623 | tempText += i18n(" (%1 y.)"). arg( years ); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | tempText += "</a>"; | 627 | tempText += "</a>"; |
628 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 628 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
629 | if ( !ev->location().isEmpty() ) | 629 | if ( !ev->location().isEmpty() ) |
630 | tempText += " ("+ev->location() +")"; | 630 | tempText += " ("+ev->location() +")"; |
631 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) | 631 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) |
632 | tempText += " ["+ev->relatedTo()->summary() +"]"; | 632 | tempText += " ["+ev->relatedTo()->summary() +"]"; |
633 | tempText += "</td></tr>\n"; | 633 | tempText += "</td></tr>\n"; |
634 | mText += tempText; | 634 | mText += tempText; |
635 | return true; | 635 | return true; |
636 | } | 636 | } |
637 | 637 | ||
638 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | 638 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) |
639 | { | 639 | { |
640 | if ( mTodos.find( ev ) != mTodos.end() ) return false; | 640 | if ( mTodos.find( ev ) != mTodos.end() ) return false; |
641 | 641 | ||
642 | mTodos.append( ev ); | 642 | mTodos.append( ev ); |
643 | if ( !isSub ) | 643 | if ( !isSub ) |
644 | mText += "<p>"; | 644 | mText += "<p>"; |
645 | else | 645 | else |
646 | mText += "<li>"; | 646 | mText += "<li>"; |
647 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; | 647 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; |
648 | 648 | ||
649 | 649 | ||
650 | mText += ind; | 650 | mText += ind; |
651 | bool needClose = false; | 651 | bool needClose = false; |
652 | if ( ev->cancelled() ) { | 652 | if ( ev->cancelled() ) { |
653 | mText += "<font color=\"#F00000\">[c"; | 653 | mText += "<font color=\"#F00000\">[c"; |
654 | needClose =true; | 654 | needClose =true; |
655 | 655 | ||
656 | } | 656 | } |
657 | if ( ev->isAlarmEnabled() ) { | 657 | if ( ev->isAlarmEnabled() ) { |
658 | if ( !needClose) | 658 | if ( !needClose) |
659 | mText +="["; | 659 | mText +="["; |
660 | mText += "a"; | 660 | mText += "a"; |
661 | needClose =true; | 661 | needClose =true; |
662 | 662 | ||
663 | } | 663 | } |
664 | 664 | ||
665 | if ( ev->description().length() > 0 ) { | 665 | if ( ev->description().length() > 0 ) { |
666 | if ( !needClose) | 666 | if ( !needClose) |
667 | mText +="["; | 667 | mText +="["; |
668 | mText += "i"; | 668 | mText += "i"; |
669 | needClose =true; | 669 | needClose =true; |
670 | } | 670 | } |
671 | if ( ev->doesRecur() ) { | 671 | if ( ev->doesRecur() ) { |
672 | if ( !needClose) | 672 | if ( !needClose) |
673 | mText +="["; | 673 | mText +="["; |
674 | mText += "r"; | 674 | mText += "r"; |
675 | needClose =true; | 675 | needClose =true; |
676 | } | 676 | } |
677 | // if ( ev->recurrence()->doesRecur() ) { | 677 | // if ( ev->recurrence()->doesRecur() ) { |
678 | // if ( !needClose) | 678 | // if ( !needClose) |
679 | // mText +="("; | 679 | // mText +="("; |
680 | // mText += "r"; | 680 | // mText += "r"; |
681 | // needClose =true; | 681 | // needClose =true; |
682 | // } | 682 | // } |
683 | if ( needClose ) | 683 | if ( needClose ) |
684 | mText += "] "; | 684 | mText += "] "; |
685 | if ( ev->cancelled() ) | 685 | if ( ev->cancelled() ) |
686 | mText += "</font>"; | 686 | mText += "</font>"; |
687 | mText += "<a href=\"todo:" + ev->uid() + "\">"; | 687 | mText += "<a href=\"todo:" + ev->uid() + "\">"; |
688 | if ( ev->summary().length() > 0 ) | 688 | if ( ev->summary().length() > 0 ) |
689 | mText += ev->summary(); | 689 | mText += ev->summary(); |
690 | else | 690 | else |
691 | mText += i18n("-no summary-"); | 691 | mText += i18n("-no summary-"); |
692 | mText += "</a>"; | 692 | mText += "</a>"; |
693 | if ( ((Todo*)ev)->hasDueDate () ) { | 693 | if ( ((Todo*)ev)->hasDueDate () ) { |
694 | QString year = ""; | 694 | QString year = ""; |
695 | int ye = ((Todo*)ev)->dtDue().date().year(); | 695 | int ye = ((Todo*)ev)->dtDue().date().year(); |
696 | if ( QDateTime::currentDateTime().date().year() != ye ) | 696 | if ( QDateTime::currentDateTime().date().year() != ye ) |
697 | year = QString::number( ye ); | 697 | year = QString::number( ye ); |
698 | QString dfs = KGlobal::locale()->dateFormatShort(); | 698 | QString dfs = KGlobal::locale()->dateFormatShort(); |
699 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 699 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
700 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; | 700 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
701 | KGlobal::locale()->setDateFormatShort(dfs); | 701 | KGlobal::locale()->setDateFormatShort(dfs); |
702 | } | 702 | } |
703 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 703 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
704 | if ( !ev->location().isEmpty() ) | 704 | if ( !ev->location().isEmpty() ) |
705 | mText += " ("+ev->location() +")"; | 705 | mText += " ("+ev->location() +")"; |
706 | if ( !isSub ) { | 706 | if ( !isSub ) { |
707 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 707 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
708 | mText += " ["+ev->relatedTo()->summary() +"]"; | 708 | mText += " ["+ev->relatedTo()->summary() +"]"; |
709 | mText += "</p>\n"; | 709 | mText += "</p>\n"; |
710 | } | 710 | } |
711 | else { | 711 | else { |
712 | ind += "-"; | 712 | ind += "-"; |
713 | mText += "</li>\n"; | 713 | mText += "</li>\n"; |
714 | } | 714 | } |
715 | QPtrList<Incidence> Relations = ev->relations(); | 715 | QPtrList<Incidence> Relations = ev->relations(); |
716 | Incidence *to; | 716 | Incidence *to; |
717 | for (to=Relations.first();to;to=Relations.next()) { | 717 | for (to=Relations.first();to;to=Relations.next()) { |
718 | if (!((Todo*)to)->isCompleted()) | 718 | if (!((Todo*)to)->isCompleted()) |
719 | appendTodo( to, ind , true ); | 719 | appendTodo( to, ind , true ); |
720 | } | 720 | } |
721 | 721 | ||
722 | return true; | 722 | return true; |
723 | } | 723 | } |
724 | 724 | ||
725 | /* | 725 | /* |
726 | void KOWhatsNextView::createEventViewer() | 726 | void KOWhatsNextView::createEventViewer() |
727 | { | 727 | { |
728 | if (!mEventViewer) { | 728 | if (!mEventViewer) { |
729 | 729 | ||
730 | mEventViewer = new KOEventViewerDialog(this); | 730 | mEventViewer = new KOEventViewerDialog(this); |
731 | } | 731 | } |
732 | } | 732 | } |
733 | */ | 733 | */ |
734 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) | 734 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) |
735 | { | 735 | { |
736 | mEventViewer = v; | 736 | mEventViewer = v; |
737 | } | 737 | } |
738 | 738 | ||
739 | // TODO: Create this function in CalendarView and remove it from here | 739 | // TODO: Create this function in CalendarView and remove it from here |
740 | void KOWhatsNextView::showIncidence(const QString &uid) | 740 | void KOWhatsNextView::showIncidence(const QString &uid) |
741 | { | 741 | { |
742 | 742 | ||
743 | if ( !mEventViewer ) { | 743 | if ( !mEventViewer ) { |
744 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); | 744 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); |
745 | return; | 745 | return; |
746 | } | 746 | } |
747 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; | 747 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; |
748 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); | 748 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); |
749 | if (uid.startsWith("event:")) { | 749 | if (uid.startsWith("event:")) { |
750 | #ifdef DESKTOP_VERSION | 750 | #ifdef DESKTOP_VERSION |
751 | Event *event = calendar()->event(uid.mid(8)); | 751 | Event *event = calendar()->event(uid.mid(8)); |
752 | #else | 752 | #else |
753 | Event *event = calendar()->event(uid.mid(6)); | 753 | Event *event = calendar()->event(uid.mid(6)); |
754 | #endif | 754 | #endif |
755 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); | 755 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); |
756 | if (!event) return; | 756 | if (!event) return; |
757 | //createEventViewer(); | 757 | //createEventViewer(); |
758 | mEventViewer->setEvent(event); | 758 | mEventViewer->setEvent(event); |
759 | } else if (uid.startsWith("todo:")) { | 759 | } else if (uid.startsWith("todo:")) { |
760 | #ifdef DESKTOP_VERSION | 760 | #ifdef DESKTOP_VERSION |
761 | Todo *todo = calendar()->todo(uid.mid(7)); | 761 | Todo *todo = calendar()->todo(uid.mid(7)); |
762 | #else | 762 | #else |
763 | Todo *todo = calendar()->todo(uid.mid(5)); | 763 | Todo *todo = calendar()->todo(uid.mid(5)); |
764 | #endif | 764 | #endif |
765 | if (!todo) return; | 765 | if (!todo) return; |
766 | //createEventViewer(); | 766 | //createEventViewer(); |
767 | mEventViewer->setTodo(todo); | 767 | mEventViewer->setTodo(todo); |
768 | } else { | 768 | } else { |
769 | return; | 769 | return; |
770 | 770 | ||
771 | } | 771 | } |
772 | mEventViewer->showMe(); | 772 | mEventViewer->showMe(); |
773 | mEventViewer->raise(); | 773 | mEventViewer->raise(); |
774 | } | 774 | } |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 708ee6b..9a36939 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,666 +1,696 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = new Recurrence(this); | 36 | mRecurrence = new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | mHoliday = false; | ||
44 | mBirthday = false; | ||
45 | mAnniversary = false; | ||
46 | |||
43 | } | 47 | } |
44 | 48 | ||
45 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
46 | { | 50 | { |
47 | // TODO: reenable attributes currently commented out. | 51 | // TODO: reenable attributes currently commented out. |
48 | mRevision = i.mRevision; | 52 | mRevision = i.mRevision; |
49 | mCreated = i.mCreated; | 53 | mCreated = i.mCreated; |
50 | mDescription = i.mDescription; | 54 | mDescription = i.mDescription; |
51 | mSummary = i.mSummary; | 55 | mSummary = i.mSummary; |
52 | mCategories = i.mCategories; | 56 | mCategories = i.mCategories; |
53 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
54 | mRelatedTo = 0; | 58 | mRelatedTo = 0; |
55 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
56 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
57 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
58 | mAttachments = i.mAttachments; | 62 | mAttachments = i.mAttachments; |
59 | mResources = i.mResources; | 63 | mResources = i.mResources; |
60 | mSecrecy = i.mSecrecy; | 64 | mSecrecy = i.mSecrecy; |
61 | mPriority = i.mPriority; | 65 | mPriority = i.mPriority; |
62 | mLocation = i.mLocation; | 66 | mLocation = i.mLocation; |
63 | mCancelled = i.mCancelled; | 67 | mCancelled = i.mCancelled; |
64 | mHasStartDate = i.mHasStartDate; | 68 | mHasStartDate = i.mHasStartDate; |
65 | QPtrListIterator<Alarm> it( i.mAlarms ); | 69 | QPtrListIterator<Alarm> it( i.mAlarms ); |
66 | const Alarm *a; | 70 | const Alarm *a; |
67 | while( (a = it.current()) ) { | 71 | while( (a = it.current()) ) { |
68 | Alarm *b = new Alarm( *a ); | 72 | Alarm *b = new Alarm( *a ); |
69 | b->setParent( this ); | 73 | b->setParent( this ); |
70 | mAlarms.append( b ); | 74 | mAlarms.append( b ); |
71 | 75 | ||
72 | ++it; | 76 | ++it; |
73 | } | 77 | } |
74 | mAlarms.setAutoDelete(true); | 78 | mAlarms.setAutoDelete(true); |
75 | mHasRecurrenceID = i.mHasRecurrenceID; | 79 | mHasRecurrenceID = i.mHasRecurrenceID; |
76 | mRecurrenceID = i.mRecurrenceID; | 80 | mRecurrenceID = i.mRecurrenceID; |
77 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 81 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
82 | mHoliday = i.mHoliday ; | ||
83 | mBirthday = i.mBirthday; | ||
84 | mAnniversary = i.mAnniversary; | ||
78 | } | 85 | } |
79 | 86 | ||
80 | Incidence::~Incidence() | 87 | Incidence::~Incidence() |
81 | { | 88 | { |
82 | 89 | ||
83 | Incidence *ev; | 90 | Incidence *ev; |
84 | QPtrList<Incidence> Relations = relations(); | 91 | QPtrList<Incidence> Relations = relations(); |
85 | for (ev=Relations.first();ev;ev=Relations.next()) { | 92 | for (ev=Relations.first();ev;ev=Relations.next()) { |
86 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 93 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
87 | } | 94 | } |
88 | if (relatedTo()) relatedTo()->removeRelation(this); | 95 | if (relatedTo()) relatedTo()->removeRelation(this); |
89 | delete mRecurrence; | 96 | delete mRecurrence; |
90 | 97 | ||
91 | } | 98 | } |
99 | |||
100 | bool Incidence::isHoliday() const | ||
101 | { | ||
102 | return mHoliday; | ||
103 | } | ||
104 | bool Incidence::isBirthday() const | ||
105 | { | ||
106 | |||
107 | return mBirthday ; | ||
108 | } | ||
109 | bool Incidence::isAnniversary() const | ||
110 | { | ||
111 | return mAnniversary ; | ||
112 | |||
113 | } | ||
114 | |||
92 | bool Incidence::hasRecurrenceID() const | 115 | bool Incidence::hasRecurrenceID() const |
93 | { | 116 | { |
94 | return mHasRecurrenceID; | 117 | return mHasRecurrenceID; |
95 | } | 118 | } |
96 | 119 | ||
97 | void Incidence::setHasRecurrenceID( bool b ) | 120 | void Incidence::setHasRecurrenceID( bool b ) |
98 | { | 121 | { |
99 | mHasRecurrenceID = b; | 122 | mHasRecurrenceID = b; |
100 | } | 123 | } |
101 | 124 | ||
102 | void Incidence::setRecurrenceID(QDateTime d) | 125 | void Incidence::setRecurrenceID(QDateTime d) |
103 | { | 126 | { |
104 | mRecurrenceID = d; | 127 | mRecurrenceID = d; |
105 | mHasRecurrenceID = true; | 128 | mHasRecurrenceID = true; |
106 | updated(); | 129 | updated(); |
107 | } | 130 | } |
108 | QDateTime Incidence::recurrenceID () const | 131 | QDateTime Incidence::recurrenceID () const |
109 | { | 132 | { |
110 | return mRecurrenceID; | 133 | return mRecurrenceID; |
111 | } | 134 | } |
112 | 135 | ||
113 | bool Incidence::cancelled() const | 136 | bool Incidence::cancelled() const |
114 | { | 137 | { |
115 | return mCancelled; | 138 | return mCancelled; |
116 | } | 139 | } |
117 | void Incidence::setCancelled( bool b ) | 140 | void Incidence::setCancelled( bool b ) |
118 | { | 141 | { |
119 | mCancelled = b; | 142 | mCancelled = b; |
120 | updated(); | 143 | updated(); |
121 | } | 144 | } |
122 | bool Incidence::hasStartDate() const | 145 | bool Incidence::hasStartDate() const |
123 | { | 146 | { |
124 | return mHasStartDate; | 147 | return mHasStartDate; |
125 | } | 148 | } |
126 | 149 | ||
127 | void Incidence::setHasStartDate(bool f) | 150 | void Incidence::setHasStartDate(bool f) |
128 | { | 151 | { |
129 | if (mReadOnly) return; | 152 | if (mReadOnly) return; |
130 | mHasStartDate = f; | 153 | mHasStartDate = f; |
131 | updated(); | 154 | updated(); |
132 | } | 155 | } |
133 | 156 | ||
134 | // A string comparison that considers that null and empty are the same | 157 | // A string comparison that considers that null and empty are the same |
135 | static bool stringCompare( const QString& s1, const QString& s2 ) | 158 | static bool stringCompare( const QString& s1, const QString& s2 ) |
136 | { | 159 | { |
137 | if ( s1.isEmpty() && s2.isEmpty() ) | 160 | if ( s1.isEmpty() && s2.isEmpty() ) |
138 | return true; | 161 | return true; |
139 | return s1 == s2; | 162 | return s1 == s2; |
140 | } | 163 | } |
141 | 164 | ||
142 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 165 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
143 | { | 166 | { |
144 | 167 | ||
145 | if( i1.alarms().count() != i2.alarms().count() ) { | 168 | if( i1.alarms().count() != i2.alarms().count() ) { |
146 | return false; // no need to check further | 169 | return false; // no need to check further |
147 | } | 170 | } |
148 | if ( i1.alarms().count() > 0 ) { | 171 | if ( i1.alarms().count() > 0 ) { |
149 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
150 | { | 173 | { |
151 | qDebug("alarm not equal "); | 174 | qDebug("alarm not equal "); |
152 | return false; | 175 | return false; |
153 | } | 176 | } |
154 | } | 177 | } |
155 | #if 0 | 178 | #if 0 |
156 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 179 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
157 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 180 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
158 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
159 | if( *a1.current() == *a2.current() ) { | 182 | if( *a1.current() == *a2.current() ) { |
160 | continue; | 183 | continue; |
161 | } | 184 | } |
162 | else { | 185 | else { |
163 | return false; | 186 | return false; |
164 | } | 187 | } |
165 | } | 188 | } |
166 | #endif | 189 | #endif |
167 | 190 | ||
168 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
169 | if ( i1.hasRecurrenceID() ) { | 192 | if ( i1.hasRecurrenceID() ) { |
170 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 193 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
171 | return false; | 194 | return false; |
172 | } | 195 | } |
173 | 196 | ||
174 | } else { | 197 | } else { |
175 | return false; | 198 | return false; |
176 | } | 199 | } |
177 | 200 | ||
178 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
179 | return false; | 202 | return false; |
180 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
181 | if ( i1.hasStartDate() ) { | 204 | if ( i1.hasStartDate() ) { |
182 | if ( i1.dtStart() != i2.dtStart() ) | 205 | if ( i1.dtStart() != i2.dtStart() ) |
183 | return false; | 206 | return false; |
184 | } | 207 | } |
185 | } else { | 208 | } else { |
186 | return false; | 209 | return false; |
187 | } | 210 | } |
188 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
189 | qDebug("recurrence is NOT equal "); | 212 | qDebug("recurrence is NOT equal "); |
190 | return false; | 213 | return false; |
191 | } | 214 | } |
192 | return | 215 | return |
193 | // i1.created() == i2.created() && | 216 | // i1.created() == i2.created() && |
194 | stringCompare( i1.description(), i2.description() ) && | 217 | stringCompare( i1.description(), i2.description() ) && |
195 | stringCompare( i1.summary(), i2.summary() ) && | 218 | stringCompare( i1.summary(), i2.summary() ) && |
196 | i1.categories() == i2.categories() && | 219 | i1.categories() == i2.categories() && |
197 | // no need to compare mRelatedTo | 220 | // no need to compare mRelatedTo |
198 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
199 | // i1.relations() == i2.relations() && | 222 | // i1.relations() == i2.relations() && |
200 | i1.exDates() == i2.exDates() && | 223 | i1.exDates() == i2.exDates() && |
201 | i1.attachments() == i2.attachments() && | 224 | i1.attachments() == i2.attachments() && |
202 | i1.resources() == i2.resources() && | 225 | i1.resources() == i2.resources() && |
203 | i1.secrecy() == i2.secrecy() && | 226 | i1.secrecy() == i2.secrecy() && |
204 | i1.priority() == i2.priority() && | 227 | i1.priority() == i2.priority() && |
205 | i1.cancelled() == i2.cancelled() && | 228 | i1.cancelled() == i2.cancelled() && |
206 | stringCompare( i1.location(), i2.location() ); | 229 | stringCompare( i1.location(), i2.location() ); |
207 | } | 230 | } |
208 | 231 | ||
209 | Incidence* Incidence::recreateCloneException( QDate d ) | 232 | Incidence* Incidence::recreateCloneException( QDate d ) |
210 | { | 233 | { |
211 | Incidence* newInc = clone(); | 234 | Incidence* newInc = clone(); |
212 | newInc->recreate(); | 235 | newInc->recreate(); |
213 | if ( doesRecur() ) { | 236 | if ( doesRecur() ) { |
214 | addExDate( d ); | 237 | addExDate( d ); |
215 | newInc->recurrence()->unsetRecurs(); | 238 | newInc->recurrence()->unsetRecurs(); |
216 | if ( type() == "Event") { | 239 | if ( type() == "Event") { |
217 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
218 | QTime tim = dtStart().time(); | 241 | QTime tim = dtStart().time(); |
219 | newInc->setDtStart( QDateTime(d, tim) ); | 242 | newInc->setDtStart( QDateTime(d, tim) ); |
220 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
221 | } else { | 244 | } else { |
222 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
223 | QTime tim = ((Todo*)this)->dtDue().time(); | 246 | QTime tim = ((Todo*)this)->dtDue().time(); |
224 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
225 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
226 | ((Todo*)this)->setRecurDates(); | 249 | ((Todo*)this)->setRecurDates(); |
227 | } | 250 | } |
228 | } | 251 | } |
229 | return newInc; | 252 | return newInc; |
230 | } | 253 | } |
231 | 254 | ||
232 | void Incidence::recreate() | 255 | void Incidence::recreate() |
233 | { | 256 | { |
234 | setCreated(QDateTime::currentDateTime()); | 257 | setCreated(QDateTime::currentDateTime()); |
235 | 258 | ||
236 | setUid(CalFormat::createUniqueId()); | 259 | setUid(CalFormat::createUniqueId()); |
237 | 260 | ||
238 | setRevision(0); | 261 | setRevision(0); |
239 | setIDStr( ":" ); | 262 | setIDStr( ":" ); |
240 | setLastModified(QDateTime::currentDateTime()); | 263 | setLastModified(QDateTime::currentDateTime()); |
241 | } | 264 | } |
242 | 265 | ||
243 | void Incidence::setReadOnly( bool readOnly ) | 266 | void Incidence::setReadOnly( bool readOnly ) |
244 | { | 267 | { |
245 | IncidenceBase::setReadOnly( readOnly ); | 268 | IncidenceBase::setReadOnly( readOnly ); |
246 | recurrence()->setRecurReadOnly( readOnly); | 269 | recurrence()->setRecurReadOnly( readOnly); |
247 | } | 270 | } |
248 | 271 | ||
249 | void Incidence::setCreated(QDateTime created) | 272 | void Incidence::setCreated(QDateTime created) |
250 | { | 273 | { |
251 | if (mReadOnly) return; | 274 | if (mReadOnly) return; |
252 | mCreated = getEvenTime(created); | 275 | mCreated = getEvenTime(created); |
253 | } | 276 | } |
254 | 277 | ||
255 | QDateTime Incidence::created() const | 278 | QDateTime Incidence::created() const |
256 | { | 279 | { |
257 | return mCreated; | 280 | return mCreated; |
258 | } | 281 | } |
259 | 282 | ||
260 | void Incidence::setRevision(int rev) | 283 | void Incidence::setRevision(int rev) |
261 | { | 284 | { |
262 | if (mReadOnly) return; | 285 | if (mReadOnly) return; |
263 | mRevision = rev; | 286 | mRevision = rev; |
264 | 287 | ||
265 | updated(); | 288 | updated(); |
266 | } | 289 | } |
267 | 290 | ||
268 | int Incidence::revision() const | 291 | int Incidence::revision() const |
269 | { | 292 | { |
270 | return mRevision; | 293 | return mRevision; |
271 | } | 294 | } |
272 | 295 | ||
273 | void Incidence::setDtStart(const QDateTime &dtStart) | 296 | void Incidence::setDtStart(const QDateTime &dtStart) |
274 | { | 297 | { |
275 | 298 | ||
276 | QDateTime dt = getEvenTime(dtStart); | 299 | QDateTime dt = getEvenTime(dtStart); |
277 | recurrence()->setRecurStart( dt); | 300 | recurrence()->setRecurStart( dt); |
278 | IncidenceBase::setDtStart( dt ); | 301 | IncidenceBase::setDtStart( dt ); |
279 | } | 302 | } |
280 | 303 | ||
281 | void Incidence::setDescription(const QString &description) | 304 | void Incidence::setDescription(const QString &description) |
282 | { | 305 | { |
283 | if (mReadOnly) return; | 306 | if (mReadOnly) return; |
284 | mDescription = description; | 307 | mDescription = description; |
285 | updated(); | 308 | updated(); |
286 | } | 309 | } |
287 | 310 | ||
288 | QString Incidence::description() const | 311 | QString Incidence::description() const |
289 | { | 312 | { |
290 | return mDescription; | 313 | return mDescription; |
291 | } | 314 | } |
292 | 315 | ||
293 | 316 | ||
294 | void Incidence::setSummary(const QString &summary) | 317 | void Incidence::setSummary(const QString &summary) |
295 | { | 318 | { |
296 | if (mReadOnly) return; | 319 | if (mReadOnly) return; |
297 | mSummary = summary; | 320 | mSummary = summary; |
298 | updated(); | 321 | updated(); |
299 | } | 322 | } |
300 | 323 | ||
301 | QString Incidence::summary() const | 324 | QString Incidence::summary() const |
302 | { | 325 | { |
303 | return mSummary; | 326 | return mSummary; |
304 | } | 327 | } |
328 | void Incidence::checkCategories() | ||
329 | { | ||
330 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | ||
331 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | ||
332 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | ||
333 | } | ||
305 | 334 | ||
306 | void Incidence::setCategories(const QStringList &categories) | 335 | void Incidence::setCategories(const QStringList &categories) |
307 | { | 336 | { |
308 | if (mReadOnly) return; | 337 | if (mReadOnly) return; |
309 | mCategories = categories; | 338 | mCategories = categories; |
339 | checkCategories(); | ||
310 | updated(); | 340 | updated(); |
311 | } | 341 | } |
312 | 342 | ||
313 | // TODO: remove setCategories(QString) function | 343 | // TODO: remove setCategories(QString) function |
314 | void Incidence::setCategories(const QString &catStr) | 344 | void Incidence::setCategories(const QString &catStr) |
315 | { | 345 | { |
316 | if (mReadOnly) return; | 346 | if (mReadOnly) return; |
317 | mCategories.clear(); | 347 | mCategories.clear(); |
318 | 348 | ||
319 | if (catStr.isEmpty()) return; | 349 | if (catStr.isEmpty()) return; |
320 | 350 | ||
321 | mCategories = QStringList::split(",",catStr); | 351 | mCategories = QStringList::split(",",catStr); |
322 | 352 | ||
323 | QStringList::Iterator it; | 353 | QStringList::Iterator it; |
324 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 354 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
325 | *it = (*it).stripWhiteSpace(); | 355 | *it = (*it).stripWhiteSpace(); |
326 | } | 356 | } |
327 | 357 | checkCategories(); | |
328 | updated(); | 358 | updated(); |
329 | } | 359 | } |
330 | 360 | ||
331 | QStringList Incidence::categories() const | 361 | QStringList Incidence::categories() const |
332 | { | 362 | { |
333 | return mCategories; | 363 | return mCategories; |
334 | } | 364 | } |
335 | 365 | ||
336 | QString Incidence::categoriesStr() | 366 | QString Incidence::categoriesStr() |
337 | { | 367 | { |
338 | return mCategories.join(","); | 368 | return mCategories.join(","); |
339 | } | 369 | } |
340 | 370 | ||
341 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 371 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
342 | { | 372 | { |
343 | if (mReadOnly) return; | 373 | if (mReadOnly) return; |
344 | mRelatedToUid = relatedToUid; | 374 | mRelatedToUid = relatedToUid; |
345 | } | 375 | } |
346 | 376 | ||
347 | QString Incidence::relatedToUid() const | 377 | QString Incidence::relatedToUid() const |
348 | { | 378 | { |
349 | return mRelatedToUid; | 379 | return mRelatedToUid; |
350 | } | 380 | } |
351 | 381 | ||
352 | void Incidence::setRelatedTo(Incidence *relatedTo) | 382 | void Incidence::setRelatedTo(Incidence *relatedTo) |
353 | { | 383 | { |
354 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 384 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
355 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 385 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
356 | if (mReadOnly || mRelatedTo == relatedTo) return; | 386 | if (mReadOnly || mRelatedTo == relatedTo) return; |
357 | if(mRelatedTo) { | 387 | if(mRelatedTo) { |
358 | // updated(); | 388 | // updated(); |
359 | mRelatedTo->removeRelation(this); | 389 | mRelatedTo->removeRelation(this); |
360 | } | 390 | } |
361 | mRelatedTo = relatedTo; | 391 | mRelatedTo = relatedTo; |
362 | if (mRelatedTo) mRelatedTo->addRelation(this); | 392 | if (mRelatedTo) mRelatedTo->addRelation(this); |
363 | } | 393 | } |
364 | 394 | ||
365 | Incidence *Incidence::relatedTo() const | 395 | Incidence *Incidence::relatedTo() const |
366 | { | 396 | { |
367 | return mRelatedTo; | 397 | return mRelatedTo; |
368 | } | 398 | } |
369 | 399 | ||
370 | QPtrList<Incidence> Incidence::relations() const | 400 | QPtrList<Incidence> Incidence::relations() const |
371 | { | 401 | { |
372 | return mRelations; | 402 | return mRelations; |
373 | } | 403 | } |
374 | 404 | ||
375 | void Incidence::addRelation(Incidence *event) | 405 | void Incidence::addRelation(Incidence *event) |
376 | { | 406 | { |
377 | if( mRelations.findRef( event ) == -1 ) { | 407 | if( mRelations.findRef( event ) == -1 ) { |
378 | mRelations.append(event); | 408 | mRelations.append(event); |
379 | //updated(); | 409 | //updated(); |
380 | } | 410 | } |
381 | } | 411 | } |
382 | 412 | ||
383 | void Incidence::removeRelation(Incidence *event) | 413 | void Incidence::removeRelation(Incidence *event) |
384 | { | 414 | { |
385 | 415 | ||
386 | mRelations.removeRef(event); | 416 | mRelations.removeRef(event); |
387 | 417 | ||
388 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 418 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
389 | } | 419 | } |
390 | 420 | ||
391 | bool Incidence::recursOn(const QDate &qd) const | 421 | bool Incidence::recursOn(const QDate &qd) const |
392 | { | 422 | { |
393 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 423 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
394 | else return false; | 424 | else return false; |
395 | } | 425 | } |
396 | 426 | ||
397 | void Incidence::setExDates(const DateList &exDates) | 427 | void Incidence::setExDates(const DateList &exDates) |
398 | { | 428 | { |
399 | if (mReadOnly) return; | 429 | if (mReadOnly) return; |
400 | mExDates = exDates; | 430 | mExDates = exDates; |
401 | 431 | ||
402 | recurrence()->setRecurExDatesCount(mExDates.count()); | 432 | recurrence()->setRecurExDatesCount(mExDates.count()); |
403 | 433 | ||
404 | updated(); | 434 | updated(); |
405 | } | 435 | } |
406 | 436 | ||
407 | void Incidence::addExDate(const QDate &date) | 437 | void Incidence::addExDate(const QDate &date) |
408 | { | 438 | { |
409 | if (mReadOnly) return; | 439 | if (mReadOnly) return; |
410 | mExDates.append(date); | 440 | mExDates.append(date); |
411 | 441 | ||
412 | recurrence()->setRecurExDatesCount(mExDates.count()); | 442 | recurrence()->setRecurExDatesCount(mExDates.count()); |
413 | 443 | ||
414 | updated(); | 444 | updated(); |
415 | } | 445 | } |
416 | 446 | ||
417 | DateList Incidence::exDates() const | 447 | DateList Incidence::exDates() const |
418 | { | 448 | { |
419 | return mExDates; | 449 | return mExDates; |
420 | } | 450 | } |
421 | 451 | ||
422 | bool Incidence::isException(const QDate &date) const | 452 | bool Incidence::isException(const QDate &date) const |
423 | { | 453 | { |
424 | DateList::ConstIterator it; | 454 | DateList::ConstIterator it; |
425 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 455 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
426 | if ( (*it) == date ) { | 456 | if ( (*it) == date ) { |
427 | return true; | 457 | return true; |
428 | } | 458 | } |
429 | } | 459 | } |
430 | 460 | ||
431 | return false; | 461 | return false; |
432 | } | 462 | } |
433 | 463 | ||
434 | void Incidence::addAttachment(Attachment *attachment) | 464 | void Incidence::addAttachment(Attachment *attachment) |
435 | { | 465 | { |
436 | if (mReadOnly || !attachment) return; | 466 | if (mReadOnly || !attachment) return; |
437 | mAttachments.append(attachment); | 467 | mAttachments.append(attachment); |
438 | updated(); | 468 | updated(); |
439 | } | 469 | } |
440 | 470 | ||
441 | void Incidence::deleteAttachment(Attachment *attachment) | 471 | void Incidence::deleteAttachment(Attachment *attachment) |
442 | { | 472 | { |
443 | mAttachments.removeRef(attachment); | 473 | mAttachments.removeRef(attachment); |
444 | } | 474 | } |
445 | 475 | ||
446 | void Incidence::deleteAttachments(const QString& mime) | 476 | void Incidence::deleteAttachments(const QString& mime) |
447 | { | 477 | { |
448 | Attachment *at = mAttachments.first(); | 478 | Attachment *at = mAttachments.first(); |
449 | while (at) { | 479 | while (at) { |
450 | if (at->mimeType() == mime) | 480 | if (at->mimeType() == mime) |
451 | mAttachments.remove(); | 481 | mAttachments.remove(); |
452 | else | 482 | else |
453 | at = mAttachments.next(); | 483 | at = mAttachments.next(); |
454 | } | 484 | } |
455 | } | 485 | } |
456 | 486 | ||
457 | QPtrList<Attachment> Incidence::attachments() const | 487 | QPtrList<Attachment> Incidence::attachments() const |
458 | { | 488 | { |
459 | return mAttachments; | 489 | return mAttachments; |
460 | } | 490 | } |
461 | 491 | ||
462 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 492 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
463 | { | 493 | { |
464 | QPtrList<Attachment> attachments; | 494 | QPtrList<Attachment> attachments; |
465 | QPtrListIterator<Attachment> it( mAttachments ); | 495 | QPtrListIterator<Attachment> it( mAttachments ); |
466 | Attachment *at; | 496 | Attachment *at; |
467 | while ( (at = it.current()) ) { | 497 | while ( (at = it.current()) ) { |
468 | if (at->mimeType() == mime) | 498 | if (at->mimeType() == mime) |
469 | attachments.append(at); | 499 | attachments.append(at); |
470 | ++it; | 500 | ++it; |
471 | } | 501 | } |
472 | 502 | ||
473 | return attachments; | 503 | return attachments; |
474 | } | 504 | } |
475 | 505 | ||
476 | void Incidence::setResources(const QStringList &resources) | 506 | void Incidence::setResources(const QStringList &resources) |
477 | { | 507 | { |
478 | if (mReadOnly) return; | 508 | if (mReadOnly) return; |
479 | mResources = resources; | 509 | mResources = resources; |
480 | updated(); | 510 | updated(); |
481 | } | 511 | } |
482 | 512 | ||
483 | QStringList Incidence::resources() const | 513 | QStringList Incidence::resources() const |
484 | { | 514 | { |
485 | return mResources; | 515 | return mResources; |
486 | } | 516 | } |
487 | 517 | ||
488 | 518 | ||
489 | void Incidence::setPriority(int priority) | 519 | void Incidence::setPriority(int priority) |
490 | { | 520 | { |
491 | if (mReadOnly) return; | 521 | if (mReadOnly) return; |
492 | mPriority = priority; | 522 | mPriority = priority; |
493 | updated(); | 523 | updated(); |
494 | } | 524 | } |
495 | 525 | ||
496 | int Incidence::priority() const | 526 | int Incidence::priority() const |
497 | { | 527 | { |
498 | return mPriority; | 528 | return mPriority; |
499 | } | 529 | } |
500 | 530 | ||
501 | void Incidence::setSecrecy(int sec) | 531 | void Incidence::setSecrecy(int sec) |
502 | { | 532 | { |
503 | if (mReadOnly) return; | 533 | if (mReadOnly) return; |
504 | mSecrecy = sec; | 534 | mSecrecy = sec; |
505 | updated(); | 535 | updated(); |
506 | } | 536 | } |
507 | 537 | ||
508 | int Incidence::secrecy() const | 538 | int Incidence::secrecy() const |
509 | { | 539 | { |
510 | return mSecrecy; | 540 | return mSecrecy; |
511 | } | 541 | } |
512 | 542 | ||
513 | QString Incidence::secrecyStr() const | 543 | QString Incidence::secrecyStr() const |
514 | { | 544 | { |
515 | return secrecyName(mSecrecy); | 545 | return secrecyName(mSecrecy); |
516 | } | 546 | } |
517 | 547 | ||
518 | QString Incidence::secrecyName(int secrecy) | 548 | QString Incidence::secrecyName(int secrecy) |
519 | { | 549 | { |
520 | switch (secrecy) { | 550 | switch (secrecy) { |
521 | case SecrecyPublic: | 551 | case SecrecyPublic: |
522 | return i18n("Public"); | 552 | return i18n("Public"); |
523 | break; | 553 | break; |
524 | case SecrecyPrivate: | 554 | case SecrecyPrivate: |
525 | return i18n("Private"); | 555 | return i18n("Private"); |
526 | break; | 556 | break; |
527 | case SecrecyConfidential: | 557 | case SecrecyConfidential: |
528 | return i18n("Confidential"); | 558 | return i18n("Confidential"); |
529 | break; | 559 | break; |
530 | default: | 560 | default: |
531 | return i18n("Undefined"); | 561 | return i18n("Undefined"); |
532 | break; | 562 | break; |
533 | } | 563 | } |
534 | } | 564 | } |
535 | 565 | ||
536 | QStringList Incidence::secrecyList() | 566 | QStringList Incidence::secrecyList() |
537 | { | 567 | { |
538 | QStringList list; | 568 | QStringList list; |
539 | list << secrecyName(SecrecyPublic); | 569 | list << secrecyName(SecrecyPublic); |
540 | list << secrecyName(SecrecyPrivate); | 570 | list << secrecyName(SecrecyPrivate); |
541 | list << secrecyName(SecrecyConfidential); | 571 | list << secrecyName(SecrecyConfidential); |
542 | 572 | ||
543 | return list; | 573 | return list; |
544 | } | 574 | } |
545 | 575 | ||
546 | 576 | ||
547 | QPtrList<Alarm> Incidence::alarms() const | 577 | QPtrList<Alarm> Incidence::alarms() const |
548 | { | 578 | { |
549 | return mAlarms; | 579 | return mAlarms; |
550 | } | 580 | } |
551 | 581 | ||
552 | Alarm* Incidence::newAlarm() | 582 | Alarm* Incidence::newAlarm() |
553 | { | 583 | { |
554 | Alarm* alarm = new Alarm(this); | 584 | Alarm* alarm = new Alarm(this); |
555 | mAlarms.append(alarm); | 585 | mAlarms.append(alarm); |
556 | // updated(); | 586 | // updated(); |
557 | return alarm; | 587 | return alarm; |
558 | } | 588 | } |
559 | 589 | ||
560 | void Incidence::addAlarm(Alarm *alarm) | 590 | void Incidence::addAlarm(Alarm *alarm) |
561 | { | 591 | { |
562 | mAlarms.append(alarm); | 592 | mAlarms.append(alarm); |
563 | updated(); | 593 | updated(); |
564 | } | 594 | } |
565 | 595 | ||
566 | void Incidence::removeAlarm(Alarm *alarm) | 596 | void Incidence::removeAlarm(Alarm *alarm) |
567 | { | 597 | { |
568 | mAlarms.removeRef(alarm); | 598 | mAlarms.removeRef(alarm); |
569 | updated(); | 599 | updated(); |
570 | } | 600 | } |
571 | 601 | ||
572 | void Incidence::clearAlarms() | 602 | void Incidence::clearAlarms() |
573 | { | 603 | { |
574 | mAlarms.clear(); | 604 | mAlarms.clear(); |
575 | updated(); | 605 | updated(); |
576 | } | 606 | } |
577 | 607 | ||
578 | bool Incidence::isAlarmEnabled() const | 608 | bool Incidence::isAlarmEnabled() const |
579 | { | 609 | { |
580 | Alarm* alarm; | 610 | Alarm* alarm; |
581 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 611 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
582 | if (alarm->enabled()) | 612 | if (alarm->enabled()) |
583 | return true; | 613 | return true; |
584 | } | 614 | } |
585 | return false; | 615 | return false; |
586 | } | 616 | } |
587 | 617 | ||
588 | Recurrence *Incidence::recurrence() const | 618 | Recurrence *Incidence::recurrence() const |
589 | { | 619 | { |
590 | return mRecurrence; | 620 | return mRecurrence; |
591 | } | 621 | } |
592 | void Incidence::setRecurrence( Recurrence * r) | 622 | void Incidence::setRecurrence( Recurrence * r) |
593 | { | 623 | { |
594 | delete mRecurrence; | 624 | delete mRecurrence; |
595 | mRecurrence = r; | 625 | mRecurrence = r; |
596 | } | 626 | } |
597 | 627 | ||
598 | void Incidence::setLocation(const QString &location) | 628 | void Incidence::setLocation(const QString &location) |
599 | { | 629 | { |
600 | if (mReadOnly) return; | 630 | if (mReadOnly) return; |
601 | mLocation = location; | 631 | mLocation = location; |
602 | updated(); | 632 | updated(); |
603 | } | 633 | } |
604 | 634 | ||
605 | QString Incidence::location() const | 635 | QString Incidence::location() const |
606 | { | 636 | { |
607 | return mLocation; | 637 | return mLocation; |
608 | } | 638 | } |
609 | 639 | ||
610 | ushort Incidence::doesRecur() const | 640 | ushort Incidence::doesRecur() const |
611 | { | 641 | { |
612 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 642 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
613 | else return Recurrence::rNone; | 643 | else return Recurrence::rNone; |
614 | } | 644 | } |
615 | 645 | ||
616 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 646 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
617 | { | 647 | { |
618 | QDateTime incidenceStart = dt; | 648 | QDateTime incidenceStart = dt; |
619 | *ok = false; | 649 | *ok = false; |
620 | if ( doesRecur() ) { | 650 | if ( doesRecur() ) { |
621 | bool last; | 651 | bool last; |
622 | recurrence()->getPreviousDateTime( incidenceStart , &last ); | 652 | recurrence()->getPreviousDateTime( incidenceStart , &last ); |
623 | int count = 0; | 653 | int count = 0; |
624 | if ( !last ) { | 654 | if ( !last ) { |
625 | while ( !last ) { | 655 | while ( !last ) { |
626 | ++count; | 656 | ++count; |
627 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); | 657 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); |
628 | if ( recursOn( incidenceStart.date() ) ) { | 658 | if ( recursOn( incidenceStart.date() ) ) { |
629 | last = true; // exit while llop | 659 | last = true; // exit while llop |
630 | } else { | 660 | } else { |
631 | if ( last ) { // no alarm on last recurrence | 661 | if ( last ) { // no alarm on last recurrence |
632 | return QDateTime (); | 662 | return QDateTime (); |
633 | } | 663 | } |
634 | int year = incidenceStart.date().year(); | 664 | int year = incidenceStart.date().year(); |
635 | // workaround for bug in recurrence | 665 | // workaround for bug in recurrence |
636 | if ( count == 100 || year < 1000 || year > 5000 ) { | 666 | if ( count == 100 || year < 1000 || year > 5000 ) { |
637 | return QDateTime (); | 667 | return QDateTime (); |
638 | } | 668 | } |
639 | incidenceStart = incidenceStart.addSecs( 1 ); | 669 | incidenceStart = incidenceStart.addSecs( 1 ); |
640 | } | 670 | } |
641 | } | 671 | } |
642 | } else { | 672 | } else { |
643 | return QDateTime (); | 673 | return QDateTime (); |
644 | } | 674 | } |
645 | } else { | 675 | } else { |
646 | if ( hasStartDate () ) { | 676 | if ( hasStartDate () ) { |
647 | incidenceStart = dtStart(); | 677 | incidenceStart = dtStart(); |
648 | } | 678 | } |
649 | if ( type() =="Todo" ) { | 679 | if ( type() =="Todo" ) { |
650 | if ( ((Todo*)this)->hasDueDate() ) | 680 | if ( ((Todo*)this)->hasDueDate() ) |
651 | incidenceStart = ((Todo*)this)->dtDue(); | 681 | incidenceStart = ((Todo*)this)->dtDue(); |
652 | } | 682 | } |
653 | } | 683 | } |
654 | if ( incidenceStart > dt ) | 684 | if ( incidenceStart > dt ) |
655 | *ok = true; | 685 | *ok = true; |
656 | return incidenceStart; | 686 | return incidenceStart; |
657 | } | 687 | } |
658 | QDateTime Incidence::dtStart() const | 688 | QDateTime Incidence::dtStart() const |
659 | { | 689 | { |
660 | if ( doesRecur() ) { | 690 | if ( doesRecur() ) { |
661 | if ( type() == "Todo" ) { | 691 | if ( type() == "Todo" ) { |
662 | ((Todo*)this)->checkSetCompletedFalse(); | 692 | ((Todo*)this)->checkSetCompletedFalse(); |
663 | } | 693 | } |
664 | } | 694 | } |
665 | return mDtStart; | 695 | return mDtStart; |
666 | } | 696 | } |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 0ae9656..f8da342 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -1,309 +1,314 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef INCIDENCE_H | 20 | #ifndef INCIDENCE_H |
21 | #define INCIDENCE_H | 21 | #define INCIDENCE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | #include "recurrence.h" | 30 | #include "recurrence.h" |
31 | #include "alarm.h" | 31 | #include "alarm.h" |
32 | #include "attachment.h" | 32 | #include "attachment.h" |
33 | #include "listbase.h" | 33 | #include "listbase.h" |
34 | #include "incidencebase.h" | 34 | #include "incidencebase.h" |
35 | 35 | ||
36 | namespace KCal { | 36 | namespace KCal { |
37 | 37 | ||
38 | class Event; | 38 | class Event; |
39 | class Todo; | 39 | class Todo; |
40 | class Journal; | 40 | class Journal; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | This class provides the base class common to all calendar components. | 43 | This class provides the base class common to all calendar components. |
44 | */ | 44 | */ |
45 | class Incidence : public IncidenceBase | 45 | class Incidence : public IncidenceBase |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | /** | 48 | /** |
49 | This class provides the interface for a visitor of calendar components. It | 49 | This class provides the interface for a visitor of calendar components. It |
50 | serves as base class for concrete visitors, which implement certain actions on | 50 | serves as base class for concrete visitors, which implement certain actions on |
51 | calendar components. It allows to add functions, which operate on the concrete | 51 | calendar components. It allows to add functions, which operate on the concrete |
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | 115 | ||
116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; | 116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; |
117 | void setReadOnly( bool ); | 117 | void setReadOnly( bool ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | Recreate event. The event is made a new unique event, but already stored | 120 | Recreate event. The event is made a new unique event, but already stored |
121 | event information is preserved. Sets uniquie id, creation date, last | 121 | event information is preserved. Sets uniquie id, creation date, last |
122 | modification date and revision number. | 122 | modification date and revision number. |
123 | */ | 123 | */ |
124 | void recreate(); | 124 | void recreate(); |
125 | Incidence* recreateCloneException(QDate); | 125 | Incidence* recreateCloneException(QDate); |
126 | 126 | ||
127 | /** set creation date */ | 127 | /** set creation date */ |
128 | void setCreated(QDateTime); | 128 | void setCreated(QDateTime); |
129 | /** return time and date of creation. */ | 129 | /** return time and date of creation. */ |
130 | QDateTime created() const; | 130 | QDateTime created() const; |
131 | 131 | ||
132 | /** set the number of revisions this event has seen */ | 132 | /** set the number of revisions this event has seen */ |
133 | void setRevision(int rev); | 133 | void setRevision(int rev); |
134 | /** return the number of revisions this event has seen */ | 134 | /** return the number of revisions this event has seen */ |
135 | int revision() const; | 135 | int revision() const; |
136 | 136 | ||
137 | /** Set starting date/time. */ | 137 | /** Set starting date/time. */ |
138 | virtual void setDtStart(const QDateTime &dtStart); | 138 | virtual void setDtStart(const QDateTime &dtStart); |
139 | /** Return the incidence's ending date/time as a QDateTime. */ | 139 | /** Return the incidence's ending date/time as a QDateTime. */ |
140 | virtual QDateTime dtEnd() const { return QDateTime(); } | 140 | virtual QDateTime dtEnd() const { return QDateTime(); } |
141 | 141 | ||
142 | /** sets the event's lengthy description. */ | 142 | /** sets the event's lengthy description. */ |
143 | void setDescription(const QString &description); | 143 | void setDescription(const QString &description); |
144 | /** returns a reference to the event's description. */ | 144 | /** returns a reference to the event's description. */ |
145 | QString description() const; | 145 | QString description() const; |
146 | 146 | ||
147 | /** sets the event's short summary. */ | 147 | /** sets the event's short summary. */ |
148 | void setSummary(const QString &summary); | 148 | void setSummary(const QString &summary); |
149 | /** returns a reference to the event's summary. */ | 149 | /** returns a reference to the event's summary. */ |
150 | QString summary() const; | 150 | QString summary() const; |
151 | 151 | ||
152 | /** set event's applicable categories */ | 152 | /** set event's applicable categories */ |
153 | void setCategories(const QStringList &categories); | 153 | void setCategories(const QStringList &categories); |
154 | /** set event's categories based on a comma delimited string */ | 154 | /** set event's categories based on a comma delimited string */ |
155 | void setCategories(const QString &catStr); | 155 | void setCategories(const QString &catStr); |
156 | /** return categories in a list */ | 156 | /** return categories in a list */ |
157 | QStringList categories() const; | 157 | QStringList categories() const; |
158 | /** return categories as a comma separated string */ | 158 | /** return categories as a comma separated string */ |
159 | QString categoriesStr(); | 159 | QString categoriesStr(); |
160 | 160 | ||
161 | /** point at some other event to which the event relates. This function should | 161 | /** point at some other event to which the event relates. This function should |
162 | * only be used when constructing a calendar before the related Event | 162 | * only be used when constructing a calendar before the related Event |
163 | * exists. */ | 163 | * exists. */ |
164 | void setRelatedToUid(const QString &); | 164 | void setRelatedToUid(const QString &); |
165 | /** what event does this one relate to? This function should | 165 | /** what event does this one relate to? This function should |
166 | * only be used when constructing a calendar before the related Event | 166 | * only be used when constructing a calendar before the related Event |
167 | * exists. */ | 167 | * exists. */ |
168 | QString relatedToUid() const; | 168 | QString relatedToUid() const; |
169 | /** point at some other event to which the event relates */ | 169 | /** point at some other event to which the event relates */ |
170 | void setRelatedTo(Incidence *relatedTo); | 170 | void setRelatedTo(Incidence *relatedTo); |
171 | /** what event does this one relate to? */ | 171 | /** what event does this one relate to? */ |
172 | Incidence *relatedTo() const; | 172 | Incidence *relatedTo() const; |
173 | /** All events that are related to this event */ | 173 | /** All events that are related to this event */ |
174 | QPtrList<Incidence> relations() const; | 174 | QPtrList<Incidence> relations() const; |
175 | /** Add an event which is related to this event */ | 175 | /** Add an event which is related to this event */ |
176 | void addRelation(Incidence *); | 176 | void addRelation(Incidence *); |
177 | /** Remove event that is related to this event */ | 177 | /** Remove event that is related to this event */ |
178 | void removeRelation(Incidence *); | 178 | void removeRelation(Incidence *); |
179 | 179 | ||
180 | /** returns the list of dates which are exceptions to the recurrence rule */ | 180 | /** returns the list of dates which are exceptions to the recurrence rule */ |
181 | DateList exDates() const; | 181 | DateList exDates() const; |
182 | /** sets the list of dates which are exceptions to the recurrence rule */ | 182 | /** sets the list of dates which are exceptions to the recurrence rule */ |
183 | void setExDates(const DateList &_exDates); | 183 | void setExDates(const DateList &_exDates); |
184 | void setExDates(const char *dates); | 184 | void setExDates(const char *dates); |
185 | /** Add a date to the list of exceptions of the recurrence rule. */ | 185 | /** Add a date to the list of exceptions of the recurrence rule. */ |
186 | void addExDate(const QDate &date); | 186 | void addExDate(const QDate &date); |
187 | 187 | ||
188 | /** returns true if there is an exception for this date in the recurrence | 188 | /** returns true if there is an exception for this date in the recurrence |
189 | rule set, or false otherwise. */ | 189 | rule set, or false otherwise. */ |
190 | bool isException(const QDate &qd) const; | 190 | bool isException(const QDate &qd) const; |
191 | 191 | ||
192 | /** add attachment to this event */ | 192 | /** add attachment to this event */ |
193 | void addAttachment(Attachment *attachment); | 193 | void addAttachment(Attachment *attachment); |
194 | /** remove and delete a specific attachment */ | 194 | /** remove and delete a specific attachment */ |
195 | void deleteAttachment(Attachment *attachment); | 195 | void deleteAttachment(Attachment *attachment); |
196 | /** remove and delete all attachments with this mime type */ | 196 | /** remove and delete all attachments with this mime type */ |
197 | void deleteAttachments(const QString& mime); | 197 | void deleteAttachments(const QString& mime); |
198 | /** return list of all associated attachments */ | 198 | /** return list of all associated attachments */ |
199 | QPtrList<Attachment> attachments() const; | 199 | QPtrList<Attachment> attachments() const; |
200 | /** find a list of attachments with this mime type */ | 200 | /** find a list of attachments with this mime type */ |
201 | QPtrList<Attachment> attachments(const QString& mime) const; | 201 | QPtrList<Attachment> attachments(const QString& mime) const; |
202 | 202 | ||
203 | /** sets the event's status the value specified. See the enumeration | 203 | /** sets the event's status the value specified. See the enumeration |
204 | * above for possible values. */ | 204 | * above for possible values. */ |
205 | void setSecrecy(int); | 205 | void setSecrecy(int); |
206 | /** return the event's secrecy. */ | 206 | /** return the event's secrecy. */ |
207 | int secrecy() const; | 207 | int secrecy() const; |
208 | /** return the event's secrecy in string format. */ | 208 | /** return the event's secrecy in string format. */ |
209 | QString secrecyStr() const; | 209 | QString secrecyStr() const; |
210 | /** return list of all availbale secrecy classes */ | 210 | /** return list of all availbale secrecy classes */ |
211 | static QStringList secrecyList(); | 211 | static QStringList secrecyList(); |
212 | /** return human-readable name of secrecy class */ | 212 | /** return human-readable name of secrecy class */ |
213 | static QString secrecyName(int); | 213 | static QString secrecyName(int); |
214 | 214 | ||
215 | /** returns TRUE if the date specified is one on which the event will | 215 | /** returns TRUE if the date specified is one on which the event will |
216 | * recur. */ | 216 | * recur. */ |
217 | bool recursOn(const QDate &qd) const; | 217 | bool recursOn(const QDate &qd) const; |
218 | 218 | ||
219 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): | 219 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): |
220 | 220 | ||
221 | /** set resources used, such as Office, Car, etc. */ | 221 | /** set resources used, such as Office, Car, etc. */ |
222 | void setResources(const QStringList &resources); | 222 | void setResources(const QStringList &resources); |
223 | /** return list of current resources */ | 223 | /** return list of current resources */ |
224 | QStringList resources() const; | 224 | QStringList resources() const; |
225 | 225 | ||
226 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ | 226 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ |
227 | void setPriority(int priority); | 227 | void setPriority(int priority); |
228 | /** get the event's priority */ | 228 | /** get the event's priority */ |
229 | int priority() const; | 229 | int priority() const; |
230 | 230 | ||
231 | /** All alarms that are associated with this incidence */ | 231 | /** All alarms that are associated with this incidence */ |
232 | QPtrList<Alarm> alarms() const; | 232 | QPtrList<Alarm> alarms() const; |
233 | /** Create a new alarm which is associated with this incidence */ | 233 | /** Create a new alarm which is associated with this incidence */ |
234 | Alarm* newAlarm(); | 234 | Alarm* newAlarm(); |
235 | /** Add an alarm which is associated with this incidence */ | 235 | /** Add an alarm which is associated with this incidence */ |
236 | void addAlarm(Alarm*); | 236 | void addAlarm(Alarm*); |
237 | /** Remove an alarm that is associated with this incidence */ | 237 | /** Remove an alarm that is associated with this incidence */ |
238 | void removeAlarm(Alarm*); | 238 | void removeAlarm(Alarm*); |
239 | /** Remove all alarms that are associated with this incidence */ | 239 | /** Remove all alarms that are associated with this incidence */ |
240 | void clearAlarms(); | 240 | void clearAlarms(); |
241 | /** return whether any alarm associated with this incidence is enabled */ | 241 | /** return whether any alarm associated with this incidence is enabled */ |
242 | bool isAlarmEnabled() const; | 242 | bool isAlarmEnabled() const; |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Return the recurrence rule associated with this incidence. If there is | 245 | Return the recurrence rule associated with this incidence. If there is |
246 | none, returns an appropriate (non-0) object. | 246 | none, returns an appropriate (non-0) object. |
247 | */ | 247 | */ |
248 | Recurrence *recurrence() const; | 248 | Recurrence *recurrence() const; |
249 | void setRecurrence(Recurrence * r); | 249 | void setRecurrence(Recurrence * r); |
250 | /** | 250 | /** |
251 | Forward to Recurrence::doesRecur(). | 251 | Forward to Recurrence::doesRecur(). |
252 | */ | 252 | */ |
253 | ushort doesRecur() const; | 253 | ushort doesRecur() const; |
254 | 254 | ||
255 | /** set the event's/todo's location. Do _not_ use it with journal */ | 255 | /** set the event's/todo's location. Do _not_ use it with journal */ |
256 | void setLocation(const QString &location); | 256 | void setLocation(const QString &location); |
257 | /** return the event's/todo's location. Do _not_ use it with journal */ | 257 | /** return the event's/todo's location. Do _not_ use it with journal */ |
258 | QString location() const; | 258 | QString location() const; |
259 | /** returns TRUE or FALSE depending on whether the todo has a start date */ | 259 | /** returns TRUE or FALSE depending on whether the todo has a start date */ |
260 | bool hasStartDate() const; | 260 | bool hasStartDate() const; |
261 | /** sets the event's hasStartDate value. */ | 261 | /** sets the event's hasStartDate value. */ |
262 | void setHasStartDate(bool f); | 262 | void setHasStartDate(bool f); |
263 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; | 263 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; |
264 | bool cancelled() const; | 264 | bool cancelled() const; |
265 | void setCancelled( bool b ); | 265 | void setCancelled( bool b ); |
266 | 266 | ||
267 | bool hasRecurrenceID() const; | 267 | bool hasRecurrenceID() const; |
268 | void setHasRecurrenceID( bool b ); | 268 | void setHasRecurrenceID( bool b ); |
269 | 269 | ||
270 | void setRecurrenceID(QDateTime); | 270 | void setRecurrenceID(QDateTime); |
271 | QDateTime recurrenceID () const; | 271 | QDateTime recurrenceID () const; |
272 | QDateTime dtStart() const; | 272 | QDateTime dtStart() const; |
273 | bool isHoliday() const; | ||
274 | bool isBirthday() const; | ||
275 | bool isAnniversary() const; | ||
273 | 276 | ||
274 | 277 | ||
275 | protected: | 278 | protected: |
276 | QPtrList<Alarm> mAlarms; | 279 | QPtrList<Alarm> mAlarms; |
277 | QPtrList<Incidence> mRelations; | 280 | QPtrList<Incidence> mRelations; |
278 | QDateTime mRecurrenceID; | 281 | QDateTime mRecurrenceID; |
279 | bool mHasRecurrenceID; | 282 | bool mHasRecurrenceID; |
280 | private: | 283 | private: |
284 | void checkCategories(); | ||
285 | bool mHoliday, mBirthday, mAnniversary; | ||
281 | int mRevision; | 286 | int mRevision; |
282 | bool mCancelled; | 287 | bool mCancelled; |
283 | 288 | ||
284 | // base components of jounal, event and todo | 289 | // base components of jounal, event and todo |
285 | QDateTime mCreated; | 290 | QDateTime mCreated; |
286 | QString mDescription; | 291 | QString mDescription; |
287 | QString mSummary; | 292 | QString mSummary; |
288 | QStringList mCategories; | 293 | QStringList mCategories; |
289 | Incidence *mRelatedTo; | 294 | Incidence *mRelatedTo; |
290 | QString mRelatedToUid; | 295 | QString mRelatedToUid; |
291 | DateList mExDates; | 296 | DateList mExDates; |
292 | QPtrList<Attachment> mAttachments; | 297 | QPtrList<Attachment> mAttachments; |
293 | QStringList mResources; | 298 | QStringList mResources; |
294 | bool mHasStartDate; // if todo has associated start date | 299 | bool mHasStartDate; // if todo has associated start date |
295 | 300 | ||
296 | int mSecrecy; | 301 | int mSecrecy; |
297 | int mPriority; // 1 = highest, 2 = less, etc. | 302 | int mPriority; // 1 = highest, 2 = less, etc. |
298 | 303 | ||
299 | //QPtrList<Alarm> mAlarms; | 304 | //QPtrList<Alarm> mAlarms; |
300 | Recurrence *mRecurrence; | 305 | Recurrence *mRecurrence; |
301 | 306 | ||
302 | QString mLocation; | 307 | QString mLocation; |
303 | }; | 308 | }; |
304 | 309 | ||
305 | bool operator==( const Incidence&, const Incidence& ); | 310 | bool operator==( const Incidence&, const Incidence& ); |
306 | 311 | ||
307 | } | 312 | } |
308 | 313 | ||
309 | #endif | 314 | #endif |