-rw-r--r-- | library/datebookdb.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/library/datebookdb.cpp b/library/datebookdb.cpp index 000ff71..188d8e1 100644 --- a/library/datebookdb.cpp +++ b/library/datebookdb.cpp | |||
@@ -80,37 +80,40 @@ bool nextOccurance(const Event &e, const QDate &from, QDateTime &next) | |||
80 | next = e.start(); | 80 | next = e.start(); |
81 | return TRUE; | 81 | return TRUE; |
82 | } | 82 | } |
83 | 83 | ||
84 | switch ( e.repeatPattern().type ) { | 84 | switch ( e.repeatPattern().type ) { |
85 | case Event::Weekly: | 85 | case Event::Weekly: |
86 | /* weekly is just daily by 7 */ | 86 | /* weekly is just daily by 7 */ |
87 | /* first convert the repeatPattern.Days() mask to the next | 87 | /* first convert the repeatPattern.Days() mask to the next |
88 | day of week valid after from */ | 88 | day of week valid after from */ |
89 | dayOfWeek = from.dayOfWeek(); | 89 | dayOfWeek = from.dayOfWeek(); |
90 | dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ | 90 | dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ |
91 | 91 | ||
92 | /* this is done in case freq > 1 and from in week not | 92 | /* this is done in case freq > 1 and from in week not |
93 | for this round */ | 93 | for this round */ |
94 | // firstOfWeek = 0; this is already done at decl. | 94 | // firstOfWeek = 0; this is already done at decl. |
95 | while(!((1 << firstOfWeek) & e.repeatPattern().days)) | 95 | while(!((1 << firstOfWeek) & e.repeatPattern().days)) |
96 | firstOfWeek++; | 96 | firstOfWeek++; |
97 | |||
98 | |||
97 | 99 | ||
98 | /* there is at least one 'day', or there would be no event */ | 100 | /* there is at least one 'day', or there would be no event */ |
99 | while(!((1 << (dayOfWeek % 7)) & e.repeatPattern().days)) | 101 | while(!((1 << (dayOfWeek % 7)) & e.repeatPattern().days)) |
100 | dayOfWeek++; | 102 | dayOfWeek++; |
103 | |||
101 | 104 | ||
102 | dayOfWeek = dayOfWeek % 7; /* the actual day of week */ | 105 | dayOfWeek = dayOfWeek % 7; /* the actual day of week */ |
103 | dayOfWeek -= e.start().date().dayOfWeek() -1; | 106 | dayOfWeek -= e.start().date().dayOfWeek() -1; |
104 | 107 | ||
105 | firstOfWeek = firstOfWeek % 7; /* the actual first of week */ | 108 | firstOfWeek = firstOfWeek % 7; /* the actual first of week */ |
106 | firstOfWeek -= e.start().date().dayOfWeek() -1; | 109 | firstOfWeek -= e.start().date().dayOfWeek() -1; |
107 | 110 | ||
108 | // dayOfWeek may be negitive now | 111 | // dayOfWeek may be negitive now |
109 | // day of week is number of days to add to start day | 112 | // day of week is number of days to add to start day |
110 | 113 | ||
111 | freq *= 7; | 114 | freq *= 7; |
112 | // FALL-THROUGH !!!!! | 115 | // FALL-THROUGH !!!!! |
113 | case Event::Daily: | 116 | case Event::Daily: |
114 | // the add is for the possible fall through from weekly */ | 117 | // the add is for the possible fall through from weekly */ |
115 | if(e.start().date().addDays(dayOfWeek) > from) { | 118 | if(e.start().date().addDays(dayOfWeek) > from) { |
116 | /* first week exception */ | 119 | /* first week exception */ |
@@ -878,32 +881,39 @@ void DateBookDB::loadFile( const QString &strFile ) | |||
878 | case FAction: | 881 | case FAction: |
879 | currentAction = value.toInt(); | 882 | currentAction = value.toInt(); |
880 | break; | 883 | break; |
881 | case FActionKey: | 884 | case FActionKey: |
882 | journalKey = value.toInt(); | 885 | journalKey = value.toInt(); |
883 | break; | 886 | break; |
884 | case FJournalOrigHadRepeat: | 887 | case FJournalOrigHadRepeat: |
885 | origHadRepeat = value.toInt(); | 888 | origHadRepeat = value.toInt(); |
886 | break; | 889 | break; |
887 | default: | 890 | default: |
888 | qDebug( "huh??? missing enum? -- attr.: %s", attr ); | 891 | qDebug( "huh??? missing enum? -- attr.: %s", attr ); |
889 | break; | 892 | break; |
890 | } | 893 | } |
891 | #endif | 894 | #endif |
892 | } | 895 | } |
893 | // "post processing" (dates, times, alarm, recurrence) | 896 | // "post processing" (dates, times, alarm, recurrence) |
897 | |||
898 | // other half of 1169 fixlet without getting into regression | ||
899 | // if rp.days == 0 and rp.type == Event::Weekly | ||
900 | if ( rp.type == Event::Weekly && rp.days == 0 ) | ||
901 | rp.days = Event::day( e.start().date().dayOfWeek() ); | ||
902 | |||
903 | |||
894 | // start date/time | 904 | // start date/time |
895 | e.setRepeat( rp.type != Event::NoRepeat, rp ); | 905 | e.setRepeat( rp.type != Event::NoRepeat, rp ); |
896 | 906 | ||
897 | if ( alarmTime != -1 ) | 907 | if ( alarmTime != -1 ) |
898 | e.setAlarm( TRUE, alarmTime, alarmSound ); | 908 | e.setAlarm( TRUE, alarmTime, alarmSound ); |
899 | 909 | ||
900 | // now do our action based on the current action... | 910 | // now do our action based on the current action... |
901 | switch ( currentAction ) { | 911 | switch ( currentAction ) { |
902 | case ACTION_ADD: | 912 | case ACTION_ADD: |
903 | addJFEvent( e ); | 913 | addJFEvent( e ); |
904 | break; | 914 | break; |
905 | case ACTION_REMOVE: | 915 | case ACTION_REMOVE: |
906 | removeJFEvent( e ); | 916 | removeJFEvent( e ); |
907 | break; | 917 | break; |
908 | case ACTION_REPLACE: | 918 | case ACTION_REPLACE: |
909 | // be a little bit careful, | 919 | // be a little bit careful, |