KCalendarCore
memorycalendar.cpp
Go to the documentation of this file.
84 Incidence::Ptr incidence(const QString &uid, IncidenceBase::IncidenceType type, const QDateTime &recurrenceId = {}) const;
86 bool deleteIncidence(const QString &uid, IncidenceBase::IncidenceType type, const QDateTime &recurrenceId = {});
91 void forIncidences(const QMultiHash<Key, Incidence::Ptr> &incidences, const Key &key, std::function<void(const typename IncidenceType::Ptr &)> &&op) const
93 for (auto it = incidences.constFind(key), end = incidences.cend(); it != end && it.key() == key; ++it) {
99 void forIncidences(const QMultiHash<Key, Incidence::Ptr> &incidences, std::function<void(const typename IncidenceType::Ptr &)> &&op) const
107 typename IncidenceType::List castIncidenceList(const QMultiHash<QString, Incidence::Ptr> &incidences) const
111 std::transform(incidences.cbegin(), incidences.cend(), std::back_inserter(list), [](const Incidence::Ptr &inc) {
118 typename IncidenceType::List incidenceInstances(IncidenceBase::IncidenceType type, const Incidence::Ptr &incidence) const
121 forIncidences<IncidenceType, QString>(mIncidences[type], incidence->uid(), [&list](const typename IncidenceType::Ptr &incidence) {
129 Incidence::Ptr findIncidence(const QMultiHash<QString, Incidence::Ptr> &incidences, const QString &uid, const QDateTime &recurrenceId) const
131 for (auto it = incidences.constFind(uid), end = incidences.cend(); it != end && it.key() == uid; ++it) {
135 } else if (!recurrenceId.isNull() && incidence->hasRecurrenceId() && recurrenceId == incidence->recurrenceId()) {
218 for (auto it = d->mIncidences[incidence->type()].constFind(incidence->uid()), end = d->mIncidences[incidence->type()].constEnd();
240bool MemoryCalendar::Private::deleteIncidence(const QString &uid, IncidenceBase::IncidenceType type, const QDateTime &recurrenceId)
242 for (auto it = mIncidences[type].find(uid), end = mIncidences[type].end(); it != end && it.key() == uid; ++it) {
246 } else if (!recurrenceId.isNull() && (!incidence->hasRecurrenceId() || recurrenceId != incidence->recurrenceId())) {
270Incidence::Ptr MemoryCalendar::Private::incidence(const QString &uid, Incidence::IncidenceType type, const QDateTime &recurrenceId) const
290 qCWarning(KCALCORE_LOG) << "Calendar already contains an incidence of type" << type << "with UID" << uid << ", not inserting it again";
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();
357 return Calendar::sortTodos(d->castIncidenceList<Todo>(d->mIncidences[Incidence::TypeTodo]), sortField, sortDirection);
360Todo::List MemoryCalendar::todoInstances(const Incidence::Ptr &todo, TodoSortField sortField, SortDirection sortDirection) const
362 return Calendar::sortTodos(d->incidenceInstances<Todo>(Incidence::TypeTodo, todo), sortField, sortDirection);
369 d->forIncidences<Todo>(d->mIncidencesForDate[Incidence::TypeTodo], date, [&todoList](const Todo::Ptr &todo) {
374 d->forIncidences<Todo>(d->mIncidences[Incidence::TypeTodo], [this, &todoList, &date](const Todo::Ptr &todo) {
383Todo::List MemoryCalendar::rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone, bool inclusive) const
396 QDateTime rStart = todo->hasDueDate() ? todo->dtDue() : todo->hasStartDate() ? todo->dtStart() : QDateTime();
431Alarm::List MemoryCalendar::alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms) const
436 d->forIncidences<Event>(d->mIncidences[Incidence::TypeEvent], [this, &alarmList, &from, &to](const Event::Ptr &e) {
444 d->forIncidences<Todo>(d->mIncidences[IncidenceBase::TypeTodo], [this, &alarmList, &from, &to](const Todo::Ptr &t) {
474 qCWarning(KCALCORE_LOG) << "Incidence::update() called twice without an updated() call in between.";
493 qCWarning(KCALCORE_LOG) << "Incidence::updated() called twice without an update() call in between.";
520Event::List MemoryCalendar::rawEventsForDate(const QDate &date, const QTimeZone &timeZone, EventSortField sortField, SortDirection sortDirection) const
536 d->forIncidences<Event>(d->mIncidencesForDate[Incidence::TypeEvent], date, [&eventList](const Event::Ptr &event) {
570Event::List MemoryCalendar::rawEvents(const QDate &start, const QDate &end, const QTimeZone &timeZone, bool inclusive) const
625Event::List MemoryCalendar::rawEvents(EventSortField sortField, SortDirection sortDirection) const
627 return Calendar::sortEvents(d->castIncidenceList<Event>(d->mIncidences[Incidence::TypeEvent]), sortField, sortDirection);
630Event::List MemoryCalendar::eventInstances(const Incidence::Ptr &event, EventSortField sortField, SortDirection sortDirection) const
632 return Calendar::sortEvents(d->incidenceInstances<Event>(Incidence::TypeEvent, event), sortField, sortDirection);
655Journal::List MemoryCalendar::rawJournals(JournalSortField sortField, SortDirection sortDirection) const
657 return Calendar::sortJournals(d->castIncidenceList<Journal>(d->mIncidences[Incidence::TypeJournal]), sortField, sortDirection);
660Journal::List MemoryCalendar::journalInstances(const Incidence::Ptr &journal, JournalSortField sortField, SortDirection sortDirection) const
662 return Calendar::sortJournals(d->incidenceInstances<Journal>(Incidence::TypeJournal, journal), sortField, sortDirection);
669 d->forIncidences<Journal>(d->mIncidencesForDate[Incidence::TypeJournal], date, [&journalList](const Journal::Ptr &journal) {
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
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 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 a calendar stored in memory.
Definition memorycalendar.h:32
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.
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.
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)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
const QList< QKeySequence > & find()
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
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:05 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:05 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.