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 <[email protected]>
5  SPDX-FileCopyrightText: 2001, 2003 Cornelius Schumacher <[email protected]>
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 <[email protected]>
17  @author Cornelius Schumacher <[email protected]>
18  */
19 #ifndef KCALCORE_MEMORYCALENDAR_H
20 #define KCALCORE_MEMORYCALENDAR_H
21 
22 #include "calendar.h"
23 #include "kcalendarcore_export.h"
24 
25 namespace KCalendarCore
26 {
27 /**
28  @brief
29  This class provides a calendar stored in memory.
30 */
31 class KCALENDARCORE_EXPORT MemoryCalendar : public Calendar
32 {
33  Q_OBJECT
34 public:
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  Clears out the current calendar, freeing all used memory etc. etc.
57  */
58  void close() override;
59 
60  /**
61  @copydoc Calendar::doSetTimeZone()
62  */
63  void doSetTimeZone(const QTimeZone &timeZone) override;
64 
65  /**
66  @copydoc Calendar::deleteIncidence()
67  */
68  bool deleteIncidence(const Incidence::Ptr &incidence) override;
69 
70  /**
71  @copydoc Calendar::deleteIncidenceInstances
72  */
73  bool deleteIncidenceInstances(const Incidence::Ptr &incidence) override;
74 
75  /**
76  @copydoc Calendar::addIncidence()
77  */
78  bool addIncidence(const Incidence::Ptr &incidence) override;
79 
80  // Event Specific Methods //
81 
82  /**
83  @copydoc Calendar::addEvent()
84  */
85  bool addEvent(const Event::Ptr &event) override;
86 
87  /**
88  @copydoc Calendar::deleteEvent()
89  */
90  bool deleteEvent(const Event::Ptr &event) override;
91 
92  /**
93  @copydoc Calendar::deleteEventInstances()
94  */
95  bool deleteEventInstances(const Event::Ptr &event) override;
96 
97  /**
98  @copydoc Calendar::rawEvents(EventSortField, SortDirection)const
99  */
100  Q_REQUIRED_RESULT Event::List rawEvents(EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override;
101 
102  /**
103  @copydoc Calendar::rawEvents(const QDate &, const QDate &, const QTimeZone &, bool)const
104  */
105  Q_REQUIRED_RESULT Event::List rawEvents(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const override;
106 
107  /**
108  Returns an unfiltered list of all Events which occur on the given date.
109 
110  @param date request unfiltered Event list for this QDate only.
111  @param timeZone time zone to interpret @p date, or the calendar's
112  default time zone if none is specified
113  @param sortField specifies the EventSortField.
114  @param sortDirection specifies the SortDirection.
115 
116  @return the list of unfiltered Events occurring on the specified QDate.
117  */
118  Q_REQUIRED_RESULT Event::List rawEventsForDate(const QDate &date,
119  const QTimeZone &timeZone = {},
120  EventSortField sortField = EventSortUnsorted,
121  SortDirection sortDirection = SortDirectionAscending) const override;
122 
123  /**
124  @copydoc Calendar::rawEventsForDate(const QDateTime &)const
125  */
126  Q_REQUIRED_RESULT Event::List rawEventsForDate(const QDateTime &dt) const override;
127 
128  /**
129  * Returns an incidence by identifier.
130  * @see Incidence::instanceIdentifier()
131  * @since 4.11
132  */
133  Incidence::Ptr instance(const QString &identifier) const;
134 
135  /**
136  @copydoc Calendar::event()
137  */
138  Q_REQUIRED_RESULT Event::Ptr event(const QString &uid, const QDateTime &recurrenceId = {}) const override;
139 
140  /**
141  @copydoc Calendar::deletedEvent()
142  */
143  Q_REQUIRED_RESULT Event::Ptr deletedEvent(const QString &uid, const QDateTime &recurrenceId = {}) const override;
144 
145  /**
146  @copydoc Calendar::deletedEvents(EventSortField, SortDirection)const
147  */
148  Q_REQUIRED_RESULT Event::List deletedEvents(EventSortField sortField = EventSortUnsorted,
149  SortDirection sortDirection = SortDirectionAscending) const override;
150 
151  /**
152  @copydoc Calendar::eventInstances(const Incidence::Ptr &, EventSortField, SortDirection)const
153  */
154  Q_REQUIRED_RESULT Event::List eventInstances(const Incidence::Ptr &event,
155  EventSortField sortField = EventSortUnsorted,
156  SortDirection sortDirection = SortDirectionAscending) const override;
157 
158  // To-do Specific Methods //
159 
160  /**
161  @copydoc Calendar::addTodo()
162  */
163  bool addTodo(const Todo::Ptr &todo) override;
164 
165  /**
166  @copydoc Calendar::deleteTodo()
167  */
168  bool deleteTodo(const Todo::Ptr &todo) override;
169 
170  /**
171  @copydoc Calendar::deleteTodoInstances()
172  */
173  bool deleteTodoInstances(const Todo::Ptr &todo) override;
174 
175  /**
176  @copydoc Calendar::rawTodos(TodoSortField, SortDirection)const
177  */
178  Q_REQUIRED_RESULT Todo::List rawTodos(TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override;
179 
180  /**
181  @copydoc Calendar::rawTodos(const QDate &, const QDate &, const QTimeZone &, bool)const
182  */
183  Q_REQUIRED_RESULT Todo::List rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const override;
184 
185  /**
186  @copydoc Calendar::rawTodosForDate()
187  */
188  Q_REQUIRED_RESULT Todo::List rawTodosForDate(const QDate &date) const override;
189 
190  /**
191  @copydoc Calendar::todo()
192  */
193  Q_REQUIRED_RESULT Todo::Ptr todo(const QString &uid, const QDateTime &recurrenceId = {}) const override;
194 
195  /**
196  @copydoc Calendar::deletedTodo()
197  */
198  Q_REQUIRED_RESULT Todo::Ptr deletedTodo(const QString &uid, const QDateTime &recurrenceId = {}) const override;
199 
200  /**
201  @copydoc Calendar::deletedTodos(TodoSortField, SortDirection)const
202  */
203  Q_REQUIRED_RESULT Todo::List deletedTodos(TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override;
204 
205  /**
206  @copydoc Calendar::todoInstances(const Incidence::Ptr &, TodoSortField, SortDirection)const
207  */
208  Q_REQUIRED_RESULT Todo::List
209  todoInstances(const Incidence::Ptr &todo, TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override;
210 
211  // Journal Specific Methods //
212 
213  /**
214  @copydoc Calendar::addJournal()
215  */
216  bool addJournal(const Journal::Ptr &journal) override;
217 
218  /**
219  @copydoc Calendar::deleteJournal()
220  */
221  bool deleteJournal(const Journal::Ptr &journal) override;
222 
223  /**
224  @copydoc Calendar::deleteJournalInstances()
225  */
226  bool deleteJournalInstances(const Journal::Ptr &journal) override;
227 
228  /**
229  @copydoc Calendar::rawJournals()
230  */
231  Q_REQUIRED_RESULT Journal::List rawJournals(JournalSortField sortField = JournalSortUnsorted,
232  SortDirection sortDirection = SortDirectionAscending) const override;
233 
234  /**
235  @copydoc Calendar::rawJournalsForDate()
236  */
237  Q_REQUIRED_RESULT Journal::List rawJournalsForDate(const QDate &date) const override;
238 
239  /**
240  @copydoc Calendar::journal()
241  */
242  Journal::Ptr journal(const QString &uid, const QDateTime &recurrenceId = {}) const override;
243 
244  /**
245  @copydoc Calendar::deletedJournal()
246  */
247  Journal::Ptr deletedJournal(const QString &uid, const QDateTime &recurrenceId = {}) const override;
248 
249  /**
250  @copydoc Calendar::deletedJournals(JournalSortField, SortDirection)const
251  */
252  Q_REQUIRED_RESULT Journal::List deletedJournals(JournalSortField sortField = JournalSortUnsorted,
253  SortDirection sortDirection = SortDirectionAscending) const override;
254 
255  /**
256  @copydoc Calendar::journalInstances(const Incidence::Ptr &,
257  JournalSortField, SortDirection)const
258  */
259  Q_REQUIRED_RESULT Journal::List journalInstances(const Incidence::Ptr &journal,
261  SortDirection sortDirection = SortDirectionAscending) const override;
262 
263  // Alarm Specific Methods //
264 
265  /**
266  @copydoc Calendar::alarms()
267  */
268  Q_REQUIRED_RESULT Alarm::List alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms = false) const override;
269 
270  /**
271  Return a list of Alarms that occur before the specified timestamp.
272 
273  @param to is the ending timestamp.
274  @return the list of Alarms occurring before the specified QDateTime.
275  */
276  Q_REQUIRED_RESULT Alarm::List alarmsTo(const QDateTime &to) const; // TODO KF6 remove, already defined in Calendar
277 
278  /**
279  Return true if the memory calendar is updating the lastModified field
280  of incidence owned by the calendar on any incidence change.
281 
282  @since 5.80
283  */
284  bool updateLastModifiedOnChange() const;
285 
286  /**
287  Govern if the memory calendar is changing the lastModified field of incidence
288  it owns, on incidence updates.
289 
290  @param update, when true, the lastModified field of an incidence owned by the
291  calendar is set to the current date time on any change of the incidence.
292 
293  @since 5.80
294  */
295  void setUpdateLastModifiedOnChange(bool update);
296 
297  /**
298  @copydoc Calendar::incidenceUpdate(const QString &,const QDateTime &)
299  */
300  void incidenceUpdate(const QString &uid, const QDateTime &recurrenceId) override;
301 
302  /**
303  @copydoc Calendar::incidenceUpdated(const QString &,const QDateTime &)
304  */
305  void incidenceUpdated(const QString &uid, const QDateTime &recurrenceId) override;
306 
307  using QObject::event; // prevent warning about hidden virtual method
308 
309 protected:
310  /**
311  @copydoc IncidenceBase::virtual_hook()
312  */
313  void virtual_hook(int id, void *data) override;
314 
315 private:
316  //@cond PRIVATE
317  class Private;
318  Private *const d;
319  //@endcond
320 
321  Q_DISABLE_COPY(MemoryCalendar)
322 };
323 
324 }
325 
326 #endif
Do not sort Journals.
Definition: calendar.h:91
JournalSortField
Calendar Journal sort keys.
Definition: calendar.h:90
TodoSortField
Calendar Todo sort keys.
Definition: calendar.h:77
Represents the main calendar class.
Definition: calendar.h:118
Do not sort Events.
Definition: calendar.h:68
virtual bool event(QEvent *e)
QSharedPointer< MemoryCalendar > Ptr
A shared pointer to a MemoryCalendar.
EventSortField
Calendar Event sort keys.
Definition: calendar.h:67
This file is part of the API for handling calendar data and defines the Calendar class.
Sort in ascending order (first to last)
Definition: calendar.h:60
Do not sort Todos.
Definition: calendar.h:78
SortDirection
Calendar Incidence sort directions.
Definition: calendar.h:59
This class provides a calendar stored in memory.
Namespace for all KCalendarCore types.
Definition: alarm.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 22:50:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.