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 | |||
@@ -835,12 +835,32 @@ void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime 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 ); |
@@ -853,18 +873,10 @@ void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | |||
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) |
@@ -876,7 +888,7 @@ void KOEditorRecurrence::readEvent(Incidence *event) | |||
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; |
@@ -897,7 +909,7 @@ void KOEditorRecurrence::readEvent(Incidence *event) | |||
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; |
@@ -969,7 +981,7 @@ void KOEditorRecurrence::readEvent(Incidence *event) | |||
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 | ||