Changeset View
Changeset View
Standalone View
Standalone View
src/occurrenceiterator.cpp
Show All 30 Lines | |||||
31 | 31 | | |||
32 | #include "occurrenceiterator.h" | 32 | #include "occurrenceiterator.h" | ||
33 | #include "calendar.h" | 33 | #include "calendar.h" | ||
34 | #include "calfilter.h" | 34 | #include "calfilter.h" | ||
35 | #include "utils.h" | 35 | #include "utils.h" | ||
36 | 36 | | |||
37 | #include <QDate> | 37 | #include <QDate> | ||
38 | 38 | | |||
39 | using namespace KCalCore; | 39 | using namespace KCalendarCore; | ||
40 | 40 | | |||
41 | /** | 41 | /** | ||
42 | Private class that helps to provide binary compatibility between releases. | 42 | Private class that helps to provide binary compatibility between releases. | ||
43 | @internal | 43 | @internal | ||
44 | */ | 44 | */ | ||
45 | //@cond PRIVATE | 45 | //@cond PRIVATE | ||
46 | class Q_DECL_HIDDEN KCalCore::OccurrenceIterator::Private | 46 | class Q_DECL_HIDDEN KCalendarCore::OccurrenceIterator::Private | ||
47 | { | 47 | { | ||
48 | public: | 48 | public: | ||
49 | Private(OccurrenceIterator *qq) | 49 | Private(OccurrenceIterator *qq) | ||
50 | : q(qq), | 50 | : q(qq), | ||
51 | occurrenceIt(occurrenceList) | 51 | occurrenceIt(occurrenceList) | ||
52 | { | 52 | { | ||
53 | } | 53 | } | ||
54 | 54 | | |||
Show All 15 Lines | 59 | struct Occurrence { | |||
70 | QDateTime recurrenceId; | 70 | QDateTime recurrenceId; | ||
71 | QDateTime startDate; | 71 | QDateTime startDate; | ||
72 | }; | 72 | }; | ||
73 | QList<Occurrence> occurrenceList; | 73 | QList<Occurrence> occurrenceList; | ||
74 | QListIterator<Occurrence> occurrenceIt; | 74 | QListIterator<Occurrence> occurrenceIt; | ||
75 | Occurrence current; | 75 | Occurrence current; | ||
76 | 76 | | |||
77 | /* | 77 | /* | ||
78 | * KCalCore::CalFilter can't handle individual occurrences. | 78 | * KCalendarCore::CalFilter can't handle individual occurrences. | ||
79 | * When filtering completed to-dos, the CalFilter doesn't hide | 79 | * When filtering completed to-dos, the CalFilter doesn't hide | ||
80 | * them if it's a recurring to-do. | 80 | * them if it's a recurring to-do. | ||
81 | */ | 81 | */ | ||
82 | bool occurrenceIsHidden(const Calendar &calendar, | 82 | bool occurrenceIsHidden(const Calendar &calendar, | ||
83 | const Incidence::Ptr &inc, | 83 | const Incidence::Ptr &inc, | ||
84 | const QDateTime &occurrenceDate) | 84 | const QDateTime &occurrenceDate) | ||
85 | { | 85 | { | ||
86 | if ((inc->type() == Incidence::TypeTodo) && | 86 | if ((inc->type() == Incidence::TypeTodo) && | ||
87 | calendar.filter() && | 87 | calendar.filter() && | ||
88 | (calendar.filter()->criteria() & KCalCore::CalFilter::HideCompletedTodos)) { | 88 | (calendar.filter()->criteria() & KCalendarCore::CalFilter::HideCompletedTodos)) { | ||
89 | if (inc->recurs()) { | 89 | if (inc->recurs()) { | ||
90 | const Todo::Ptr todo = inc.staticCast<Todo>(); | 90 | const Todo::Ptr todo = inc.staticCast<Todo>(); | ||
91 | if (todo && (occurrenceDate < todo->dtDue())) { | 91 | if (todo && (occurrenceDate < todo->dtDue())) { | ||
92 | return true; | 92 | return true; | ||
93 | } | 93 | } | ||
94 | } else if (inc->hasRecurrenceId()) { | 94 | } else if (inc->hasRecurrenceId()) { | ||
95 | const Todo::Ptr mainTodo = calendar.todo(inc->uid()); | 95 | const Todo::Ptr mainTodo = calendar.todo(inc->uid()); | ||
96 | if (mainTodo && mainTodo->isCompleted()) { | 96 | if (mainTodo && mainTodo->isCompleted()) { | ||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | |||||
173 | * incidence, which would be even more efficient. | 173 | * incidence, which would be even more efficient. | ||
174 | * | 174 | * | ||
175 | * By making this class a friend of calendar, we could also use the internally | 175 | * By making this class a friend of calendar, we could also use the internally | ||
176 | * available data structures. | 176 | * available data structures. | ||
177 | */ | 177 | */ | ||
178 | OccurrenceIterator::OccurrenceIterator(const Calendar &calendar, | 178 | OccurrenceIterator::OccurrenceIterator(const Calendar &calendar, | ||
179 | const QDateTime &start, | 179 | const QDateTime &start, | ||
180 | const QDateTime &end) | 180 | const QDateTime &end) | ||
181 | : d(new KCalCore::OccurrenceIterator::Private(this)) | 181 | : d(new KCalendarCore::OccurrenceIterator::Private(this)) | ||
182 | { | 182 | { | ||
183 | d->start = start; | 183 | d->start = start; | ||
184 | d->end = end; | 184 | d->end = end; | ||
185 | 185 | | |||
186 | Event::List events = calendar.rawEvents(start.date(), end.date(), start.timeZone()); | 186 | Event::List events = calendar.rawEvents(start.date(), end.date(), start.timeZone()); | ||
187 | if (calendar.filter()) { | 187 | if (calendar.filter()) { | ||
188 | calendar.filter()->apply(&events); | 188 | calendar.filter()->apply(&events); | ||
189 | } | 189 | } | ||
190 | 190 | | |||
191 | Todo::List todos = calendar.rawTodos(start.date(), end.date(), start.timeZone()); | 191 | Todo::List todos = calendar.rawTodos(start.date(), end.date(), start.timeZone()); | ||
192 | if (calendar.filter()) { | 192 | if (calendar.filter()) { | ||
193 | calendar.filter()->apply(&todos); | 193 | calendar.filter()->apply(&todos); | ||
194 | } | 194 | } | ||
195 | 195 | | |||
196 | Journal::List journals; | 196 | Journal::List journals; | ||
197 | const Journal::List allJournals = calendar.rawJournals(); | 197 | const Journal::List allJournals = calendar.rawJournals(); | ||
198 | for (const KCalCore::Journal::Ptr &journal : allJournals) { | 198 | for (const KCalendarCore::Journal::Ptr &journal : allJournals) { | ||
199 | const QDate journalStart = journal->dtStart().toTimeZone(start.timeZone()).date(); | 199 | const QDate journalStart = journal->dtStart().toTimeZone(start.timeZone()).date(); | ||
200 | if (journal->dtStart().isValid() && | 200 | if (journal->dtStart().isValid() && | ||
201 | journalStart >= start.date() && | 201 | journalStart >= start.date() && | ||
202 | journalStart <= end.date()) { | 202 | journalStart <= end.date()) { | ||
203 | journals << journal; | 203 | journals << journal; | ||
204 | } | 204 | } | ||
205 | } | 205 | } | ||
206 | 206 | | |||
207 | if (calendar.filter()) { | 207 | if (calendar.filter()) { | ||
208 | calendar.filter()->apply(&journals); | 208 | calendar.filter()->apply(&journals); | ||
209 | } | 209 | } | ||
210 | 210 | | |||
211 | const Incidence::List incidences = | 211 | const Incidence::List incidences = | ||
212 | KCalCore::Calendar::mergeIncidenceList(events, todos, journals); | 212 | KCalendarCore::Calendar::mergeIncidenceList(events, todos, journals); | ||
213 | d->setupIterator(calendar, incidences); | 213 | d->setupIterator(calendar, incidences); | ||
214 | } | 214 | } | ||
215 | 215 | | |||
216 | OccurrenceIterator::OccurrenceIterator(const Calendar &calendar, | 216 | OccurrenceIterator::OccurrenceIterator(const Calendar &calendar, | ||
217 | const Incidence::Ptr &incidence, | 217 | const Incidence::Ptr &incidence, | ||
218 | const QDateTime &start, | 218 | const QDateTime &start, | ||
219 | const QDateTime &end) | 219 | const QDateTime &end) | ||
220 | : d(new KCalCore::OccurrenceIterator::Private(this)) | 220 | : d(new KCalendarCore::OccurrenceIterator::Private(this)) | ||
221 | { | 221 | { | ||
222 | Q_ASSERT(incidence); | 222 | Q_ASSERT(incidence); | ||
223 | d->start = start; | 223 | d->start = start; | ||
224 | d->end = end; | 224 | d->end = end; | ||
225 | d->setupIterator(calendar, Incidence::List() << incidence); | 225 | d->setupIterator(calendar, Incidence::List() << incidence); | ||
226 | } | 226 | } | ||
227 | 227 | | |||
228 | OccurrenceIterator::~OccurrenceIterator() | 228 | OccurrenceIterator::~OccurrenceIterator() | ||
Show All 27 Lines |