Changeset View
Changeset View
Standalone View
Standalone View
kcalcore/occurrenceiterator.cpp
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | public: | ||||
void setupIterator(const Calendar &calendar, const Incidence::List &incidences) | void setupIterator(const Calendar &calendar, const Incidence::List &incidences) | ||||
{ | { | ||||
foreach(const Incidence::Ptr &inc, incidences) { | foreach(const Incidence::Ptr &inc, incidences) { | ||||
if (inc->hasRecurrenceId()) { | if (inc->hasRecurrenceId()) { | ||||
continue; | continue; | ||||
} | } | ||||
if (inc->recurs()) { | if (inc->recurs()) { | ||||
Incidence::Ptr incidence(inc), lastInc(inc); | |||||
mollekopf: lastInc and lastOffset seem to be unused?
Either remove, or otherwise you probably also have to… | |||||
Not Done Inline ActionsNo lastInc and lastOffset are used later on in the next for loop ( l151, l162). So we can move the two variables back to ther further position. But on the other side lastOffset and lastInc are used internally in the for loop and only need to valid if resetIncidence is True. IMO I think just leave it like i did now, because otherwise we would mix cleanup & patching. knauss: No lastInc and lastOffset are used later on in the next for loop ( l151, l162).
So we can move… | |||||
qint64 offset(0), lastOffset(0); | |||||
KDateTime occurrenceStartDate; | |||||
QHash<KDateTime, Incidence::Ptr> recurrenceIds; | QHash<KDateTime, Incidence::Ptr> recurrenceIds; | ||||
KDateTime incidenceRecStart = inc->dateTime(Incidence::RoleRecurrenceStart); | KDateTime incidenceRecStart = inc->dateTime(Incidence::RoleRecurrenceStart); | ||||
foreach(const Incidence::Ptr &exception, calendar.instances(inc)) { | foreach(const Incidence::Ptr &exception, calendar.instances(inc)) { | ||||
if (incidenceRecStart.isValid()) | if (incidenceRecStart.isValid()) | ||||
recurrenceIds.insert(exception->recurrenceId().toTimeSpec(incidenceRecStart.timeSpec()), exception); | recurrenceIds.insert(exception->recurrenceId().toTimeSpec(incidenceRecStart.timeSpec()), exception); | ||||
// For exceptions with thisAndFuture we need to store this as incidence, if the exception has already happend | |||||
// We don't have a sorted list of exception, that's why we have to test the current recurrenceId against the stored | |||||
if (exception->thisAndFuture() && start >= exception->recurrenceId() | |||||
&& (!incidence->recurrenceId().isValid() || incidence->recurrenceId() < exception->recurrenceId())) { | |||||
incidence = exception; | |||||
occurrenceStartDate = incidence->dtStart(); | |||||
offset = incidence->recurrenceId().secsTo_long(incidence->dtStart()); | |||||
} | |||||
} | } | ||||
const bool isAllDay = inc->allDay(); | const bool isAllDay = inc->allDay(); | ||||
const DateTimeList occurrences = inc->recurrence()->timesInInterval(start, end); | const DateTimeList occurrences = inc->recurrence()->timesInInterval(start, end); | ||||
Incidence::Ptr incidence(inc), lastInc(inc); | |||||
qint64 offset(0), lastOffset(0); | |||||
KDateTime occurrenceStartDate; | |||||
foreach(KDateTime recurrenceId, occurrences) { //krazy:exclude=foreach | foreach(KDateTime recurrenceId, occurrences) { //krazy:exclude=foreach | ||||
//timesInInterval generates always date-times, | //timesInInterval generates always date-times, | ||||
//which is not what we want for all-day events | //which is not what we want for all-day events | ||||
recurrenceId.setDateOnly(isAllDay); | recurrenceId.setDateOnly(isAllDay); | ||||
occurrenceStartDate = recurrenceId; | occurrenceStartDate = recurrenceId; | ||||
bool resetIncidence = false; | bool resetIncidence = false; | ||||
if (recurrenceIds.contains(recurrenceId)) { | if (recurrenceIds.contains(recurrenceId)) { | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return d->current.startDate; | return d->current.startDate; | ||||
} | } | ||||
KDateTime OccurrenceIterator::recurrenceId() const | KDateTime OccurrenceIterator::recurrenceId() const | ||||
{ | { | ||||
return d->current.recurrenceId; | return d->current.recurrenceId; | ||||
} | } | ||||
No newline at end of file | No newline at end of file |
lastInc and lastOffset seem to be unused?
Either remove, or otherwise you probably also have to adjust lastInc when setting the exception on incidence.