-rw-r--r-- | korganizer/koagendaview.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 20a5b74..76d5c4b 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -699,514 +699,521 @@ void KOAgendaView::createDayLabels() | |||
699 | dlf.setPointSize( fontPoint ); | 699 | dlf.setPointSize( fontPoint ); |
700 | QFontMetrics f( dlf ); | 700 | QFontMetrics f( dlf ); |
701 | wid = f.width( "30" ); | 701 | wid = f.width( "30" ); |
702 | needWid = wid * selCount; | 702 | needWid = wid * selCount; |
703 | if ( needWid < maxWid ) | 703 | if ( needWid < maxWid ) |
704 | break; | 704 | break; |
705 | } | 705 | } |
706 | maxLen = 2; | 706 | maxLen = 2; |
707 | } | 707 | } |
708 | //qDebug("Max len %d ", dayTest.length() ); | 708 | //qDebug("Max len %d ", dayTest.length() ); |
709 | 709 | ||
710 | QFontMetrics tempF( dlf ); | 710 | QFontMetrics tempF( dlf ); |
711 | newHight = tempF.height(); | 711 | newHight = tempF.height(); |
712 | mDayLabels->setFont( dlf ); | 712 | mDayLabels->setFont( dlf ); |
713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
715 | //mLayoutDayLabels->addSpacing( 2 ); | 715 | //mLayoutDayLabels->addSpacing( 2 ); |
716 | // QFont lFont = dlf; | 716 | // QFont lFont = dlf; |
717 | bool appendLabels = false; | 717 | bool appendLabels = false; |
718 | KOAgendaButton *dayLabel; | 718 | KOAgendaButton *dayLabel; |
719 | dayLabel = mDayLabelsList.first(); | 719 | dayLabel = mDayLabelsList.first(); |
720 | if ( !dayLabel ) { | 720 | if ( !dayLabel ) { |
721 | appendLabels = true; | 721 | appendLabels = true; |
722 | dayLabel = getNewDaylabel(); | 722 | dayLabel = getNewDaylabel(); |
723 | } | 723 | } |
724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
725 | dayLabel->setFont( dlf ); | 725 | dayLabel->setFont( dlf ); |
726 | dayLabel->setNum( -1 ); | 726 | dayLabel->setNum( -1 ); |
727 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 727 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
728 | #if 0 | 728 | #if 0 |
729 | if ( QApplication::desktop()->width() <= 320 ) | 729 | if ( QApplication::desktop()->width() <= 320 ) |
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); | 730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); |
731 | else | 731 | else |
732 | #endif | 732 | #endif |
733 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 733 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
734 | dayLabel->show(); | 734 | dayLabel->show(); |
735 | DateList::ConstIterator dit; | 735 | DateList::ConstIterator dit; |
736 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 736 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
737 | int counter = -1; | 737 | int counter = -1; |
738 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 738 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
739 | ++counter; | 739 | ++counter; |
740 | QDate date = *dit; | 740 | QDate date = *dit; |
741 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 741 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
742 | if ( ! appendLabels ) { | 742 | if ( ! appendLabels ) { |
743 | dayLabel = mDayLabelsList.next(); | 743 | dayLabel = mDayLabelsList.next(); |
744 | if ( !dayLabel ) | 744 | if ( !dayLabel ) |
745 | appendLabels = true; | 745 | appendLabels = true; |
746 | } | 746 | } |
747 | if ( appendLabels ) { | 747 | if ( appendLabels ) { |
748 | dayLabel = getNewDaylabel(); | 748 | dayLabel = getNewDaylabel(); |
749 | } | 749 | } |
750 | dayLabel->setMinimumWidth( 1 ); | 750 | dayLabel->setMinimumWidth( 1 ); |
751 | dayLabel->setMaximumWidth( 10240 ); | 751 | dayLabel->setMaximumWidth( 10240 ); |
752 | dayLabel->setFont( dlf ); | 752 | dayLabel->setFont( dlf ); |
753 | dayLabel->show(); | 753 | dayLabel->show(); |
754 | dayLabel->setAutoRepeat( false ); | 754 | dayLabel->setAutoRepeat( false ); |
755 | dayLabel->setNum( counter ); | 755 | dayLabel->setNum( counter ); |
756 | QString str; | 756 | QString str; |
757 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 757 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
758 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 758 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
759 | switch ( maxLen ) { | 759 | switch ( maxLen ) { |
760 | case 2: | 760 | case 2: |
761 | str = QString::number( date.day() ); | 761 | str = QString::number( date.day() ); |
762 | break; | 762 | break; |
763 | 763 | ||
764 | case 3: | 764 | case 3: |
765 | str = dayName.left( 1 ) +QString::number( date.day()); | 765 | str = dayName.left( 1 ) +QString::number( date.day()); |
766 | 766 | ||
767 | break; | 767 | break; |
768 | case 4: | 768 | case 4: |
769 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 769 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
770 | 770 | ||
771 | break; | 771 | break; |
772 | case 5: | 772 | case 5: |
773 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 773 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
774 | 774 | ||
775 | break; | 775 | break; |
776 | case 6: | 776 | case 6: |
777 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 777 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
778 | break; | 778 | break; |
779 | 779 | ||
780 | default: | 780 | default: |
781 | break; | 781 | break; |
782 | } | 782 | } |
783 | if ( oneday ) { | 783 | if ( oneday ) { |
784 | QString addString; | 784 | QString addString; |
785 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 785 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
786 | addString = i18n("Today"); | 786 | addString = i18n("Today"); |
787 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 787 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
788 | addString = i18n("Tomorrow"); | 788 | addString = i18n("Tomorrow"); |
789 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 789 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
790 | addString = i18n("Yesterday"); | 790 | addString = i18n("Yesterday"); |
791 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 791 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
792 | addString = i18n("Day before yesterday"); | 792 | addString = i18n("Day before yesterday"); |
793 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 793 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
794 | addString = i18n("Day after tomorrow"); | 794 | addString = i18n("Day after tomorrow"); |
795 | if ( !addString.isEmpty() ) { | 795 | if ( !addString.isEmpty() ) { |
796 | str = addString+", " + str; | 796 | str = addString+", " + str; |
797 | } else { | 797 | } else { |
798 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 798 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
799 | } | 799 | } |
800 | } | 800 | } |
801 | dayLabel->setText(str); | 801 | dayLabel->setText(str); |
802 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 802 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
803 | if (date == QDate::currentDate()) { | 803 | if (date == QDate::currentDate()) { |
804 | QFont bFont = dlf; | 804 | QFont bFont = dlf; |
805 | bFont.setBold( true ); | 805 | bFont.setBold( true ); |
806 | dayLabel->setFont(bFont); | 806 | dayLabel->setFont(bFont); |
807 | } | 807 | } |
808 | //dayLayout->addWidget(dayLabel); | 808 | //dayLayout->addWidget(dayLabel); |
809 | 809 | ||
810 | #ifndef KORG_NOPLUGINS | 810 | #ifndef KORG_NOPLUGINS |
811 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 811 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
812 | CalendarDecoration *it; | 812 | CalendarDecoration *it; |
813 | for(it = cds.first(); it; it = cds.next()) { | 813 | for(it = cds.first(); it; it = cds.next()) { |
814 | QString text = it->shortText( date ); | 814 | QString text = it->shortText( date ); |
815 | if ( !text.isEmpty() ) { | 815 | if ( !text.isEmpty() ) { |
816 | QLabel *label = new QLabel(text,mDayLabels); | 816 | QLabel *label = new QLabel(text,mDayLabels); |
817 | label->setAlignment(AlignCenter); | 817 | label->setAlignment(AlignCenter); |
818 | dayLayout->addWidget(label); | 818 | dayLayout->addWidget(label); |
819 | } | 819 | } |
820 | } | 820 | } |
821 | 821 | ||
822 | for(it = cds.first(); it; it = cds.next()) { | 822 | for(it = cds.first(); it; it = cds.next()) { |
823 | QWidget *wid = it->smallWidget(mDayLabels,date); | 823 | QWidget *wid = it->smallWidget(mDayLabels,date); |
824 | if ( wid ) { | 824 | if ( wid ) { |
825 | // wid->setHeight(20); | 825 | // wid->setHeight(20); |
826 | dayLayout->addWidget(wid); | 826 | dayLayout->addWidget(wid); |
827 | } | 827 | } |
828 | } | 828 | } |
829 | #endif | 829 | #endif |
830 | } | 830 | } |
831 | if ( ! appendLabels ) { | 831 | if ( ! appendLabels ) { |
832 | dayLabel = mDayLabelsList.next(); | 832 | dayLabel = mDayLabelsList.next(); |
833 | if ( !dayLabel ) | 833 | if ( !dayLabel ) |
834 | appendLabels = true; | 834 | appendLabels = true; |
835 | } | 835 | } |
836 | if ( appendLabels ) { | 836 | if ( appendLabels ) { |
837 | dayLabel = getNewDaylabel(); | 837 | dayLabel = getNewDaylabel(); |
838 | } | 838 | } |
839 | //dayLabel->hide();//test only | 839 | //dayLabel->hide();//test only |
840 | 840 | ||
841 | dayLabel->setText(">"); | 841 | dayLabel->setText(">"); |
842 | dayLabel->setFont( dlf ); | 842 | dayLabel->setFont( dlf ); |
843 | dayLabel->setAutoRepeat( true ); | 843 | dayLabel->setAutoRepeat( true ); |
844 | dayLabel->show(); | 844 | dayLabel->show(); |
845 | dayLabel->setNum( -2 ); | 845 | dayLabel->setNum( -2 ); |
846 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 846 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
847 | 847 | ||
848 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 848 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
849 | if ( !appendLabels ) { | 849 | if ( !appendLabels ) { |
850 | dayLabel = mDayLabelsList.next(); | 850 | dayLabel = mDayLabelsList.next(); |
851 | while ( dayLabel ) { | 851 | while ( dayLabel ) { |
852 | //qDebug("!dayLabel %d",dayLabel ); | 852 | //qDebug("!dayLabel %d",dayLabel ); |
853 | dayLabel->hide(); | 853 | dayLabel->hide(); |
854 | dayLabel = mDayLabelsList.next(); | 854 | dayLabel = mDayLabelsList.next(); |
855 | } | 855 | } |
856 | } | 856 | } |
857 | 857 | ||
858 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 858 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
859 | } | 859 | } |
860 | 860 | ||
861 | int KOAgendaView::maxDatesHint() | 861 | int KOAgendaView::maxDatesHint() |
862 | { | 862 | { |
863 | // Not sure about the max number of events, so return 0 for now. | 863 | // Not sure about the max number of events, so return 0 for now. |
864 | return 0; | 864 | return 0; |
865 | } | 865 | } |
866 | 866 | ||
867 | int KOAgendaView::currentDateCount() | 867 | int KOAgendaView::currentDateCount() |
868 | { | 868 | { |
869 | return mSelectedDates.count(); | 869 | return mSelectedDates.count(); |
870 | } | 870 | } |
871 | 871 | ||
872 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 872 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
873 | { | 873 | { |
874 | QPtrList<Incidence> selected; | 874 | QPtrList<Incidence> selected; |
875 | Incidence *incidence; | 875 | Incidence *incidence; |
876 | 876 | ||
877 | incidence = mAgenda->selectedIncidence(); | 877 | incidence = mAgenda->selectedIncidence(); |
878 | if (incidence) selected.append(incidence); | 878 | if (incidence) selected.append(incidence); |
879 | 879 | ||
880 | incidence = mAllDayAgenda->selectedIncidence(); | 880 | incidence = mAllDayAgenda->selectedIncidence(); |
881 | if (incidence) selected.append(incidence); | 881 | if (incidence) selected.append(incidence); |
882 | 882 | ||
883 | return selected; | 883 | return selected; |
884 | } | 884 | } |
885 | 885 | ||
886 | DateList KOAgendaView::selectedDates() | 886 | DateList KOAgendaView::selectedDates() |
887 | { | 887 | { |
888 | DateList selected; | 888 | DateList selected; |
889 | QDate qd; | 889 | QDate qd; |
890 | 890 | ||
891 | qd = mAgenda->selectedIncidenceDate(); | 891 | qd = mAgenda->selectedIncidenceDate(); |
892 | if (qd.isValid()) selected.append(qd); | 892 | if (qd.isValid()) selected.append(qd); |
893 | 893 | ||
894 | qd = mAllDayAgenda->selectedIncidenceDate(); | 894 | qd = mAllDayAgenda->selectedIncidenceDate(); |
895 | if (qd.isValid()) selected.append(qd); | 895 | if (qd.isValid()) selected.append(qd); |
896 | 896 | ||
897 | return selected; | 897 | return selected; |
898 | } | 898 | } |
899 | 899 | ||
900 | 900 | ||
901 | void KOAgendaView::updateView() | 901 | void KOAgendaView::updateView() |
902 | { | 902 | { |
903 | if ( mBlockUpdating ) | 903 | if ( mBlockUpdating ) |
904 | return; | 904 | return; |
905 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 905 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
906 | fillAgenda(); | 906 | fillAgenda(); |
907 | 907 | ||
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | /* | 911 | /* |
912 | Update configuration settings for the agenda view. This method is not | 912 | Update configuration settings for the agenda view. This method is not |
913 | complete. | 913 | complete. |
914 | */ | 914 | */ |
915 | void KOAgendaView::updateConfig() | 915 | void KOAgendaView::updateConfig() |
916 | { | 916 | { |
917 | if ( mBlockUpdating ) | 917 | if ( mBlockUpdating ) |
918 | return; | 918 | return; |
919 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 919 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
920 | int old = KOPrefs::instance()->mHourSize; | 920 | int old = KOPrefs::instance()->mHourSize; |
921 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 921 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
922 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 922 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
923 | } | 923 | } |
924 | 924 | ||
925 | 925 | ||
926 | // update config for children | 926 | // update config for children |
927 | mTimeLabels->updateConfig(); | 927 | mTimeLabels->updateConfig(); |
928 | mAgenda->storePosition(); | 928 | mAgenda->storePosition(); |
929 | mAgenda->updateConfig(); | 929 | mAgenda->updateConfig(); |
930 | mAllDayAgenda->updateConfig(); | 930 | mAllDayAgenda->updateConfig(); |
931 | // widget synchronization | 931 | // widget synchronization |
932 | //TODO: find a better way, maybe signal/slot | 932 | //TODO: find a better way, maybe signal/slot |
933 | mTimeLabels->positionChanged(); | 933 | mTimeLabels->positionChanged(); |
934 | 934 | ||
935 | // for some reason, this needs to be called explicitly | 935 | // for some reason, this needs to be called explicitly |
936 | mTimeLabels->repaint(); | 936 | mTimeLabels->repaint(); |
937 | 937 | ||
938 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 938 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
939 | 939 | ||
940 | // ToolTips displaying summary of events | 940 | // ToolTips displaying summary of events |
941 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 941 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
942 | ->mEnableToolTips); | 942 | ->mEnableToolTips); |
943 | 943 | ||
944 | //setHolidayMasks(); | 944 | //setHolidayMasks(); |
945 | 945 | ||
946 | //createDayLabels(); called by via updateView(); | 946 | //createDayLabels(); called by via updateView(); |
947 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 947 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
948 | updateView(); | 948 | updateView(); |
949 | mAgenda->restorePosition(); | 949 | mAgenda->restorePosition(); |
950 | } | 950 | } |
951 | 951 | ||
952 | 952 | ||
953 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 953 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
954 | { | 954 | { |
955 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 955 | |
956 | //qDebug("KOAgendaView::updateEventDates "); | 956 | |
957 | int xxx = item->cellX(); | ||
958 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | ||
959 | if ( mMinY.at(xxx) > item->cellYTop() ) | ||
960 | mMinY.at(xxx) = item->cellYTop(); | ||
961 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | ||
962 | mMaxY.at(xxx) = item->cellYBottom(); | ||
963 | |||
957 | QDateTime startDt,endDt; | 964 | QDateTime startDt,endDt; |
958 | QDate startDate; | 965 | QDate startDate; |
959 | int lenInSecs; | 966 | int lenInSecs; |
960 | // if ( type == KOAgenda::RESIZETOP ) | 967 | // if ( type == KOAgenda::RESIZETOP ) |
961 | // qDebug("RESIZETOP "); | 968 | // qDebug("RESIZETOP "); |
962 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 969 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
963 | // qDebug("RESIZEBOTTOM "); | 970 | // qDebug("RESIZEBOTTOM "); |
964 | // if ( type == KOAgenda::MOVE ) | 971 | // if ( type == KOAgenda::MOVE ) |
965 | // qDebug("MOVE "); | 972 | // qDebug("MOVE "); |
966 | if ( item->incidence()->type() == "Event" ) { | 973 | if ( item->incidence()->type() == "Event" ) { |
967 | startDt =item->incidence()->dtStart(); | 974 | startDt =item->incidence()->dtStart(); |
968 | endDt = item->incidence()->dtEnd(); | 975 | endDt = item->incidence()->dtEnd(); |
969 | lenInSecs = startDt.secsTo( endDt ); | 976 | lenInSecs = startDt.secsTo( endDt ); |
970 | } | 977 | } |
971 | 978 | ||
972 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 979 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
973 | 980 | ||
974 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 981 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
975 | startDate = mSelectedDates[item->mLastMoveXPos]; | 982 | startDate = mSelectedDates[item->mLastMoveXPos]; |
976 | } else { | 983 | } else { |
977 | if (item->cellX() < 0) { | 984 | if (item->cellX() < 0) { |
978 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 985 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
979 | } else { | 986 | } else { |
980 | startDate = mSelectedDates[item->cellX()]; | 987 | startDate = mSelectedDates[item->cellX()]; |
981 | } | 988 | } |
982 | } | 989 | } |
983 | startDt.setDate(startDate); | 990 | startDt.setDate(startDate); |
984 | 991 | ||
985 | if (item->incidence()->doesFloat()) { | 992 | if (item->incidence()->doesFloat()) { |
986 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 993 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
987 | } else { | 994 | } else { |
988 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 995 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
989 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 996 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
990 | if ( item->incidence()->type() == "Event" ) { | 997 | if ( item->incidence()->type() == "Event" ) { |
991 | if ( type == KOAgenda::MOVE ) { | 998 | if ( type == KOAgenda::MOVE ) { |
992 | endDt = startDt.addSecs(lenInSecs); | 999 | endDt = startDt.addSecs(lenInSecs); |
993 | 1000 | ||
994 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 1001 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
995 | if (item->lastMultiItem()) { | 1002 | if (item->lastMultiItem()) { |
996 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1003 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
997 | endDt.setDate(startDate. | 1004 | endDt.setDate(startDate. |
998 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1005 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
999 | } else { | 1006 | } else { |
1000 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1007 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1001 | endDt.setDate(startDate); | 1008 | endDt.setDate(startDate); |
1002 | } | 1009 | } |
1003 | } | 1010 | } |
1004 | } else { | 1011 | } else { |
1005 | // todo | 1012 | // todo |
1006 | if (item->lastMultiItem()) { | 1013 | if (item->lastMultiItem()) { |
1007 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1014 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1008 | endDt.setDate(startDate. | 1015 | endDt.setDate(startDate. |
1009 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1016 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1010 | } else { | 1017 | } else { |
1011 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1018 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1012 | if ( item->cellYBottom() > 0 ) | 1019 | if ( item->cellYBottom() > 0 ) |
1013 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1020 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1014 | else | 1021 | else |
1015 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1022 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1016 | endDt.setDate(startDate); | 1023 | endDt.setDate(startDate); |
1017 | } | 1024 | } |
1018 | } | 1025 | } |
1019 | } | 1026 | } |
1020 | if ( item->incidence()->type() == "Event" ) { | 1027 | if ( item->incidence()->type() == "Event" ) { |
1021 | item->incidence()->setDtStart(startDt); | 1028 | item->incidence()->setDtStart(startDt); |
1022 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1029 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1023 | } else if ( item->incidence()->type() == "Todo" ) { | 1030 | } else if ( item->incidence()->type() == "Todo" ) { |
1024 | Todo* to = static_cast<Todo*>(item->incidence()); | 1031 | Todo* to = static_cast<Todo*>(item->incidence()); |
1025 | 1032 | ||
1026 | to->setDtDue(endDt); | 1033 | to->setDtDue(endDt); |
1027 | if ( to->hasStartDate() ) { | 1034 | if ( to->hasStartDate() ) { |
1028 | if (to->dtStart() >= to->dtDue() ) | 1035 | if (to->dtStart() >= to->dtDue() ) |
1029 | to->setDtStart(to->dtDue().addDays( -2 )); | 1036 | to->setDtStart(to->dtDue().addDays( -2 )); |
1030 | } | 1037 | } |
1031 | 1038 | ||
1032 | } | 1039 | } |
1033 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1040 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1034 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1041 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1035 | item->setItemDate(startDt.date()); | 1042 | item->setItemDate(startDt.date()); |
1036 | //item->updateItem(); | 1043 | //item->updateItem(); |
1037 | if ( item->incidence()->type() == "Todo" ) { | 1044 | if ( item->incidence()->type() == "Todo" ) { |
1038 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1045 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1039 | 1046 | ||
1040 | } | 1047 | } |
1041 | else | 1048 | else |
1042 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1049 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1043 | item->updateItem(); | 1050 | item->updateItem(); |
1044 | } | 1051 | } |
1045 | 1052 | ||
1046 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1053 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1047 | { | 1054 | { |
1048 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1055 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1049 | 1056 | ||
1050 | mSelectedDates.clear(); | 1057 | mSelectedDates.clear(); |
1051 | // qDebug("KOAgendaView::showDates "); | 1058 | // qDebug("KOAgendaView::showDates "); |
1052 | QDate d = start; | 1059 | QDate d = start; |
1053 | while (d <= end) { | 1060 | while (d <= end) { |
1054 | mSelectedDates.append(d); | 1061 | mSelectedDates.append(d); |
1055 | d = d.addDays( 1 ); | 1062 | d = d.addDays( 1 ); |
1056 | } | 1063 | } |
1057 | 1064 | ||
1058 | // and update the view | 1065 | // and update the view |
1059 | fillAgenda(); | 1066 | fillAgenda(); |
1060 | } | 1067 | } |
1061 | 1068 | ||
1062 | 1069 | ||
1063 | void KOAgendaView::showEvents(QPtrList<Event>) | 1070 | void KOAgendaView::showEvents(QPtrList<Event>) |
1064 | { | 1071 | { |
1065 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1072 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1066 | } | 1073 | } |
1067 | 1074 | ||
1068 | void KOAgendaView::changeEventDisplay(Event *, int) | 1075 | void KOAgendaView::changeEventDisplay(Event *, int) |
1069 | { | 1076 | { |
1070 | // qDebug("KOAgendaView::changeEventDisplay "); | 1077 | // qDebug("KOAgendaView::changeEventDisplay "); |
1071 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1078 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1072 | // this should be re-written to be MUCH smarter. Right now we | 1079 | // this should be re-written to be MUCH smarter. Right now we |
1073 | // are just playing dumb. | 1080 | // are just playing dumb. |
1074 | fillAgenda(); | 1081 | fillAgenda(); |
1075 | } | 1082 | } |
1076 | 1083 | ||
1077 | void KOAgendaView::fillAgenda(const QDate &) | 1084 | void KOAgendaView::fillAgenda(const QDate &) |
1078 | { | 1085 | { |
1079 | // qDebug("KOAgendaView::fillAgenda "); | 1086 | // qDebug("KOAgendaView::fillAgenda "); |
1080 | fillAgenda(); | 1087 | fillAgenda(); |
1081 | } | 1088 | } |
1082 | 1089 | ||
1083 | void KOAgendaView::fillAgenda() | 1090 | void KOAgendaView::fillAgenda() |
1084 | { | 1091 | { |
1085 | if ( globalFlagBlockStartup ) | 1092 | if ( globalFlagBlockStartup ) |
1086 | return; | 1093 | return; |
1087 | if ( globalFlagBlockAgenda == 1 ) | 1094 | if ( globalFlagBlockAgenda == 1 ) |
1088 | return; | 1095 | return; |
1089 | static bool onlyOne = false; | 1096 | static bool onlyOne = false; |
1090 | if ( onlyOne ) | 1097 | if ( onlyOne ) |
1091 | return; | 1098 | return; |
1092 | onlyOne = true; | 1099 | onlyOne = true; |
1093 | //if ( globalFlagBlockAgenda == 2 ) | 1100 | //if ( globalFlagBlockAgenda == 2 ) |
1094 | //globalFlagBlockAgenda = 0; | 1101 | //globalFlagBlockAgenda = 0; |
1095 | // globalFlagBlockPainting = false; | 1102 | // globalFlagBlockPainting = false; |
1096 | if ( globalFlagBlockAgenda == 0 ) | 1103 | if ( globalFlagBlockAgenda == 0 ) |
1097 | globalFlagBlockAgenda = 1; | 1104 | globalFlagBlockAgenda = 1; |
1098 | // clearView(); | 1105 | // clearView(); |
1099 | //qDebug("fillAgenda()++++ "); | 1106 | //qDebug("fillAgenda()++++ "); |
1100 | globalFlagBlockAgendaItemPaint = 1; | 1107 | globalFlagBlockAgendaItemPaint = 1; |
1101 | 1108 | ||
1102 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1109 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1103 | mAgenda->changeColumns(mSelectedDates.count()); | 1110 | mAgenda->changeColumns(mSelectedDates.count()); |
1104 | qApp->processEvents(); | 1111 | qApp->processEvents(); |
1105 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1112 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1106 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1113 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1107 | setHolidayMasks(); | 1114 | setHolidayMasks(); |
1108 | 1115 | ||
1109 | //mAgenda->hideUnused(); | 1116 | //mAgenda->hideUnused(); |
1110 | //mAllDayAgenda->hideUnused(); | 1117 | //mAllDayAgenda->hideUnused(); |
1111 | 1118 | ||
1112 | // mAgenda->blockNextRepaint( false ); | 1119 | // mAgenda->blockNextRepaint( false ); |
1113 | // mAgenda->viewport()->repaint(); | 1120 | // mAgenda->viewport()->repaint(); |
1114 | // mAgenda->blockNextRepaint( true ); | 1121 | // mAgenda->blockNextRepaint( true ); |
1115 | mMinY.resize(mSelectedDates.count()); | 1122 | mMinY.resize(mSelectedDates.count()); |
1116 | mMaxY.resize(mSelectedDates.count()); | 1123 | mMaxY.resize(mSelectedDates.count()); |
1117 | 1124 | ||
1118 | QPtrList<Event> dayEvents; | 1125 | QPtrList<Event> dayEvents; |
1119 | 1126 | ||
1120 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1127 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1121 | // Therefore, gtodoset all of them. | 1128 | // Therefore, gtodoset all of them. |
1122 | QPtrList<Todo> todos = calendar()->todos(); | 1129 | QPtrList<Todo> todos = calendar()->todos(); |
1123 | 1130 | ||
1124 | mAgenda->setDateList(mSelectedDates); | 1131 | mAgenda->setDateList(mSelectedDates); |
1125 | 1132 | ||
1126 | QDate today = QDate::currentDate(); | 1133 | QDate today = QDate::currentDate(); |
1127 | 1134 | ||
1128 | DateList::ConstIterator dit; | 1135 | DateList::ConstIterator dit; |
1129 | int curCol = 0; | 1136 | int curCol = 0; |
1130 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1137 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1131 | QDate currentDate = *dit; | 1138 | QDate currentDate = *dit; |
1132 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1139 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1133 | // << endl; | 1140 | // << endl; |
1134 | 1141 | ||
1135 | dayEvents = calendar()->events(currentDate,true); | 1142 | dayEvents = calendar()->events(currentDate,true); |
1136 | 1143 | ||
1137 | // Default values, which can never be reached | 1144 | // Default values, which can never be reached |
1138 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1145 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1139 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1146 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1140 | 1147 | ||
1141 | unsigned int numEvent; | 1148 | unsigned int numEvent; |
1142 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1149 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1143 | Event *event = dayEvents.at(numEvent); | 1150 | Event *event = dayEvents.at(numEvent); |
1144 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1151 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1145 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1152 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1146 | continue; | 1153 | continue; |
1147 | // kdDebug() << " Event: " << event->summary() << endl; | 1154 | // kdDebug() << " Event: " << event->summary() << endl; |
1148 | 1155 | ||
1149 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1156 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1150 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1157 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1151 | 1158 | ||
1152 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1159 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1153 | 1160 | ||
1154 | if (event->doesFloat()) { | 1161 | if (event->doesFloat()) { |
1155 | if (event->recurrence()->doesRecur()) { | 1162 | if (event->recurrence()->doesRecur()) { |
1156 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1163 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1157 | } else { | 1164 | } else { |
1158 | if (beginX <= 0 && curCol == 0) { | 1165 | if (beginX <= 0 && curCol == 0) { |
1159 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1166 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1160 | } else if (beginX == curCol) { | 1167 | } else if (beginX == curCol) { |
1161 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1168 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1162 | } | 1169 | } |
1163 | } | 1170 | } |
1164 | } else if (event->isMultiDay()) { | 1171 | } else if (event->isMultiDay()) { |
1165 | if ( event->doesRecur () ) { | 1172 | if ( event->doesRecur () ) { |
1166 | QDate dateit = currentDate; | 1173 | QDate dateit = currentDate; |
1167 | int count = 0; | 1174 | int count = 0; |
1168 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1175 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1169 | while (! event->recursOn( dateit ) && count <= max ) { | 1176 | while (! event->recursOn( dateit ) && count <= max ) { |
1170 | ++count; | 1177 | ++count; |
1171 | dateit = dateit.addDays( -1 ); | 1178 | dateit = dateit.addDays( -1 ); |
1172 | } | 1179 | } |
1173 | bool ok; | 1180 | bool ok; |
1174 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1181 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1175 | if ( ok ) | 1182 | if ( ok ) |
1176 | { | 1183 | { |
1177 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1184 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1178 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1185 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1179 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1186 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1180 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1187 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1181 | 1188 | ||
1182 | } | 1189 | } |
1183 | } | 1190 | } |
1184 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1191 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1185 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1192 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1186 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1193 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1187 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1194 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1188 | //qDebug("insert!!! "); | 1195 | //qDebug("insert!!! "); |
1189 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1196 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1190 | } | 1197 | } |
1191 | if (beginX == curCol) { | 1198 | if (beginX == curCol) { |
1192 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1199 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1193 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1200 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1194 | } else if (endX == curCol) { | 1201 | } else if (endX == curCol) { |
1195 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1202 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1196 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1203 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1197 | } else { | 1204 | } else { |
1198 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1205 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1199 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1206 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1200 | } | 1207 | } |
1201 | } else { | 1208 | } else { |
1202 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1209 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1203 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1210 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1204 | if (endY < startY) endY = startY; | 1211 | if (endY < startY) endY = startY; |
1205 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1212 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1206 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1213 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1207 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1214 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1208 | } | 1215 | } |
1209 | } | 1216 | } |
1210 | // ---------- [display Todos -------------- | 1217 | // ---------- [display Todos -------------- |
1211 | unsigned int numTodo; | 1218 | unsigned int numTodo; |
1212 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1219 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |