author | zautrix <zautrix> | 2005-03-18 15:12:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-18 15:12:58 (UTC) |
commit | f9f521c487143641b2cf077d04fe1c475001bce2 (patch) (side-by-side diff) | |
tree | 4ffac6d14ceb3e5d77f7634f2b2a49fd91a9e77a | |
parent | 66bc0202d4e2306f7029362fe09d0c7ab0e7cc36 (diff) | |
download | kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.zip kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.tar.gz kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.tar.bz2 |
rec fix
-rw-r--r-- | korganizer/komonthview.cpp | 15 | ||||
-rw-r--r-- | libkcal/recurrence.cpp | 26 |
2 files changed, 10 insertions, 31 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index cb69832..004ff50 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -1257,18 +1257,15 @@ void KOMonthView::updateView() QDateTime dt; bool ok; QDate endDate = mStartDate.addDays( timeSpan ); for( event = events.first(); event; event = events.next() ) { // for event if ( event->doesRecur() ) { bool last; - qDebug("********************************************** "); - qDebug("Event summary: %s ", event->summary().latin1()); QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); QDateTime incidenceEnd; int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); - qDebug("eventlen %d ", eventlen); bool invalid = false; while( true ) { if ( incidenceStart.isValid() ) { incidenceEnd = incidenceStart.addDays( eventlen ); int st = incidenceStart.date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend @@ -1285,30 +1282,24 @@ void KOMonthView::updateView() } } } else { if ( invalid ) break; invalid = true; - qDebug("invalid %s", event->summary().latin1()); + //qDebug("invalid %s", event->summary().latin1()); incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; } if ( last ) break; bool ok; - qDebug("TRY next occurence %s ", incidenceStart.toString().latin1()); incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); - if ( ! ok ) { - qDebug("NOT OK "); + if ( ! ok ) break; - } - if ( incidenceStart.date() > endDate ) { - qDebug("incidenceStart.date() > endDate "); + if ( incidenceStart.date() > endDate ) break; } - qDebug("next occurence %s ", incidenceStart.toString().latin1()); - } } else { // no recur int st = event->dtStart().date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( event->dtEnd().date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp index 8a175c9..6ee5499 100644 --- a/libkcal/recurrence.cpp +++ b/libkcal/recurrence.cpp @@ -973,13 +973,13 @@ bool Recurrence::recursSecondly(const QDate &qd, int secondFreq) const ((rDuration > 0) && (qd <= endDate()) || ((rDuration == 0) && (qd <= rEndDateTime.date())) || (rDuration == -1))) { // The date queried falls within the range of the event. if (secondFreq < 24*3600) return true; // the event recurs at least once each day - int after = mRecurStart.secsTo(QDateTime(qd)); + int after = mRecurStart.secsTo(QDateTime(qd)) - 1; if (after / secondFreq != (after + 24*3600) / secondFreq) return true; } return false; } @@ -1185,25 +1185,24 @@ QDate Recurrence::getNextDateNoTime(const QDate &preDate, bool *last) const switch (recurs) { case rDaily: nextDate = dStart.addDays((dStart.daysTo(preDate)/rFreq + 1) * rFreq); break; case rWeekly: { - QDate start = dStart.addDays(1 - dStart.dayOfWeek()); // start of week for dStart + QDate start = dStart.addDays(-((dStart.dayOfWeek() - rWeekStart + 7)%7)); // start of week for dStart int earliestDayOfWeek = earliestDate.dayOfWeek(); int weeksAhead = start.daysTo(earliestDate) / 7; int notThisWeek = weeksAhead % rFreq; // zero if this week is a recurring week weeksAhead -= notThisWeek; // latest week which recurred int weekday = 0; // First check for any remaining day this week, if this week is a recurring week if (!notThisWeek) weekday = getFirstDayInWeek(earliestDayOfWeek); // Check for a day in the next scheduled week - if (!weekday && earliestDayOfWeek > 1) + if (!weekday ) weekday = getFirstDayInWeek(rWeekStart) + rFreq*7; - if (weekday) nextDate = start.addDays(weeksAhead*7 + weekday - 1); break; } case rMonthlyDay: case rMonthlyPos: { int startYear = dStart.year(); @@ -1212,13 +1211,13 @@ QDate Recurrence::getNextDateNoTime(const QDate &preDate, bool *last) const int monthsAhead = (earliestYear - startYear)*12 + earliestDate.month() - startMonth; int notThisMonth = monthsAhead % rFreq; // zero if this month is a recurring month monthsAhead -= notThisMonth; // latest month which recurred // Check for the first later day in the current month if (!notThisMonth) nextDate = getFirstDateInMonth(earliestDate); - if (!nextDate.isValid() && earliestDate.day() > 1) { + if (!nextDate.isValid() ) { // Check for a day in the next scheduled month int months = startMonth - 1 + monthsAhead + rFreq; nextDate = getFirstDateInMonth(QDate(startYear + months/12, months%12 + 1, 1)); } break; } @@ -1269,30 +1268,28 @@ QDate Recurrence::getPreviousDateNoTime(const QDate &afterDate, bool *last) cons switch (recurs) { case rDaily: prevDate = dStart.addDays((dStart.daysTo(latestDate) / rFreq) * rFreq); break; case rWeekly: { - QDate start = dStart.addDays(1 - dStart.dayOfWeek()); // start of week for dStart + QDate start = dStart.addDays(-((dStart.dayOfWeek() - rWeekStart + 7)%7)); // start of week for dStart int latestDayOfWeek = latestDate.dayOfWeek(); int weeksAhead = start.daysTo(latestDate) / 7; int notThisWeek = weeksAhead % rFreq; // zero if this week is a recurring week weeksAhead -= notThisWeek; // latest week which recurred int weekday = 0; // First check for any previous day this week, if this week is a recurring week if (!notThisWeek) weekday = getLastDayInWeek(latestDayOfWeek); // Check for a day in the previous scheduled week if (!weekday) { - int weekEnd = (rWeekStart + 5)%7 + 1; - if (latestDayOfWeek < weekEnd) { if (!notThisWeek) weeksAhead -= rFreq; + int weekEnd = (rWeekStart + 5)%7 + 1; weekday = getLastDayInWeek(weekEnd); } - } if (weekday) prevDate = start.addDays(weeksAhead*7 + weekday - 1); break; } case rMonthlyDay: case rMonthlyPos: { @@ -3397,17 +3394,8 @@ QDate Recurrence::getLastDateInYear(const QDate &latestDate) const } return QDate(); } void Recurrence::dump() const { - kdDebug() << "Recurrence::dump():" << endl; - - kdDebug() << " type: " << recurs << endl; - - kdDebug() << " rDays: " << endl; - int i; - for( i = 0; i < 7; ++i ) { - kdDebug() << " " << i << ": " - << ( rDays.testBit( i ) ? "true" : "false" ) << endl; - } + ; } |