KCalendarCore

memorycalendar.cpp
Go to the documentation of this file.
1/*
2 This file is part of the kcalcore library.
3
4 SPDX-FileCopyrightText: 1998 Preston Brown <pbrown@kde.org>
5 SPDX-FileCopyrightText: 2001, 2003, 2004 Cornelius Schumacher <schumacher@kde.org>
6 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7
8 SPDX-License-Identifier: LGPL-2.0-or-later
9*/
10/**
11 @file
12 This file is part of the API for handling calendar data and
13 defines the MemoryCalendar class.
14
15 @brief
16 This class provides a calendar stored as a local file.
17
18 @author Preston Brown <pbrown@kde.org>
19 @author Cornelius Schumacher <schumacher@kde.org>
20 */
21
22#include "memorycalendar.h"
23#include "calformat.h"
24#include "kcalendarcore_debug.h"
25
26#include <QDate>
27
28#include <functional>
29
30using namespace KCalendarCore;
31
32/**
33 Private class that helps to provide binary compatibility between releases.
34 @internal
35*/
36//@cond PRIVATE
37class Q_DECL_HIDDEN KCalendarCore::MemoryCalendar::Private
38{
39private:
40 static constexpr int incidenceTypeCount = 4;
41
42public:
43 Private(MemoryCalendar *qq)
44 : q(qq)
45 , mFormat(nullptr)
46 , mUpdateLastModified(true)
47 {
48 }
49 ~Private()
50 {
51 }
52
54 CalFormat *mFormat; // calendar format
55 QString mIncidenceBeingUpdated; // Instance identifier of Incidence currently being updated
56 bool mUpdateLastModified; // Call setLastModified() on incidence modific ations
57
58 /**
59 * List of all incidences.
60 * First indexed by incidence->type(), then by incidence->uid();
61 */
62 QMultiHash<QString, Incidence::Ptr> mIncidences[incidenceTypeCount];
63
64 /**
65 * Has all incidences, indexed by identifier.
66 */
68
69 /**
70 * Contains incidences ( to-dos; non-recurring, non-multiday events; journals; )
71 * indexed by start/due date.
72 *
73 * The QMap key is the incidence->type().
74 * The QMultiHash key is the dtStart/dtDue() converted to calendar's timezone
75 *
76 * Note: We had 3 variables, mJournalsForDate, mTodosForDate and mEventsForDate
77 * but i merged them into one (indexed by type) because it simplifies code using
78 * it. No need to if else based on type.
79 */
80 QMultiHash<QDate, Incidence::Ptr> mIncidencesForDate[incidenceTypeCount];
81
82 void insertIncidence(const Incidence::Ptr &incidence);
83
84 Incidence::Ptr incidence(const QString &uid, IncidenceBase::IncidenceType type, const QDateTime &recurrenceId = {}) const;
85
86 bool deleteIncidence(const QString &uid, IncidenceBase::IncidenceType type, const QDateTime &recurrenceId = {});
87
88 void deleteAllIncidences(IncidenceBase::IncidenceType type);
89
90 template<typename IncidenceType, typename Key>
91 void forIncidences(const QMultiHash<Key, Incidence::Ptr> &incidences, const Key &key, std::function<void(const typename IncidenceType::Ptr &)> &&op) const
92 {
93 for (auto it = incidences.constFind(key), end = incidences.cend(); it != end && it.key() == key; ++it) {
94 op(it.value().template staticCast<IncidenceType>());
95 }
96 }
97
98 template<typename IncidenceType, typename Key>
99 void forIncidences(const QMultiHash<Key, Incidence::Ptr> &incidences, std::function<void(const typename IncidenceType::Ptr &)> &&op) const
100 {
101 for (const auto &incidence : incidences) {
102 op(incidence.template staticCast<IncidenceType>());
103 }
104 }
105
106 template<typename IncidenceType>
107 typename IncidenceType::List castIncidenceList(const QMultiHash<QString, Incidence::Ptr> &incidences) const
108 {
109 typename IncidenceType::List list;
110 list.reserve(incidences.size());
111 std::transform(incidences.cbegin(), incidences.cend(), std::back_inserter(list), [](const Incidence::Ptr &inc) {
112 return inc.staticCast<IncidenceType>();
113 });
114 return list;
115 }
116
117 template<typename IncidenceType>
118 typename IncidenceType::List incidenceInstances(IncidenceBase::IncidenceType type, const Incidence::Ptr &incidence) const
119 {
120 typename IncidenceType::List list;
121 forIncidences<IncidenceType, QString>(mIncidences[type], incidence->uid(), [&list](const typename IncidenceType::Ptr &incidence) {
122 if (incidence->hasRecurrenceId()) {
123 list.push_back(incidence);
124 }
125 });
126 return list;
127 }
128
129 Incidence::Ptr findIncidence(const QMultiHash<QString, Incidence::Ptr> &incidences, const QString &uid, const QDateTime &recurrenceId) const
130 {
131 for (auto it = incidences.constFind(uid), end = incidences.cend(); it != end && it.key() == uid; ++it) {
132 const auto &incidence = it.value();
133 if (recurrenceId.isNull() && !incidence->hasRecurrenceId()) {
134 return incidence;
135 } else if (!recurrenceId.isNull() && incidence->hasRecurrenceId() && recurrenceId == incidence->recurrenceId()) {
136 return incidence;
137 }
138 }
139 return {};
140 }
141};
142//@endcond
143
145 : Calendar(timeZone)
146 , d(new KCalendarCore::MemoryCalendar::Private(this))
147{
148}
149
151 : Calendar(timeZoneId)
152 , d(new KCalendarCore::MemoryCalendar::Private(this))
153{
154}
155
157{
158 setObserversEnabled(false);
159
160 // Don't call the virtual function deleteEvents() etc, the base class might have
161 // other ways of deleting the data.
162 d->deleteAllIncidences(Incidence::TypeEvent);
163 d->deleteAllIncidences(Incidence::TypeTodo);
164 d->deleteAllIncidences(Incidence::TypeJournal);
165
166 d->mIncidencesByIdentifier.clear();
167
168 setModified(false);
169
171
172 delete d;
173}
174
175void MemoryCalendar::doSetTimeZone(const QTimeZone &timeZone)
176{
177 // Reset date based hashes before storing for the new zone.
178 for (auto &table : d->mIncidencesForDate) {
179 table.clear();
180 }
181
182 for (auto &table : d->mIncidences) {
183 for (const auto &incidence : table) {
185 if (dt.isValid()) {
186 d->mIncidencesForDate[incidence->type()].insert(dt.toTimeZone(timeZone).date(), incidence);
187 }
188 }
189 }
190}
191
193{
194 // Notify while the incidence is still available,
195 // this is necessary so korganizer still has time to query for exceptions
197 incidence->unRegisterObserver(this);
199 const QString &uid = incidence->uid();
200 bool deleted = d->deleteIncidence(uid, type, incidence->recurrenceId());
201 if (deleted) {
202 setModified(true);
203
204 // Delete child-incidences.
205 if (!incidence->hasRecurrenceId() && incidence->recurs()) {
207 }
208 } else {
209 qCWarning(KCALCORE_LOG) << incidence->typeStr() << " not found. uid=" << uid;
210 }
212 return deleted;
213}
214
216{
218 for (auto it = d->mIncidences[incidence->type()].constFind(incidence->uid()), end = d->mIncidences[incidence->type()].constEnd();
219 it != end && it.key() == incidence->uid();
220 ++it) {
221 if (it.value()->hasRecurrenceId()) {
222 qCDebug(KCALCORE_LOG) << "deleting child"
223 << ", type=" << int(incidence->type()) << ", uid="
224 << incidence->uid()
225 // << ", start=" << i->dtStart()
226 << " from calendar";
227 // Don't call deleteIncidence() now since it's modifying the
228 // mIncidences map we're iterating over.
229 instances.append(it.value());
230 }
231 }
234 }
235
236 return true;
237}
238
239//@cond PRIVATE
240bool MemoryCalendar::Private::deleteIncidence(const QString &uid, IncidenceBase::IncidenceType type, const QDateTime &recurrenceId)
241{
242 for (auto it = mIncidences[type].find(uid), end = mIncidences[type].end(); it != end && it.key() == uid; ++it) {
243 Incidence::Ptr incidence = it.value();
244 if (recurrenceId.isNull() && incidence->hasRecurrenceId()) {
245 continue;
246 } else if (!recurrenceId.isNull() && (!incidence->hasRecurrenceId() || recurrenceId != incidence->recurrenceId())) {
247 continue;
248 }
249 mIncidences[type].erase(it);
250 mIncidencesByIdentifier.remove(incidence->instanceIdentifier());
252 if (dt.isValid()) {
253 mIncidencesForDate[type].remove(dt.toTimeZone(q->timeZone()).date(), incidence);
254 }
255 return true;
256 }
257 return false;
258}
259
260void MemoryCalendar::Private::deleteAllIncidences(Incidence::IncidenceType incidenceType)
261{
262 for (auto &incidence : mIncidences[incidenceType]) {
264 incidence->unRegisterObserver(q);
265 }
266 mIncidences[incidenceType].clear();
267 mIncidencesForDate[incidenceType].clear();
268}
269
270Incidence::Ptr MemoryCalendar::Private::incidence(const QString &uid, Incidence::IncidenceType type, const QDateTime &recurrenceId) const
271{
272 return findIncidence(mIncidences[type], uid, recurrenceId);
273}
274
275void MemoryCalendar::Private::insertIncidence(const Incidence::Ptr &incidence)
276{
277 const QString uid = incidence->uid();
279 if (!mIncidences[type].contains(uid, incidence)) {
280 mIncidences[type].insert(uid, incidence);
281 mIncidencesByIdentifier.insert(incidence->instanceIdentifier(), incidence);
283 if (dt.isValid()) {
284 mIncidencesForDate[type].insert(dt.toTimeZone(q->timeZone()).date(), incidence);
285 }
286
287 } else {
288 // if we already have an to-do with this UID, it must be the same incidence,
289 // otherwise something's really broken
290 qCWarning(KCALCORE_LOG) << "Calendar already contains an incidence of type" << type << "with UID" << uid << ", not inserting it again";
291 const auto existing = mIncidences[type].value(uid);
292 if (existing != incidence) {
293 qCWarning(KCALCORE_LOG) << "The new incidence is not the same as the existing incidence!";
294 qCWarning(KCALCORE_LOG) << "The existing incidence is summary=" << existing->summary() << ", start=" << existing->dtStart();
295 qCWarning(KCALCORE_LOG) << "The new incidence is summary=" << incidence->summary() << ", start=" << incidence->dtStart();
296 }
297 Q_ASSERT(existing == incidence);
298 }
299}
300//@endcond
301
302bool MemoryCalendar::addIncidence(const Incidence::Ptr &incidence)
303{
304 d->insertIncidence(incidence);
305
307
308 incidence->registerObserver(this);
309
310 setModified(true);
311
312 return true;
313}
314
315bool MemoryCalendar::addEvent(const Event::Ptr &event)
316{
317 return addIncidence(event);
318}
319
321{
322 return deleteIncidence(event);
323}
324
326{
328}
329
330Event::Ptr MemoryCalendar::event(const QString &uid, const QDateTime &recurrenceId) const
331{
332 return d->incidence(uid, Incidence::TypeEvent, recurrenceId).staticCast<Event>();
333}
334
335bool MemoryCalendar::addTodo(const Todo::Ptr &todo)
336{
337 return addIncidence(todo);
338}
339
341{
342 return deleteIncidence(todo);
343}
344
346{
348}
349
350Todo::Ptr MemoryCalendar::todo(const QString &uid, const QDateTime &recurrenceId) const
351{
352 return d->incidence(uid, Incidence::TypeTodo, recurrenceId).staticCast<Todo>();
353}
354
356{
357 return Calendar::sortTodos(d->castIncidenceList<Todo>(d->mIncidences[Incidence::TypeTodo]), sortField, sortDirection);
358}
359
360Todo::List MemoryCalendar::todoInstances(const Incidence::Ptr &todo, TodoSortField sortField, SortDirection sortDirection) const
361{
362 return Calendar::sortTodos(d->incidenceInstances<Todo>(Incidence::TypeTodo, todo), sortField, sortDirection);
363}
364
366{
368
369 d->forIncidences<Todo>(d->mIncidencesForDate[Incidence::TypeTodo], date, [&todoList](const Todo::Ptr &todo) {
370 todoList.append(todo);
371 });
372
373 // Iterate over all todos. Look for recurring todoss that occur on this date
374 d->forIncidences<Todo>(d->mIncidences[Incidence::TypeTodo], [this, &todoList, &date](const Todo::Ptr &todo) {
375 if (todo->recurs() && todo->recursOn(date, timeZone())) {
376 todoList.append(todo);
377 }
378 });
379
380 return todoList;
381}
382
383Todo::List MemoryCalendar::rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone, bool inclusive) const
384{
385 Q_UNUSED(inclusive); // use only exact dtDue/dtStart, not dtStart and dtEnd
386
388 const auto ts = timeZone.isValid() ? timeZone : this->timeZone();
389 QDateTime st(start, QTime(0, 0, 0), ts);
390 QDateTime nd(end, QTime(23, 59, 59, 999), ts);
391
392 // Get todos
393 for (const auto &incidence : d->mIncidences[Incidence::TypeTodo]) {
394 const auto todo = incidence.staticCast<Todo>();
395
396 QDateTime rStart = todo->hasDueDate() ? todo->dtDue() : todo->hasStartDate() ? todo->dtStart() : QDateTime();
397 if (!rStart.isValid()) {
398 continue;
399 }
400
401 if (!todo->recurs()) { // non-recurring todos
402 if (nd.isValid() && nd < rStart) {
403 continue;
404 }
405 if (st.isValid() && rStart < st) {
406 continue;
407 }
408 } else { // recurring events
409 switch (todo->recurrence()->duration()) {
410 case -1: // infinite
411 break;
412 case 0: // end date given
413 default: // count given
414 QDateTime rEnd(todo->recurrence()->endDate(), QTime(23, 59, 59, 999), ts);
415 if (!rEnd.isValid()) {
416 continue;
417 }
418 if (st.isValid() && rEnd < st) {
419 continue;
420 }
421 break;
422 } // switch(duration)
423 } // if(recurs)
424
425 todoList.append(todo);
426 }
427
428 return todoList;
429}
430
431Alarm::List MemoryCalendar::alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms) const
432{
435
436 d->forIncidences<Event>(d->mIncidences[Incidence::TypeEvent], [this, &alarmList, &from, &to](const Event::Ptr &e) {
437 if (e->recurs()) {
438 appendRecurringAlarms(alarmList, e, from, to);
439 } else {
440 appendAlarms(alarmList, e, from, to);
441 }
442 });
443
444 d->forIncidences<Todo>(d->mIncidences[IncidenceBase::TypeTodo], [this, &alarmList, &from, &to](const Todo::Ptr &t) {
445 if (!t->isCompleted()) {
446 appendAlarms(alarmList, t, from, to);
447 if (t->recurs()) {
449 } else {
450 appendAlarms(alarmList, t, from, to);
451 }
452 }
453 });
454
455 return alarmList;
456}
457
459{
460 return d->mUpdateLastModified;
461}
462
464{
465 d->mUpdateLastModified = update;
466}
467
468void MemoryCalendar::incidenceUpdate(const QString &uid, const QDateTime &recurrenceId)
469{
470 Incidence::Ptr inc = incidence(uid, recurrenceId);
471
472 if (inc) {
473 if (!d->mIncidenceBeingUpdated.isEmpty()) {
474 qCWarning(KCALCORE_LOG) << "Incidence::update() called twice without an updated() call in between.";
475 }
476
477 // Save it so we can detect changes to uid or recurringId.
478 d->mIncidenceBeingUpdated = inc->instanceIdentifier();
479
481 if (dt.isValid()) {
482 d->mIncidencesForDate[inc->type()].remove(dt.toTimeZone(timeZone()).date(), inc);
483 }
484 }
485}
486
487void MemoryCalendar::incidenceUpdated(const QString &uid, const QDateTime &recurrenceId)
488{
489 Incidence::Ptr inc = incidence(uid, recurrenceId);
490
491 if (inc) {
492 if (d->mIncidenceBeingUpdated.isEmpty()) {
493 qCWarning(KCALCORE_LOG) << "Incidence::updated() called twice without an update() call in between.";
494 } else if (inc->instanceIdentifier() != d->mIncidenceBeingUpdated) {
495 // Instance identifier changed, update our hash table
496 d->mIncidencesByIdentifier.remove(d->mIncidenceBeingUpdated);
497 d->mIncidencesByIdentifier.insert(inc->instanceIdentifier(), inc);
498 }
499
500 d->mIncidenceBeingUpdated = QString();
501
502 if (d->mUpdateLastModified) {
503 inc->setLastModified(QDateTime::currentDateTimeUtc());
504 }
505 // we should probably update the revision number here,
506 // or internally in the Event itself when certain things change.
507 // need to verify with ical documentation.
508
510 if (dt.isValid()) {
511 d->mIncidencesForDate[inc->type()].insert(dt.toTimeZone(timeZone()).date(), inc);
512 }
513
515
516 setModified(true);
517 }
518}
519
520Event::List MemoryCalendar::rawEventsForDate(const QDate &date, const QTimeZone &timeZone, EventSortField sortField, SortDirection sortDirection) const
521{
523
524 if (!date.isValid()) {
525 // There can't be events on invalid dates
526 return eventList;
527 }
528
529 if (timeZone.isValid() && timeZone != this->timeZone()) {
530 // We cannot use the hash table on date, since time zone is different.
531 eventList = rawEvents(date, date, timeZone, false);
533 }
534
535 // Iterate over all non-recurring, single-day events that start on this date
536 d->forIncidences<Event>(d->mIncidencesForDate[Incidence::TypeEvent], date, [&eventList](const Event::Ptr &event) {
537 eventList.append(event);
538 });
539
540 // Iterate over all events. Look for recurring events that occur on this date
541 const auto ts = timeZone.isValid() ? timeZone : this->timeZone();
542 for (const auto &event : d->mIncidences[Incidence::TypeEvent]) {
543 const auto ev = event.staticCast<Event>();
544 if (ev->recurs()) {
545 if (ev->isMultiDay()) {
546 int extraDays = ev->dtStart().date().daysTo(ev->dtEnd().date());
547 for (int i = 0; i <= extraDays; ++i) {
548 if (ev->recursOn(date.addDays(-i), ts)) {
549 eventList.append(ev);
550 break;
551 }
552 }
553 } else {
554 if (ev->recursOn(date, ts)) {
555 eventList.append(ev);
556 }
557 }
558 } else {
559 if (ev->isMultiDay()) {
560 if (ev->dtStart().toTimeZone(ts).date() <= date && ev->dtEnd().toTimeZone(ts).date() >= date) {
561 eventList.append(ev);
562 }
563 }
564 }
565 }
566
568}
569
570Event::List MemoryCalendar::rawEvents(const QDate &start, const QDate &end, const QTimeZone &timeZone, bool inclusive) const
571{
573 const auto ts = timeZone.isValid() ? timeZone : this->timeZone();
574 QDateTime st(start, QTime(0, 0, 0), ts);
575 QDateTime nd(end, QTime(23, 59, 59, 999), ts);
576
577 // Get non-recurring events
578 for (const auto &e : d->mIncidences[Incidence::TypeEvent]) {
579 const auto event = e.staticCast<Event>();
580 QDateTime rStart = event->dtStart();
581 if (nd.isValid() && nd < rStart) {
582 continue;
583 }
584 if (inclusive && st.isValid() && rStart < st) {
585 continue;
586 }
587
588 if (!event->recurs()) { // non-recurring events
589 QDateTime rEnd = event->dtEnd();
590 if (st.isValid() && rEnd < st) {
591 continue;
592 }
593 if (inclusive && nd.isValid() && nd < rEnd) {
594 continue;
595 }
596 } else { // recurring events
597 switch (event->recurrence()->duration()) {
598 case -1: // infinite
599 if (inclusive) {
600 continue;
601 }
602 break;
603 case 0: // end date given
604 default: // count given
605 QDateTime rEnd(event->recurrence()->endDate(), QTime(23, 59, 59, 999), ts);
606 if (!rEnd.isValid()) {
607 continue;
608 }
609 if (st.isValid() && rEnd < st) {
610 continue;
611 }
612 if (inclusive && nd.isValid() && nd < rEnd) {
613 continue;
614 }
615 break;
616 } // switch(duration)
617 } // if(recurs)
618
619 eventList.append(event);
620 }
621
622 return eventList;
623}
624
626{
627 return Calendar::sortEvents(d->castIncidenceList<Event>(d->mIncidences[Incidence::TypeEvent]), sortField, sortDirection);
628}
629
631{
633}
634
635bool MemoryCalendar::addJournal(const Journal::Ptr &journal)
636{
637 return addIncidence(journal);
638}
639
641{
642 return deleteIncidence(journal);
643}
644
646{
648}
649
650Journal::Ptr MemoryCalendar::journal(const QString &uid, const QDateTime &recurrenceId) const
651{
652 return d->incidence(uid, Incidence::TypeJournal, recurrenceId).staticCast<Journal>();
653}
654
656{
657 return Calendar::sortJournals(d->castIncidenceList<Journal>(d->mIncidences[Incidence::TypeJournal]), sortField, sortDirection);
658}
659
661{
663}
664
666{
668
669 d->forIncidences<Journal>(d->mIncidencesForDate[Incidence::TypeJournal], date, [&journalList](const Journal::Ptr &journal) {
670 journalList.append(journal);
671 });
672
673 return journalList;
674}
675
676Incidence::Ptr MemoryCalendar::instance(const QString &identifier) const
677{
678 return d->mIncidencesByIdentifier.value(identifier);
679}
680
681void MemoryCalendar::virtual_hook(int id, void *data)
682{
683 Q_UNUSED(id);
684 Q_UNUSED(data);
685 Q_ASSERT(false);
686}
687
688#include "moc_memorycalendar.cpp"
This file is part of the API for handling calendar data and defines the CalFormat abstract base class...
An abstract base class that provides an interface to various calendar formats.
Definition calformat.h:39
Represents the main calendar class.
Definition calendar.h:133
QTimeZone timeZone() const
Get the time zone used for creating or modifying incidences in the Calendar.
Definition calendar.cpp:163
void appendAlarms(Alarm::List &alarms, const Incidence::Ptr &incidence, const QDateTime &from, const QDateTime &to) const
Appends alarms of incidence in interval to list of alarms.
Definition calendar.cpp:808
static Todo::List sortTodos(Todo::List &&todoList, TodoSortField sortField, SortDirection sortDirection)
Sort a list of Todos.
Definition calendar.cpp:444
void notifyIncidenceAboutToBeDeleted(const Incidence::Ptr &incidence)
Let Calendar subclasses notify that they will remove an Incidence.
Definition calendar.cpp:708
static Journal::List sortJournals(Journal::List &&journalList, JournalSortField sortField, SortDirection sortDirection)
Sort a list of Journals.
Definition calendar.cpp:532
void notifyIncidenceDeleted(const Incidence::Ptr &incidence)
Let Calendar subclasses notify that they removed an Incidence.
Definition calendar.cpp:723
virtual Incidence::List instances(const Incidence::Ptr &incidence) const
Returns an unfiltered list of all exceptions of this recurring incidence.
Definition calendar.cpp:264
Incidence::Ptr incidence(const QString &uid, const QDateTime &recurrenceId={}) const
Returns the Incidence associated with the given unique identifier.
Definition calendar.cpp:407
void setModified(bool modified)
Sets if the calendar has been modified.
Definition calendar.cpp:630
void notifyIncidenceAdded(const Incidence::Ptr &incidence)
Let Calendar subclasses notify that they inserted an Incidence.
Definition calendar.cpp:669
static Event::List sortEvents(Event::List &&eventList, EventSortField sortField, SortDirection sortDirection)
Sort a list of Events.
Definition calendar.cpp:284
void setObserversEnabled(bool enabled)
Let Calendar subclasses notify that they enabled an Observer.
Definition calendar.cpp:803
void appendRecurringAlarms(Alarm::List &alarms, const Incidence::Ptr &incidence, const QDateTime &from, const QDateTime &to) const
Appends alarms of recurring events in interval to list of alarms.
Definition calendar.cpp:824
void notifyIncidenceChanged(const Incidence::Ptr &incidence)
Let Calendar subclasses notify that they modified an Incidence.
Definition calendar.cpp:693
This class provides an Event in the sense of RFC2445.
Definition event.h:33
IncidenceType
The different types of incidences, per RFC2445.
@ TypeEvent
Type is an event.
@ TypeJournal
Type is a journal.
@ RoleCalendarHashing
Role for looking up an incidence in a Calendar.
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition incidence.h:60
Provides a Journal in the sense of RFC2445.
Definition journal.h:33
This class provides a calendar stored in memory.
bool deleteIncidenceInstances(const Incidence::Ptr &incidence) override
Delete all incidences that are instances of recurring incidence incidence.
bool deleteJournalInstances(const Journal::Ptr &journal) override
Delete all journals that are instances of recurring journal journal.
Event::List rawEvents(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending) const override
Returns a sorted, unfiltered list of all Events for this Calendar.
bool addIncidence(const Incidence::Ptr &incidence) override
Inserts an Incidence into the calendar.
void incidenceUpdate(const QString &uid, const QDateTime &recurrenceId) override
The IncidenceObserver interface.
Journal::List rawJournalsForDate(const QDate &date) const override
Returns an unfiltered list of all Journals for on the specified date.
Todo::List rawTodosForDate(const QDate &date) const override
Returns an unfiltered list of all Todos which due on the specified date.
Todo::Ptr todo(const QString &uid, const QDateTime &recurrenceId={}) const override
Returns the Todo associated with the given unique identifier.
Incidence::Ptr instance(const QString &identifier) const
Returns an incidence by identifier.
Alarm::List alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms=false) const override
Returns a list of Alarms within a time range for this Calendar.
bool addEvent(const Event::Ptr &event) override
Inserts an Event into the calendar.
bool deleteJournal(const Journal::Ptr &journal) override
Removes a Journal from the calendar.
bool deleteTodo(const Todo::Ptr &todo) override
Removes a Todo from the calendar.
bool deleteEventInstances(const Event::Ptr &event) override
Delete all events that are instances of recurring event event.
Event::List rawEventsForDate(const QDate &date, const QTimeZone &timeZone={}, EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending) const override
Returns an unfiltered list of all Events which occur on the given date.
bool updateLastModifiedOnChange() const
Return true if the memory calendar is updating the lastModified field of incidence owned by the calen...
Event::Ptr event(const QString &uid, const QDateTime &recurrenceId={}) const override
Returns the Event associated with the given unique identifier.
bool addTodo(const Todo::Ptr &todo) override
Inserts a Todo into the calendar.
Journal::List rawJournals(JournalSortField sortField=JournalSortUnsorted, SortDirection sortDirection=SortDirectionAscending) const override
Returns a sorted, unfiltered list of all Journals for this Calendar.
bool deleteEvent(const Event::Ptr &event) override
Removes an Event from the calendar.
~MemoryCalendar() override
Destroys the calendar.
void incidenceUpdated(const QString &uid, const QDateTime &recurrenceId) override
The Observer interface.
Todo::List rawTodos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending) const override
Returns a sorted, unfiltered list of all Todos for this Calendar.
MemoryCalendar(const QTimeZone &timeZone)
Constructs a calendar with a specified time zone timeZone.
bool deleteIncidence(const Incidence::Ptr &incidence) override
Removes an Incidence from the calendar.
bool deleteTodoInstances(const Todo::Ptr &todo) override
Delete all to-dos that are instances of recurring to-do todo.
void setUpdateLastModifiedOnChange(bool update)
Govern if the memory calendar is changing the lastModified field of incidence it owns,...
void doSetTimeZone(const QTimeZone &timeZone) override
Let Calendar subclasses set the time specification.
Todo::List todoInstances(const Incidence::Ptr &todo, TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending) const override
Returns a sorted, unfiltered list of all possible instances for this recurring Todo.
Event::List eventInstances(const Incidence::Ptr &event, EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending) const override
Returns a sorted, unfiltered list of all possible instances for this recurring Event.
Journal::List journalInstances(const Incidence::Ptr &journal, JournalSortField sortField=JournalSortUnsorted, SortDirection sortDirection=SortDirectionAscending) const override
Returns a sorted, unfiltered list of all instances for this recurring Journal.
Journal::Ptr journal(const QString &uid, const QDateTime &recurrenceId={}) const override
Returns the Journal associated with the given unique identifier.
bool addJournal(const Journal::Ptr &journal) override
Inserts a Journal into the calendar.
void virtual_hook(int id, void *data) override
Standard trick to add virtuals later.
Provides a To-do in the sense of RFC2445.
Definition todo.h:34
Q_SCRIPTABLE Q_NOREPLY void start()
This file is part of the API for handling calendar data and defines the MemoryCalendar class.
AKONADI_CALENDAR_EXPORT KCalendarCore::Incidence::Ptr incidence(const Akonadi::Item &item)
Type type(const QSqlDatabase &db)
void update(Part *part, const QByteArray &data, qint64 dataSize)
Namespace for all KCalendarCore types.
Definition alarm.h:37
TodoSortField
Calendar Todo sort keys.
Definition calendar.h:80
EventSortField
Calendar Event sort keys.
Definition calendar.h:70
SortDirection
Calendar Incidence sort directions.
Definition calendar.h:62
JournalSortField
Calendar Journal sort keys.
Definition calendar.h:94
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QAction * find(const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & end()
QDate addDays(qint64 ndays) const const
bool isValid(int year, int month, int day)
QDateTime currentDateTimeUtc()
QDate date() const const
bool isNull() const const
bool isValid() const const
QDateTime toTimeZone(const QTimeZone &timeZone) const const
iterator insert(const Key &key, const T &value)
bool remove(const Key &key)
void append(QList< T > &&value)
void reserve(qsizetype size)
const_iterator cbegin() const const
const_iterator cend() const const
void clear()
const_iterator constFind(const Key &key, const T &value) const const
iterator insert(const Key &key, const T &value)
qsizetype remove(const Key &key)
T value(const Key &key) const const
T qobject_cast(QObject *object)
QSharedPointer< X > staticCast() const const
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:59:19 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.