KCalendarCore

memorycalendar.h
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 Cornelius Schumacher <schumacher@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9/**
10 @file
11 This file is part of the API for handling calendar data and
12 defines the MemoryCalendar class.
13
14 Very simple implementation of a Calendar that is only in memory
15
16 @author Preston Brown <pbrown@kde.org>
17 @author Cornelius Schumacher <schumacher@kde.org>
18 */
19#ifndef KCALCORE_MEMORYCALENDAR_H
20#define KCALCORE_MEMORYCALENDAR_H
21
22#include "calendar.h"
23#include "kcalendarcore_export.h"
24
25namespace KCalendarCore
26{
27/**
28 @brief
29 This class provides a calendar stored in memory.
30*/
31class KCALENDARCORE_EXPORT MemoryCalendar : public Calendar
32{
33 Q_OBJECT
34public:
35 /**
36 A shared pointer to a MemoryCalendar
37 */
39
40 /**
41 @copydoc Calendar::Calendar(const QTimeZone &)
42 */
43 explicit MemoryCalendar(const QTimeZone &timeZone);
44
45 /**
46 @copydoc Calendar::Calendar(const QString &)
47 */
48 explicit MemoryCalendar(const QByteArray &timeZoneId);
49
50 /**
51 @copydoc Calendar::~Calendar()
52 */
53 ~MemoryCalendar() override;
54
55 /**
56 @copydoc Calendar::doSetTimeZone()
57 */
58 void doSetTimeZone(const QTimeZone &timeZone) override;
59
60 /**
61 @copydoc Calendar::deleteIncidence()
62 */
63 bool deleteIncidence(const Incidence::Ptr &incidence) override;
64
65 /**
66 @copydoc Calendar::deleteIncidenceInstances
67 */
68 bool deleteIncidenceInstances(const Incidence::Ptr &incidence) override;
69
70 /**
71 @copydoc Calendar::addIncidence()
72 */
73 bool addIncidence(const Incidence::Ptr &incidence) override;
74
75 // Event Specific Methods //
76
77 /**
78 @copydoc Calendar::addEvent()
79 */
80 bool addEvent(const Event::Ptr &event) override;
81
82 /**
83 @copydoc Calendar::deleteEvent()
84 */
85 bool deleteEvent(const Event::Ptr &event) override;
86
87 /**
88 @copydoc Calendar::deleteEventInstances()
89 */
90 bool deleteEventInstances(const Event::Ptr &event) override;
91
92 /**
93 @copydoc Calendar::rawEvents(EventSortField, SortDirection)const
94 */
95 Q_REQUIRED_RESULT Event::List rawEvents(EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override;
96
97 /**
98 @copydoc Calendar::rawEvents(const QDate &, const QDate &, const QTimeZone &, bool)const
99 */
100 Q_REQUIRED_RESULT Event::List rawEvents(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const override;
101
102 /**
103 Returns an unfiltered list of all Events which occur on the given date.
104
105 @param date request unfiltered Event list for this QDate only.
106 @param timeZone time zone to interpret @p date, or the calendar's
107 default time zone if none is specified
108 @param sortField specifies the EventSortField.
109 @param sortDirection specifies the SortDirection.
110
111 @return the list of unfiltered Events occurring on the specified QDate.
112 */
113 Q_REQUIRED_RESULT Event::List rawEventsForDate(const QDate &date,
114 const QTimeZone &timeZone = {},
116 SortDirection sortDirection = SortDirectionAscending) const override;
117
118 /**
119 * Returns an incidence by identifier.
120 * @see Incidence::instanceIdentifier()
121 * @since 4.11
122 */
123 Incidence::Ptr instance(const QString &identifier) const;
124
125 /**
126 @copydoc Calendar::event()
127 */
128 Q_REQUIRED_RESULT Event::Ptr event(const QString &uid, const QDateTime &recurrenceId = {}) const override;
129
130 /**
131 @copydoc Calendar::eventInstances(const Incidence::Ptr &, EventSortField, SortDirection)const
132 */
133 Q_REQUIRED_RESULT Event::List eventInstances(const Incidence::Ptr &event,
134 EventSortField sortField = EventSortUnsorted,
135 SortDirection sortDirection = SortDirectionAscending) const override;
136
137 // To-do Specific Methods //
138
139 /**
140 @copydoc Calendar::addTodo()
141 */
142 bool addTodo(const Todo::Ptr &todo) override;
143
144 /**
145 @copydoc Calendar::deleteTodo()
146 */
147 bool deleteTodo(const Todo::Ptr &todo) override;
148
149 /**
150 @copydoc Calendar::deleteTodoInstances()
151 */
152 bool deleteTodoInstances(const Todo::Ptr &todo) override;
153
154 /**
155 @copydoc Calendar::rawTodos(TodoSortField, SortDirection)const
156 */
157 Q_REQUIRED_RESULT Todo::List rawTodos(TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override;
158
159 /**
160 @copydoc Calendar::rawTodos(const QDate &, const QDate &, const QTimeZone &, bool)const
161 */
162 Q_REQUIRED_RESULT Todo::List rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const override;
163
164 /**
165 @copydoc Calendar::rawTodosForDate()
166 */
167 Q_REQUIRED_RESULT Todo::List rawTodosForDate(const QDate &date) const override;
168
169 /**
170 @copydoc Calendar::todo()
171 */
172 Q_REQUIRED_RESULT Todo::Ptr todo(const QString &uid, const QDateTime &recurrenceId = {}) const override;
173
174 /**
175 @copydoc Calendar::todoInstances(const Incidence::Ptr &, TodoSortField, SortDirection)const
176 */
177 Q_REQUIRED_RESULT Todo::List
178 todoInstances(const Incidence::Ptr &todo, TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override;
179
180 // Journal Specific Methods //
181
182 /**
183 @copydoc Calendar::addJournal()
184 */
185 bool addJournal(const Journal::Ptr &journal) override;
186
187 /**
188 @copydoc Calendar::deleteJournal()
189 */
190 bool deleteJournal(const Journal::Ptr &journal) override;
191
192 /**
193 @copydoc Calendar::deleteJournalInstances()
194 */
195 bool deleteJournalInstances(const Journal::Ptr &journal) override;
196
197 /**
198 @copydoc Calendar::rawJournals()
199 */
200 Q_REQUIRED_RESULT Journal::List rawJournals(JournalSortField sortField = JournalSortUnsorted,
201 SortDirection sortDirection = SortDirectionAscending) const override;
202
203 /**
204 @copydoc Calendar::rawJournalsForDate()
205 */
206 Q_REQUIRED_RESULT Journal::List rawJournalsForDate(const QDate &date) const override;
207
208 /**
209 @copydoc Calendar::journal()
210 */
211 Journal::Ptr journal(const QString &uid, const QDateTime &recurrenceId = {}) const override;
212
213 /**
214 @copydoc Calendar::journalInstances(const Incidence::Ptr &,
215 JournalSortField, SortDirection)const
216 */
217 Q_REQUIRED_RESULT Journal::List journalInstances(const Incidence::Ptr &journal,
218 JournalSortField sortField = JournalSortUnsorted,
219 SortDirection sortDirection = SortDirectionAscending) const override;
220
221 // Alarm Specific Methods //
222
223 /**
224 @copydoc Calendar::alarms()
225 */
226 Q_REQUIRED_RESULT Alarm::List alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms = false) const override;
227
228 /**
229 Return true if the memory calendar is updating the lastModified field
230 of incidence owned by the calendar on any incidence change.
231
232 @since 5.80
233 */
235
236 /**
237 Govern if the memory calendar is changing the lastModified field of incidence
238 it owns, on incidence updates.
239
240 @param update, when true, the lastModified field of an incidence owned by the
241 calendar is set to the current date time on any change of the incidence.
242
243 @since 5.80
244 */
246
247 /**
248 @copydoc Calendar::incidenceUpdate(const QString &,const QDateTime &)
249 */
250 void incidenceUpdate(const QString &uid, const QDateTime &recurrenceId) override;
251
252 /**
253 @copydoc Calendar::incidenceUpdated(const QString &,const QDateTime &)
254 */
255 void incidenceUpdated(const QString &uid, const QDateTime &recurrenceId) override;
256
257 using QObject::event; // prevent warning about hidden virtual method
258
259protected:
260 /**
261 @copydoc IncidenceBase::virtual_hook()
262 */
263 void virtual_hook(int id, void *data) override;
264
265private:
266 //@cond PRIVATE
267 class Private;
268 Private *const d;
269 //@endcond
270
271 Q_DISABLE_COPY(MemoryCalendar)
272};
273
274}
275
276#endif
This file is part of the API for handling calendar data and defines the Calendar class.
Represents the main calendar class.
Definition calendar.h:133
This class provides a calendar stored in memory.
QSharedPointer< MemoryCalendar > Ptr
A shared pointer to a MemoryCalendar.
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(const QDate &start, const QDate &end, const QTimeZone &timeZone={}, bool inclusive=false) const override
Returns an unfiltered list of all Events occurring within a date range.
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 rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone={}, bool inclusive=false) const override
Returns an unfiltered list of all Todos occurring within a date range.
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 QByteArray &timeZoneId)
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()
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
@ EventSortUnsorted
Do not sort Events.
Definition calendar.h:71
SortDirection
Calendar Incidence sort directions.
Definition calendar.h:62
@ SortDirectionAscending
Sort in ascending order (first to last)
Definition calendar.h:63
JournalSortField
Calendar Journal sort keys.
Definition calendar.h:94
virtual bool event(QEvent *e)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Apr 27 2024 22:07:29 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.