Diffstat (limited to 'korganizer/koeditorrecurrence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index dea8981..de4e4f7 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -826,87 +826,99 @@ void KOEditorRecurrence::showCurrentRule( int current ) | |||
826 | break; | 826 | break; |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
831 | { | 831 | { |
832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
833 | 833 | ||
834 | mRecurrenceRange->setDateTimes( start, end ); | 834 | mRecurrenceRange->setDateTimes( start, end ); |
835 | mExceptions->setDefaults( end ); | 835 | mExceptions->setDefaults( end ); |
836 | 836 | ||
837 | } | 837 | } |
838 | 838 | void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) | |
839 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | 839 | { |
840 | setDateTimes( from, to ); | ||
841 | QBitArray days( 7 ); | ||
842 | days.fill( 0 ); | ||
843 | days.setBit( from.date().dayOfWeek()- 1); | ||
844 | mWeekly->setDays( days ); | ||
845 | bool byPos = mMonthly->byPos(); | ||
846 | if ( byPos ) | ||
847 | mMonthly->setByDay( from.date().day()-1 ); | ||
848 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | ||
849 | if ( ! byPos) | ||
850 | mMonthly->setByDay( from.date().day()-1 ); | ||
851 | |||
852 | bool byDay = mYearly->byDay(); | ||
853 | if ( ! byDay ) | ||
854 | mYearly->setByDay( from.date().dayOfYear() ); | ||
855 | mYearly->setByMonth( from.date().month(), from.date().day() ); | ||
856 | if ( byDay ) | ||
857 | mYearly->setByDay( from.date().dayOfYear() ); | ||
858 | } | ||
859 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) | ||
840 | { | 860 | { |
841 | 861 | ||
842 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 862 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
843 | setDateTimes( from, to ); | 863 | //setDateTimes( from, to ); |
844 | 864 | ||
845 | bool enabled = false; | 865 | bool enabled = false; |
846 | mEnabledCheck->setChecked( enabled ); | 866 | mEnabledCheck->setChecked( enabled ); |
847 | setEnabled( enabled ); | 867 | setEnabled( enabled ); |
848 | 868 | ||
849 | mExceptions->setDefaults( to ); | 869 | mExceptions->setDefaults( to ); |
850 | mRecurrenceRange->setDefaults( to ); | 870 | mRecurrenceRange->setDefaults( to ); |
851 | 871 | ||
852 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 872 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
853 | showCurrentRule( mRecurrenceChooser->type() ); | 873 | showCurrentRule( mRecurrenceChooser->type() ); |
854 | 874 | ||
855 | mDaily->setFrequency( 1 ); | 875 | mDaily->setFrequency( 1 ); |
856 | |||
857 | mWeekly->setFrequency( 1 ); | 876 | mWeekly->setFrequency( 1 ); |
858 | QBitArray days( 7 ); | ||
859 | days.fill( 0 ); | ||
860 | days.setBit( from.date().dayOfWeek()- 1); | ||
861 | mWeekly->setDays( days ); | ||
862 | mMonthly->setFrequency( 1 ); | 877 | mMonthly->setFrequency( 1 ); |
863 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | ||
864 | mMonthly->setByDay( from.date().day()-1 ); | ||
865 | mYearly->setFrequency( 1 ); | 878 | mYearly->setFrequency( 1 ); |
866 | mYearly->setByDay( from.date().dayOfYear() ); | 879 | setDefaultsDates( from, to ); |
867 | mYearly->setByMonth( from.date().month(), from.date().day() ); | ||
868 | } | 880 | } |
869 | 881 | ||
870 | void KOEditorRecurrence::readEvent(Incidence *event) | 882 | void KOEditorRecurrence::readEvent(Incidence *event) |
871 | { | 883 | { |
872 | 884 | ||
873 | QDateTime dtEnd; | 885 | QDateTime dtEnd; |
874 | if ( event->typeID() == eventID ) | 886 | if ( event->typeID() == eventID ) |
875 | dtEnd = ((Event*)event)->dtEnd(); | 887 | dtEnd = ((Event*)event)->dtEnd(); |
876 | else | 888 | else |
877 | dtEnd = ((Todo*)event)->dtDue(); | 889 | dtEnd = ((Todo*)event)->dtDue(); |
878 | 890 | ||
879 | setDefaults( event->dtStart(), dtEnd, true ); | 891 | setDefaults( event->dtStart(), dtEnd ); |
880 | QBitArray rDays( 7 ); | 892 | QBitArray rDays( 7 ); |
881 | QPtrList<Recurrence::rMonthPos> rmp; | 893 | QPtrList<Recurrence::rMonthPos> rmp; |
882 | QPtrList<int> rmd; | 894 | QPtrList<int> rmd; |
883 | int day = 0; | 895 | int day = 0; |
884 | int count = 0; | 896 | int count = 0; |
885 | int month = 0; | 897 | int month = 0; |
886 | setDateTimes( event->dtStart(), dtEnd ); | 898 | setDateTimes( event->dtStart(), dtEnd ); |
887 | 899 | ||
888 | Recurrence *r = event->recurrence(); | 900 | Recurrence *r = event->recurrence(); |
889 | int f = r->frequency(); | 901 | int f = r->frequency(); |
890 | 902 | ||
891 | int recurs = r->doesRecur(); | 903 | int recurs = r->doesRecur(); |
892 | 904 | ||
893 | mEnabledCheck->setChecked( recurs ); | 905 | mEnabledCheck->setChecked( recurs ); |
894 | setEnabled( recurs ); | 906 | setEnabled( recurs ); |
895 | 907 | ||
896 | int recurrenceType = RecurrenceChooser::Weekly; | 908 | int recurrenceType = RecurrenceChooser::Weekly; |
897 | 909 | ||
898 | switch ( recurs ) { | 910 | switch ( recurs ) { |
899 | case Recurrence::rNone: | 911 | case Recurrence::rNone: |
900 | setDefaults( event->dtStart(), dtEnd, true ); | 912 | setDefaults( event->dtStart(), dtEnd ); |
901 | break; | 913 | break; |
902 | case Recurrence::rDaily: | 914 | case Recurrence::rDaily: |
903 | recurrenceType = RecurrenceChooser::Daily; | 915 | recurrenceType = RecurrenceChooser::Daily; |
904 | mDaily->setFrequency( f ); | 916 | mDaily->setFrequency( f ); |
905 | break; | 917 | break; |
906 | case Recurrence::rWeekly: | 918 | case Recurrence::rWeekly: |
907 | recurrenceType = RecurrenceChooser::Weekly; | 919 | recurrenceType = RecurrenceChooser::Weekly; |
908 | mWeekly->setFrequency( f ); | 920 | mWeekly->setFrequency( f ); |
909 | mWeekly->setDays( r->days() ); | 921 | mWeekly->setDays( r->days() ); |
910 | break; | 922 | break; |
911 | case Recurrence::rMonthlyPos: | 923 | case Recurrence::rMonthlyPos: |
912 | // we only handle one possibility in the list right now, | 924 | // we only handle one possibility in the list right now, |
@@ -960,25 +972,25 @@ void KOEditorRecurrence::readEvent(Incidence *event) | |||
960 | #endif | 972 | #endif |
961 | mYearly->setFrequency( f ); | 973 | mYearly->setFrequency( f ); |
962 | } | 974 | } |
963 | 975 | ||
964 | break; | 976 | break; |
965 | case Recurrence::rYearlyDay: | 977 | case Recurrence::rYearlyDay: |
966 | //qDebug("Recurrence::rYearlyDay: "); | 978 | //qDebug("Recurrence::rYearlyDay: "); |
967 | recurrenceType = RecurrenceChooser::Yearly; | 979 | recurrenceType = RecurrenceChooser::Yearly; |
968 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 980 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
969 | mYearly->setFrequency( f ); | 981 | mYearly->setFrequency( f ); |
970 | break; | 982 | break; |
971 | default: | 983 | default: |
972 | setDefaults( event->dtStart(), dtEnd, true ); | 984 | setDefaults( event->dtStart(), dtEnd ); |
973 | break; | 985 | break; |
974 | } | 986 | } |
975 | 987 | ||
976 | mRecurrenceChooser->setType( recurrenceType ); | 988 | mRecurrenceChooser->setType( recurrenceType ); |
977 | showCurrentRule( recurrenceType ); | 989 | showCurrentRule( recurrenceType ); |
978 | 990 | ||
979 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 991 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
980 | 992 | ||
981 | if ( r->doesRecur() ) { | 993 | if ( r->doesRecur() ) { |
982 | mRecurrenceRange->setDuration( r->duration() ); | 994 | mRecurrenceRange->setDuration( r->duration() ); |
983 | if ( r->duration() == 0 ) | 995 | if ( r->duration() == 0 ) |
984 | { | 996 | { |