KCalendarCore

calendar.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, 2004 Cornelius Schumacher <[email protected]>
6  SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <[email protected]>
7  SPDX-FileCopyrightText: 2006 David Jarvie <[email protected]>
8 
9  SPDX-License-Identifier: LGPL-2.0-or-later
10 */
11 /**
12  @file
13  This file is part of the API for handling calendar data and
14  defines the Calendar class.
15 
16  @author Preston Brown <[email protected]>
17  @author Cornelius Schumacher <[email protected]>
18  @author Reinhold Kainhofer <[email protected]>
19  @author David Jarvie <[email protected]>
20  */
21 
22 /*
23 
24 TODO: KDE5:
25 
26 This API needs serious cleaning up:
27 - Most (all) methods aren't async ( deleteIncidence(), addIncidence(), load(), save(), ... )
28  so it's not very easy to make a derived class that loads from akonadi.
29 
30 - It has too many methods. Why do we need fooEvent()/fooJournal()/fooTodo() when fooIncidence()
31  should be enough.
32 
33 */
34 
35 #ifndef KCALCORE_CALENDAR_H
36 #define KCALCORE_CALENDAR_H
37 
38 #include "customproperties.h"
39 #include "event.h"
40 #include "incidence.h"
41 #include "journal.h"
42 #include "kcalendarcore_export.h"
43 #include "todo.h"
44 
45 #include <QDateTime>
46 #include <QIcon>
47 #include <QObject>
48 #include <QTimeZone>
49 
50 /** Namespace for all KCalendarCore types. */
51 namespace KCalendarCore
52 {
53 Q_NAMESPACE_EXPORT(KCALENDARCORE_EXPORT)
54 
55 class CalFilter;
56 class Person;
57 class ICalFormat;
58 
59 /**
60  Calendar Incidence sort directions.
61 */
63  SortDirectionAscending, /**< Sort in ascending order (first to last) */
64  SortDirectionDescending, /**< Sort in descending order (last to first) */
65 };
66 
67 /**
68  Calendar Event sort keys.
69 */
71  EventSortUnsorted, /**< Do not sort Events */
72  EventSortStartDate, /**< Sort Events chronologically, by start date */
73  EventSortEndDate, /**< Sort Events chronologically, by end date */
74  EventSortSummary, /**< Sort Events alphabetically, by summary */
75 };
76 
77 /**
78  Calendar Todo sort keys.
79 */
81  TodoSortUnsorted, /**< Do not sort Todos */
82  TodoSortStartDate, /**< Sort Todos chronologically, by start date */
83  TodoSortDueDate, /**< Sort Todos chronologically, by due date */
84  TodoSortPriority, /**< Sort Todos by priority */
85  TodoSortPercentComplete, /**< Sort Todos by percentage completed */
86  TodoSortSummary, /**< Sort Todos alphabetically, by summary */
87  TodoSortCreated, /**< Sort Todos chronologically, by creation date */
88  TodoSortCategories, /**< Sort Todos by categories (tags) @since 5.83 */
89 };
90 
91 /**
92  Calendar Journal sort keys.
93 */
95  JournalSortUnsorted, /**< Do not sort Journals */
96  JournalSortDate, /**< Sort Journals chronologically by date */
97  JournalSortSummary, /**< Sort Journals alphabetically, by summary */
98 };
99 
100 /**
101  The calendar's access mode, i.e. whether it can be written to or is read only.
102  @since 5.85
103 */
105  ReadOnly,
106  ReadWrite,
107 };
108 Q_ENUM_NS(AccessMode)
109 
110 /**
111  @brief
112  Represents the main calendar class.
113 
114  A calendar contains information like incidences (events, to-dos, journals),
115  alarms, time zones, and other useful information.
116 
117  This is an abstract base class defining the interface to a calendar.
118  It is implemented by subclasses like MemoryCalendar, which use different
119  methods to store and access the data.
120 
121  <b>Ownership of Incidences</b>:
122 
123  Incidence ownership is handled by the following policy: as soon as an
124  incidence (or any other subclass of IncidenceBase) is added to the
125  Calendar by an add...() method it is owned by the Calendar object.
126  The Calendar takes care of deleting the incidence using the delete...()
127  methods. All Incidences returned by the query functions are returned
128  as pointers so that changes to the returned Incidences are immediately
129  visible in the Calendar. Do <em>Not</em> attempt to 'delete' any Incidence
130  object you get from Calendar -- use the delete...() methods.
131 */
132 class KCALENDARCORE_EXPORT Calendar : public QObject, public CustomProperties, public IncidenceBase::IncidenceObserver
133 {
134  Q_OBJECT
135  Q_PROPERTY(QString productId READ productId WRITE setProductId) // clazy:exclude=qproperty-without-notify
136  Q_PROPERTY(KCalendarCore::Person owner READ owner WRITE setOwner NOTIFY ownerChanged)
137  Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
138  Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
139  Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
140  Q_PROPERTY(KCalendarCore::AccessMode accessMode READ accessMode WRITE setAccessMode NOTIFY accessModeChanged)
141  Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged)
142 
143 public:
144  /**
145  A shared pointer to a Calendar
146  */
148 
149  /**
150  Constructs a calendar with a specified time zone @p timeZone.
151  The time zone is used as the default for creating or
152  modifying incidences in the Calendar. The time zone does
153  not alter existing incidences.
154 
155  @param timeZone time specification
156  */
157  explicit Calendar(const QTimeZone &timeZone);
158 
159  /**
160  Construct Calendar object using a time zone ID.
161  The time zone ID is used as the default for creating or modifying
162  incidences in the Calendar. The time zone does not alter existing
163  incidences.
164 
165  @param timeZoneId is a string containing a time zone ID, which is
166  assumed to be valid. If no time zone is found, the viewing time
167  specification is set to local time zone.
168  @e Example: "Europe/Berlin"
169  */
170  explicit Calendar(const QByteArray &timeZoneId);
171 
172  /**
173  Destroys the calendar.
174  */
175  ~Calendar() override;
176 
177  /**
178  Sets the calendar Product ID to @p id.
179 
180  @param id is a string containing the Product ID.
181 
182  @see productId() const
183  */
184  void setProductId(const QString &id);
185 
186  /**
187  Returns the calendar's Product ID.
188 
189  @see setProductId()
190  */
191  Q_REQUIRED_RESULT QString productId() const;
192 
193  /**
194  Sets the owner of the calendar to @p owner.
195 
196  @param owner is a Person object. Must be a non-null pointer.
197 
198  @see owner()
199  */
200  void setOwner(const Person &owner);
201 
202  /**
203  Returns the owner of the calendar.
204 
205  @return the owner Person object.
206 
207  @see setOwner()
208  */
209  Q_REQUIRED_RESULT Person owner() const;
210 
211  /**
212  Sets the default time specification zone used for creating
213  or modifying incidences in the Calendar.
214 
215  @param timeZone The time zone
216  */
217  void setTimeZone(const QTimeZone &timeZone);
218 
219  /**
220  Get the time zone used for creating or
221  modifying incidences in the Calendar.
222 
223  @return time specification
224  */
225  Q_REQUIRED_RESULT QTimeZone timeZone() const;
226 
227  /**
228  Sets the time zone ID used for creating or modifying incidences in the
229  Calendar. This method has no effect on existing incidences.
230 
231  @param timeZoneId is a string containing a time zone ID, which is
232  assumed to be valid. The time zone ID is used to set the time zone
233  for viewing Incidence date/times. If no time zone is found, the
234  viewing time specification is set to local time zone.
235  @e Example: "Europe/Berlin"
236  @see setTimeZone()
237  */
238  void setTimeZoneId(const QByteArray &timeZoneId);
239 
240  /**
241  Returns the time zone ID used for creating or modifying incidences in
242  the calendar.
243 
244  @return the string containing the time zone ID, or empty string if the
245  creation/modification time specification is not a time zone.
246  */
247  Q_REQUIRED_RESULT QByteArray timeZoneId() const;
248 
249  /**
250  Shifts the times of all incidences so that they appear at the same clock
251  time as before but in a new time zone. The shift is done from a viewing
252  time zone rather than from the actual incidence time zone.
253 
254  For example, shifting an incidence whose start time is 09:00 America/New York,
255  using an old viewing time zone (@p oldSpec) of Europe/London, to a new time
256  zone (@p newSpec) of Europe/Paris, will result in the time being shifted
257  from 14:00 (which is the London time of the incidence start) to 14:00 Paris
258  time.
259 
260  @param oldZone the time zone which provides the clock times
261  @param newZone the new time zone
262  */
263  void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone);
264 
265  /**
266  Sets if the calendar has been modified.
267 
268  @param modified is true if the calendar has been modified since open
269  or last save.
270 
271  @see isModified()
272  */
273  void setModified(bool modified);
274 
275  /**
276  Determine the calendar's modification status.
277 
278  @return true if the calendar has been modified since open or last save.
279 
280  @see setModified()
281  */
282  Q_REQUIRED_RESULT bool isModified() const;
283 
284  /**
285  * A unique identifier for this calendar.
286  * @since 5.85
287  * @see setId()
288  */
289  QString id() const;
290 
291  /**
292  * set a unique identifier for this calendar.
293  * @since 5.85
294  * @see id()
295  */
296  void setId(const QString &id);
297 
298  /**
299  * The user-visible name for this calendar.
300  * @since 5.85
301  * @see setName()
302  */
303  QString name() const;
304 
305  /**
306  * Set the user-visible name for this calendar.
307  * @since 5.85
308  * @see name()
309  */
310  void setName(const QString &name);
311 
312  /**
313  * This calendar's icon.
314  * @since 5.85
315  * @see setIconName()
316  */
317  QIcon icon() const;
318 
319  /**
320  * Set this calendar's icon.
321  * @since 5.85
322  * @see icon()
323  */
324  void setIcon(const QIcon &icon);
325 
326  /**
327  * This calendar's AccessMode, i.e. whether it is writable or read-only.
328  * Defaults to ReadWrite.
329  * @since 5.85
330  * @see setAccessMode()
331  */
332  AccessMode accessMode() const;
333 
334  /**
335  * Set this calendar's AccessMode, i.e. whether it is writable or read-only.
336  * @since 5.85
337  * @see accessMode()
338  */
339  void setAccessMode(const AccessMode mode);
340 
341  /**
342  * Returns @c true if the calendar is still loading its data and thus
343  * read access will not return complete (or even any) results.
344  * @since 5.96
345  */
346  bool isLoading() const;
347 
348  /**
349  Clears out the current calendar, freeing all used memory etc.
350  */
351  virtual void close() = 0;
352 
353  /**
354  Syncs changes in memory to persistent storage.
355 
356  @return true if the save was successful; false otherwise.
357  Base implementation returns true.
358  @deprecated since 5.106, non-functional and unused
359  */
360  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "non-functional, will be removed in KF6.") virtual bool save();
361 
362  /**
363  Loads the calendar contents from storage. This requires that the
364  calendar has been previously loaded (initialized).
365 
366  @return true if the reload was successful; otherwise false.
367  Base implementation returns true.
368  @deprecated since 5.106, non-functional and unused
369  */
370  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "non-functional, will be removed in KF6.") virtual bool reload();
371 
372  /**
373  Determine if the calendar is currently being saved.
374 
375  @return true if the calendar is currently being saved; false otherwise.
376  @deprecated since 5.106, non-functional and unused
377  */
378  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "non-functional, will be removed in KF6.") virtual bool isSaving() const;
379 
380  /**
381  Returns a list of all categories used by Incidences in this Calendar.
382 
383  @return a QStringList containing all the categories.
384  */
385  Q_REQUIRED_RESULT QStringList categories() const;
386 
387  // Incidence Specific Methods //
388 
389  /**
390  Call this to tell the calendar that you're adding a batch of incidences.
391  So it doesn't, for example, ask the destination for each incidence.
392 
393  @see endBatchAdding()
394  */
395  virtual void startBatchAdding();
396 
397  /**
398  Tells the Calendar that you stopped adding a batch of incidences.
399 
400  @see startBatchAdding()
401  */
402  virtual void endBatchAdding();
403 
404  /**
405  @return true if batch adding is in progress
406  */
407  Q_REQUIRED_RESULT bool batchAdding() const;
408 
409  /**
410  Inserts an Incidence into the calendar.
411 
412  @param incidence is a pointer to the Incidence to insert.
413 
414  @return true if the Incidence was successfully inserted; false otherwise.
415 
416  @see deleteIncidence()
417  */
418  virtual bool addIncidence(const Incidence::Ptr &incidence);
419 
420  /**
421  Removes an Incidence from the calendar.
422 
423  @param incidence is a pointer to the Incidence to remove.
424 
425  @return true if the Incidence was successfully removed; false otherwise.
426 
427  @see addIncidence()
428  */
429  virtual bool deleteIncidence(const Incidence::Ptr &incidence);
430 
431  /**
432  Returns a filtered list of all Incidences for this Calendar.
433 
434  @return the list of all filtered Incidences.
435  */
436  virtual Incidence::List incidences() const;
437 
438  /**
439  Returns a filtered list of all Incidences which occur on the given date.
440 
441  @param date request filtered Incidence list for this QDate only.
442 
443  @return the list of filtered Incidences occurring on the specified date.
444  */
445  virtual Incidence::List incidences(const QDate &date) const;
446 
447  /**
448  Returns an unfiltered list of all Incidences for this Calendar.
449 
450  @return the list of all unfiltered Incidences.
451  */
452  virtual Incidence::List rawIncidences() const;
453 
454  /**
455  Returns an unfiltered list of all exceptions of this recurring incidence.
456 
457  @param incidence incidence to check
458 
459  @return the list of all unfiltered exceptions.
460  */
461  virtual Incidence::List instances(const Incidence::Ptr &incidence) const;
462 
463  // Notebook Specific Methods //
464 
465  /**
466  Clears notebook associations from hash-tables for incidences.
467  Called when in-memory content of the calendar is cleared.
468  @deprecated since 5.106
469  */
470  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
471  virtual void clearNotebookAssociations();
472 
473  /**
474  Associate notebook for an incidence.
475 
476  @param incidence incidence
477  @param notebook notebook uid
478 
479  @return true if the operation was successful; false otherwise.
480  @deprecated since 5.106
481  */
482  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
483  virtual bool setNotebook(const Incidence::Ptr &incidence, const QString &notebook);
484 
485  /**
486  Get incidence's notebook.
487 
488  @param incidence incidence
489 
490  @return notebook uid
491  @deprecated since 5.106
492  */
493  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
494  virtual QString notebook(const Incidence::Ptr &incidence) const;
495 
496  /**
497  Get incidence's notebook.
498 
499  @param uid is a unique identifier string
500 
501  @return notebook uid
502  @deprecated since 5.106
503  */
504  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
505  virtual QString notebook(const QString &uid) const;
506 
507  /**
508  List all uids of notebooks currently in the memory.
509 
510  @return list of uids of notebooks
511  @deprecated since 5.106
512  */
513  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
514  virtual QStringList notebooks() const;
515 
516  /**
517  Check if calendar knows about the given notebook.
518  This means that it will be saved by one of the attached storages.
519 
520  @param notebook notebook uid
521  @return true if calendar has valid notebook
522  @deprecated since 5.106
523  */
524  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
525  Q_REQUIRED_RESULT bool hasValidNotebook(const QString &notebook) const;
526 
527  /**
528  Add notebook information into calendar.
529  Is usually called by storages only.
530 
531  @param notebook notebook uid
532  @param isVisible notebook visibility
533  @return true if operation succeeded
534  @see isVisible()
535  @deprecated since 5.106
536  */
537  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
538  Q_REQUIRED_RESULT bool addNotebook(const QString &notebook, bool isVisible);
539 
540  /**
541  Update notebook information in calendar.
542  Is usually called by storages only.
543 
544  @param notebook notebook uid
545  @param isVisible notebook visibility
546  @return true if operation succeeded
547  @see isVisible()
548  @deprecated since 5.106
549  */
550  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
551  Q_REQUIRED_RESULT bool updateNotebook(const QString &notebook, bool isVisible);
552 
553  /**
554  Delete notebook information from calendar.
555  Is usually called by storages only.
556 
557  @param notebook notebook uid
558  @return true if operation succeeded
559  @see isVisible()
560  @deprecated since 5.106
561  */
562  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
563  Q_REQUIRED_RESULT bool deleteNotebook(const QString &notebook);
564 
565  /**
566  set DefaultNotebook information to calendar.
567 
568  @param notebook notebook uid
569  @return true if operation was successful; false otherwise.
570  @deprecated since 5.106
571  */
572  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
573  Q_REQUIRED_RESULT bool setDefaultNotebook(const QString &notebook);
574 
575  /**
576  Get uid of default notebook.
577 
578  @return notebook uid
579  @deprecated since 5.106
580  */
581  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
582  Q_REQUIRED_RESULT QString defaultNotebook() const;
583 
584  /**
585  Check if incidence is visible.
586  @param incidence is a pointer to the Incidence to check for visibility.
587  @return true if incidence is visible, false otherwise
588  @deprecated since 5.106
589  */
590  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
591  Q_REQUIRED_RESULT bool isVisible(const Incidence::Ptr &incidence) const;
592 
593  /**
594  Check if notebook is visible.
595  @param notebook notebook uid.
596  @return true if notebook is visible, false otherwise
597  @deprecated since 5.106
598  */
599  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
600  Q_REQUIRED_RESULT bool isVisible(const QString &notebook) const;
601 
602  /**
603  List all notebook incidences in the memory.
604 
605  @param notebook is the notebook uid.
606  @return a list of incidences for the notebook.
607  @deprecated since 5.106
608  */
609  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
610  virtual Incidence::List incidences(const QString &notebook) const;
611 
612  /**
613  List all possible duplicate incidences.
614 
615  @param incidence is the incidence to check.
616  @return a list of duplicate incidences.
617  @deprecated since 5.106
618  */
619  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "notebook support is going to be removed in KF6")
620  virtual Incidence::List duplicates(const Incidence::Ptr &incidence);
621 
622  /**
623  Returns the Incidence associated with the given unique identifier.
624 
625  @param uid is a unique identifier string.
626  @param recurrenceId is possible recurrenceid of incidence, default is null
627 
628  @return a pointer to the Incidence.
629  A null pointer is returned if no such Incidence exists.
630  */
631  Incidence::Ptr incidence(const QString &uid, const QDateTime &recurrenceId = {}) const;
632 
633  /**
634  Returns the deleted Incidence associated with the given unique identifier.
635 
636  @param uid is a unique identifier string.
637  @param recurrenceId is possible recurrenceid of incidence, default is null
638 
639  @return a pointer to the Incidence.
640  A null pointer is returned if no such Incidence exists.
641  */
642  Incidence::Ptr deleted(const QString &uid, const QDateTime &recurrenceId = {}) const;
643 
644  /**
645  Delete all incidences that are instances of recurring incidence @p incidence.
646 
647  @param incidence is a pointer to a deleted Incidence
648  @return true if delete was successful; false otherwise
649  */
650  virtual bool deleteIncidenceInstances(const Incidence::Ptr &incidence) = 0;
651 
652  /**
653  Returns the Incidence associated with the given scheduling identifier.
654 
655  @param sid is a unique scheduling identifier string.
656 
657  @return a pointer to the Incidence.
658  A null pointer is returned if no such Incidence exists.
659  */
660  virtual Incidence::Ptr incidenceFromSchedulingID(const QString &sid) const;
661 
662  /**
663  Searches all events and todos for an incidence with this
664  scheduling identifier. Returns a list of matching results.
665 
666  @param sid is a unique scheduling identifier string.
667  */
668  virtual Incidence::List incidencesFromSchedulingID(const QString &sid) const;
669 
670  /**
671  Create a merged list of Events, Todos, and Journals.
672 
673  @param events is an Event list to merge.
674  @param todos is a Todo list to merge.
675  @param journals is a Journal list to merge.
676 
677  @return a list of merged Incidences.
678  */
679  static Incidence::List mergeIncidenceList(const Event::List &events, const Todo::List &todos, const Journal::List &journals);
680 
681  /**
682  Flag that a change to a Calendar Incidence is starting.
683  @param incidence is a pointer to the Incidence that will be changing.
684  */
685  virtual bool beginChange(const Incidence::Ptr &incidence);
686 
687  /**
688  Flag that a change to a Calendar Incidence has completed.
689  @param incidence is a pointer to the Incidence that was changed.
690  */
691  virtual bool endChange(const Incidence::Ptr &incidence);
692 
693  /**
694  Creates an exception for an occurrence from a recurring Incidence.
695 
696  The returned exception is not automatically inserted into the calendar.
697 
698  @param incidence is a pointer to a recurring Incidence.
699  @param recurrenceId specifies the specific occurrence for which the
700  exception applies.
701  @param thisAndFuture specifies if the exception applies only this specific
702  occcurrence or also to all future occurrences.
703 
704  @return a pointer to a new exception incidence with @param recurrenceId set.
705  @since 4.11
706  */
707  static Incidence::Ptr createException(const Incidence::Ptr &incidence, const QDateTime &recurrenceId, bool thisAndFuture = false);
708 
709  // Event Specific Methods //
710 
711  /**
712  Inserts an Event into the calendar.
713 
714  @param event is a pointer to the Event to insert.
715 
716  @return true if the Event was successfully inserted; false otherwise.
717 
718  @see deleteEvent()
719  */
720  virtual bool addEvent(const Event::Ptr &event) = 0;
721 
722  /**
723  Removes an Event from the calendar.
724 
725  @param event is a pointer to the Event to remove.
726 
727  @return true if the Event was successfully remove; false otherwise.
728 
729  @see addEvent()
730  */
731  virtual bool deleteEvent(const Event::Ptr &event) = 0;
732 
733  /**
734  Delete all events that are instances of recurring event @p event.
735 
736  @param event is a pointer to a deleted Event
737  @return true if delete was successful; false otherwise
738  */
739  virtual bool deleteEventInstances(const Event::Ptr &event) = 0;
740 
741 #if KCALENDARCORE_ENABLE_DEPRECATED_SINCE(5, 95)
742  /**
743  Sort a list of Events.
744 
745  @param eventList is a pointer to a list of Events.
746  @param sortField specifies the EventSortField.
747  @param sortDirection specifies the SortDirection.
748 
749  @return a list of Events sorted as specified.
750 
751  @deprecated since 5.95 Use the sortEvents(Event::List &&eventList, EventSortField sortField, SortDirection sortDirection)
752  overload instead. In the common case that you are sorting a list in-place, wrapping the @p eventList
753  argument with std::move will be all that's needed. In the less common case you actually want a copy,
754  create that explicitly first.
755  */
756  KCALENDARCORE_DEPRECATED_VERSION(
757  5,
758  95,
759  "Use sortEvents(Event::List &&eventList, EventSortField sortField, SortDirection sortDirection); see API docs for details.")
760  static Event::List sortEvents(const Event::List &eventList, EventSortField sortField, SortDirection sortDirection);
761 #endif
762  /**
763  Sort a list of Events.
764 
765  @param eventList the list of events that should be sorted. The list is sorted in place and returned.
766  @param sortField specifies the EventSortField.
767  @param sortDirection specifies the SortDirection.
768 
769  @return a list of Events sorted as specified.
770  @since 5.95
771  */
772  static Event::List sortEvents(Event::List &&eventList, EventSortField sortField, SortDirection sortDirection);
773 
774  /**
775  Returns a sorted, filtered list of all Events for this Calendar.
776 
777  @param sortField specifies the EventSortField.
778  @param sortDirection specifies the SortDirection.
779 
780  @return the list of all filtered Events sorted as specified.
781  */
782  virtual Event::List events(EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const;
783 
784  /**
785  Returns a filtered list of all Events which occur on the given timestamp.
786 
787  @param dt request filtered Event list for this QDateTime only.
788 
789  @return the list of filtered Events occurring on the specified timestamp.
790  */
791  Q_REQUIRED_RESULT Event::List events(const QDateTime &dt) const;
792 
793  /**
794  Returns a filtered list of all Events occurring within a date range.
795 
796  @param start is the starting date.
797  @param end is the ending date.
798  @param timeZone time zone to interpret @p start and @p end,
799  or the calendar's default time zone if none is specified
800  @param inclusive if true only Events which are completely included
801  within the date range are returned.
802 
803  @return the list of filtered Events occurring within the specified
804  date range.
805  */
806  Q_REQUIRED_RESULT Event::List events(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const;
807 
808  /**
809  Returns a sorted, filtered list of all Events which occur on the given
810  date. The Events are sorted according to @a sortField and
811  @a sortDirection.
812 
813  @param date request filtered Event list for this QDate only.
814  @param timeZone time zone to interpret @p start and @p end,
815  or the calendar's default time zone if none is specified
816  @param sortField specifies the EventSortField.
817  @param sortDirection specifies the SortDirection.
818 
819  @return the list of sorted, filtered Events occurring on @a date.
820  */
821  Q_REQUIRED_RESULT Event::List events(const QDate &date,
822  const QTimeZone &timeZone = {},
823  EventSortField sortField = EventSortUnsorted,
824  SortDirection sortDirection = SortDirectionAscending) const;
825 
826  /**
827  Returns a sorted, unfiltered list of all Events for this Calendar.
828 
829  @param sortField specifies the EventSortField.
830  @param sortDirection specifies the SortDirection.
831 
832  @return the list of all unfiltered Events sorted as specified.
833  */
834  virtual Event::List rawEvents(EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0;
835 
836 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 95)
837  /**
838  Returns an unfiltered list of all Events which occur on the given
839  timestamp.
840 
841  @param dt request unfiltered Event list for this QDateTime only.
842 
843  @return the list of unfiltered Events occurring on the specified
844  timestamp.
845 
846  @deprecated since 5.95 use rawEventsForDate(dt.date(), dt.timeZone()) overload instead.
847  */
848  KCALENDARCORE_DEPRECATED_VERSION(5, 95, "Use rawEventsForDate(dt.date(), dt.timeZone()) insead")
849  virtual Event::List rawEventsForDate(const QDateTime &dt) const = 0;
850 #endif
851 
852  /**
853  Returns an unfiltered list of all Events occurring within a date range.
854 
855  @param start is the starting date
856  @param end is the ending date
857  @param timeZone time zone to interpret @p start and @p end,
858  or the calendar's default time zone if none is specified
859  @param inclusive if true only Events which are completely included
860  within the date range are returned.
861 
862  @return the list of unfiltered Events occurring within the specified
863  date range.
864  */
865  virtual Event::List rawEvents(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const = 0;
866 
867  /**
868  Returns a sorted, unfiltered list of all Events which occur on the given
869  date. The Events are sorted according to @a sortField and
870  @a sortDirection.
871 
872  @param date request unfiltered Event list for this QDate only
873  @param timeZone time zone to interpret @p date,
874  or the calendar's default time zone if none is specified
875  @param sortField specifies the EventSortField
876  @param sortDirection specifies the SortDirection
877 
878  @return the list of sorted, unfiltered Events occurring on @p date
879  */
880  virtual Event::List rawEventsForDate(const QDate &date,
881  const QTimeZone &timeZone = {},
882  EventSortField sortField = EventSortUnsorted,
883  SortDirection sortDirection = SortDirectionAscending) const = 0;
884 
885  /**
886  Returns the Event associated with the given unique identifier.
887 
888  @param uid is a unique identifier string.
889  @param recurrenceId is possible recurrenceId of event, default is null
890 
891  @return a pointer to the Event.
892  A null pointer is returned if no such Event exists.
893  */
894  virtual Event::Ptr event(const QString &uid, const QDateTime &recurrenceId = {}) const = 0;
895 
896  /**
897  Returns the deleted Event associated with the given unique identifier.
898 
899  @param uid is a unique identifier string.
900  @param recurrenceId is possible recurrenceId of event, default is null
901 
902  @return a pointer to the deleted Event.
903  A null pointer is returned if no such deleted Event exists, or if deletion tracking
904  is disabled.
905 
906  @see deletionTracking()
907  */
908  virtual Event::Ptr deletedEvent(const QString &uid, const QDateTime &recurrenceId = {}) const = 0;
909 
910  /**
911  Returns a sorted, unfiltered list of all deleted Events for this Calendar.
912 
913  @param sortField specifies the EventSortField.
914  @param sortDirection specifies the SortDirection.
915 
916  @return the list of all unfiltered deleted Events sorted as specified. An empty list
917  is returned if deletion tracking is disabled.
918 
919  @see deletionTracking()
920  */
921  virtual Event::List deletedEvents(EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0;
922 
923  /**
924  Returns a sorted, unfiltered list of all possible instances for this recurring Event.
925 
926  @param event event to check for. Caller guarantees it's of type Event.
927  @param sortField specifies the EventSortField.
928  @param sortDirection specifies the SortDirection.
929 
930  @return the list of all unfiltered event instances sorted as specified.
931  */
932  virtual Event::List
933  eventInstances(const Incidence::Ptr &event, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0;
934 
935  // Todo Specific Methods //
936 
937  /**
938  Inserts a Todo into the calendar.
939 
940  @param todo is a pointer to the Todo to insert.
941 
942  @return true if the Todo was successfully inserted; false otherwise.
943 
944  @see deleteTodo()
945  */
946  virtual bool addTodo(const Todo::Ptr &todo) = 0;
947 
948  /**
949  Removes a Todo from the calendar.
950 
951  @param todo is a pointer to the Todo to remove.
952 
953  @return true if the Todo was successfully removed; false otherwise.
954 
955  @see addTodo()
956  */
957  virtual bool deleteTodo(const Todo::Ptr &todo) = 0;
958 
959  /**
960  Delete all to-dos that are instances of recurring to-do @p todo.
961  @param todo is a pointer to a deleted Todo
962  @return true if delete was successful; false otherwise
963  */
964  virtual bool deleteTodoInstances(const Todo::Ptr &todo) = 0;
965 
966 #if KCALENDARCORE_ENABLE_DEPRECATED_SINCE(5, 95)
967  /**
968  Sort a list of Todos.
969 
970  @param todoList is a pointer to a list of Todos.
971  @param sortField specifies the TodoSortField.
972  @param sortDirection specifies the SortDirection.
973 
974  @return a list of Todos sorted as specified.
975 
976  @deprecated since 5.95 Use the sortTodos(Todo::List &&todoList, TodoSortField sortField, SortDirection sortDirection)
977  overload instead. In the common case that you are sorting a list in-place, wrapping the @p todoList
978  argument with std::move will be all that's needed. In the less common case you actually want a copy,
979  create that explicitly first.
980  */
981  KCALENDARCORE_DEPRECATED_VERSION(5,
982  95,
983  "Use sortTodos(Todo::List &&todoList, TodoSortField sortField, SortDirection sortDirection); see API docs for details.")
984  static Todo::List sortTodos(const Todo::List &todoList, TodoSortField sortField, SortDirection sortDirection);
985 #endif
986  /**
987  Sort a list of Todos.
988 
989  @param todoList the list of todos that should be sorted. The list is sorted in place and returned.
990  @param sortField specifies the TodoSortField.
991  @param sortDirection specifies the SortDirection.
992 
993  @return a list of Todos sorted as specified.
994 
995  @since 5.95
996  */
997  static Todo::List sortTodos(Todo::List &&todoList, TodoSortField sortField, SortDirection sortDirection);
998 
999  /**
1000  Returns a sorted, filtered list of all Todos for this Calendar.
1001 
1002  @param sortField specifies the TodoSortField.
1003  @param sortDirection specifies the SortDirection.
1004 
1005  @return the list of all filtered Todos sorted as specified.
1006  */
1007  virtual Todo::List todos(TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const;
1008 
1009  /**
1010  Returns a filtered list of all Todos which are due on the specified date.
1011 
1012  @param date request filtered Todos due on this QDate.
1013 
1014  @return the list of filtered Todos due on the specified date.
1015  */
1016  virtual Todo::List todos(const QDate &date) const;
1017 
1018  /**
1019  Returns a filtered list of all Todos occurring within a date range.
1020 
1021  @param start is the starting date
1022  @param end is the ending date
1023  @param timeZone time zone to interpret @p start and @p end,
1024  or the calendar's default time zone if none is specified
1025  @param inclusive if true only Todos which are completely included
1026  within the date range are returned.
1027 
1028  @return the list of filtered Todos occurring within the specified
1029  date range.
1030  */
1031  virtual Todo::List todos(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const;
1032 
1033  /**
1034  Returns a sorted, unfiltered list of all Todos for this Calendar.
1035 
1036  @param sortField specifies the TodoSortField.
1037  @param sortDirection specifies the SortDirection.
1038 
1039  @return the list of all unfiltered Todos sorted as specified.
1040  */
1041  virtual Todo::List rawTodos(TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0;
1042 
1043  /**
1044  Returns an unfiltered list of all Todos which due on the specified date.
1045 
1046  @param date request unfiltered Todos due on this QDate.
1047 
1048  @return the list of unfiltered Todos due on the specified date.
1049  */
1050  virtual Todo::List rawTodosForDate(const QDate &date) const = 0;
1051 
1052  /**
1053  Returns an unfiltered list of all Todos occurring within a date range.
1054 
1055  @param start is the starting date
1056  @param end is the ending date
1057  @param timeZone time zone to interpret @p start and @p end,
1058  or the calendar's default time zone if none is specified
1059  @param inclusive if true only Todos which are completely included
1060  within the date range are returned.
1061 
1062  @return the list of unfiltered Todos occurring within the specified
1063  date range.
1064  */
1065  virtual Todo::List rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const = 0;
1066 
1067  /**
1068  Returns the Todo associated with the given unique identifier.
1069 
1070  @param uid is a unique identifier string.
1071  @param recurrenceId is possible recurrenceId of todo, default is null
1072 
1073  @return a pointer to the Todo.
1074  A null pointer is returned if no such Todo exists.
1075  */
1076  virtual Todo::Ptr todo(const QString &uid, const QDateTime &recurrenceId = {}) const = 0;
1077 
1078  /**
1079  Returns the deleted Todo associated with the given unique identifier.
1080 
1081  @param uid is a unique identifier string.
1082  @param recurrenceId is possible recurrenceId of todo, default is null
1083 
1084  @return a pointer to the deleted Todo.
1085  A null pointer is returned if no such deleted Todo exists or if deletion tracking
1086  is disabled.
1087 
1088  @see deletionTracking()
1089  */
1090  virtual Todo::Ptr deletedTodo(const QString &uid, const QDateTime &recurrenceId = {}) const = 0;
1091 
1092  /**
1093  Returns a sorted, unfiltered list of all deleted Todos for this Calendar.
1094 
1095  @param sortField specifies the TodoSortField.
1096  @param sortDirection specifies the SortDirection.
1097 
1098  @return the list of all unfiltered deleted Todos sorted as specified. An empty list
1099  is returned if deletion tracking is disabled.
1100 
1101  @see deletionTracking()
1102  */
1103  virtual Todo::List deletedTodos(TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0;
1104 
1105  /**
1106  Returns a sorted, unfiltered list of all possible instances for this recurring Todo.
1107 
1108  @param todo todo to check for. Caller guarantees it's of type Todo.
1109  @param sortField specifies the TodoSortField.
1110  @param sortDirection specifies the SortDirection.
1111 
1112  @return the list of all unfiltered todo instances sorted as specified.
1113  */
1114  virtual Todo::List
1115  todoInstances(const Incidence::Ptr &todo, TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0;
1116 
1117  // Journal Specific Methods //
1118 
1119  /**
1120  Inserts a Journal into the calendar.
1121 
1122  @param journal is a pointer to the Journal to insert.
1123 
1124  @return true if the Journal was successfully inserted; false otherwise.
1125 
1126  @see deleteJournal()
1127  */
1128  virtual bool addJournal(const Journal::Ptr &journal) = 0;
1129 
1130  /**
1131  Removes a Journal from the calendar.
1132 
1133  @param journal is a pointer to the Journal to remove.
1134 
1135  @return true if the Journal was successfully removed; false otherwise.
1136 
1137  @see addJournal()
1138  */
1139  virtual bool deleteJournal(const Journal::Ptr &journal) = 0;
1140 
1141  /**
1142  Delete all journals that are instances of recurring journal @p journal.
1143 
1144  @param journal is a pointer to a deleted Journal
1145  @return true if delete was successful; false otherwise
1146  */
1147  virtual bool deleteJournalInstances(const Journal::Ptr &journal) = 0;
1148 
1149 #if KCALENDARCORE_ENABLE_DEPRECATED_SINCE(5, 95)
1150  /**
1151  Sort a list of Journals.
1152 
1153  @param journalList is a pointer to a list of Journals.
1154  @param sortField specifies the JournalSortField.
1155  @param sortDirection specifies the SortDirection.
1156 
1157  @return a list of Journals sorted as specified.
1158 
1159  @deprecated since 5.95 Use the sortJournals(Journal::List &&journalList, JournalSortField sortField, SortDirection sortDirection)
1160  overload instead. In the common case that you are sorting a list in-place, wrapping the @p journalList
1161  argument with std::move will be all that's needed. In the less common case you actually want a copy,
1162  create that explicitly first.
1163  */
1164  KCALENDARCORE_DEPRECATED_VERSION(
1165  5,
1166  95,
1167  "Use sortJournals(Journal::List &&journalList, JournalSortField sortField, SortDirection sortDirection); see API docs for details.")
1168  static Journal::List sortJournals(const Journal::List &journalList, JournalSortField sortField, SortDirection sortDirection);
1169 #endif
1170  /**
1171  Sort a list of Journals.
1172 
1173  @param journalList the list of journals that should be sorted. The list is sorted in place and returned.
1174  @param sortField specifies the JournalSortField.
1175  @param sortDirection specifies the SortDirection.
1176 
1177  @return a list of Journals sorted as specified.
1178  @since 5.95
1179  */
1180  static Journal::List sortJournals(Journal::List &&journalList, JournalSortField sortField, SortDirection sortDirection);
1181 
1182  /**
1183  Returns a sorted, filtered list of all Journals for this Calendar.
1184 
1185  @param sortField specifies the JournalSortField.
1186  @param sortDirection specifies the SortDirection.
1187 
1188  @return the list of all filtered Journals sorted as specified.
1189  */
1190  virtual Journal::List journals(JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const;
1191 
1192  /**
1193  Returns a filtered list of all Journals for on the specified date.
1194 
1195  @param date request filtered Journals for this QDate only.
1196 
1197  @return the list of filtered Journals for the specified date.
1198  */
1199  virtual Journal::List journals(const QDate &date) const;
1200 
1201  /**
1202  Returns a sorted, unfiltered list of all Journals for this Calendar.
1203 
1204  @param sortField specifies the JournalSortField.
1205  @param sortDirection specifies the SortDirection.
1206 
1207  @return the list of all unfiltered Journals sorted as specified.
1208  */
1209  virtual Journal::List rawJournals(JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0;
1210 
1211  /**
1212  Returns an unfiltered list of all Journals for on the specified date.
1213 
1214  @param date request unfiltered Journals for this QDate only.
1215 
1216  @return the list of unfiltered Journals for the specified date.
1217  */
1218  virtual Journal::List rawJournalsForDate(const QDate &date) const = 0;
1219 
1220  /**
1221  Returns the Journal associated with the given unique identifier.
1222 
1223  @param uid is a unique identifier string.
1224  @param recurrenceId is possible recurrenceId of journal, default is null
1225 
1226  @return a pointer to the Journal.
1227  A null pointer is returned if no such Journal exists.
1228  */
1229  virtual Journal::Ptr journal(const QString &uid, const QDateTime &recurrenceId = {}) const = 0;
1230 
1231  /**
1232  Returns the deleted Journal associated with the given unique identifier.
1233 
1234  @param uid is a unique identifier string.
1235  @param recurrenceId is possible recurrenceId of journal, default is null
1236 
1237  @return a pointer to the deleted Journal.
1238  A null pointer is returned if no such deleted Journal exists or if deletion tracking
1239  is disabled.
1240 
1241  @see deletionTracking()
1242  */
1243  virtual Journal::Ptr deletedJournal(const QString &uid, const QDateTime &recurrenceId = {}) const = 0;
1244 
1245  /**
1246  Returns a sorted, unfiltered list of all deleted Journals for this Calendar.
1247 
1248  @param sortField specifies the JournalSortField.
1249  @param sortDirection specifies the SortDirection.
1250 
1251  @return the list of all unfiltered deleted Journals sorted as specified. An empty list
1252  is returned if deletion tracking is disabled.
1253 
1254  @see deletionTracking()
1255  */
1256  virtual Journal::List deletedJournals(JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0;
1257 
1258  /**
1259  Returns a sorted, unfiltered list of all instances for this recurring Journal.
1260 
1261  @param journal journal to check for. Caller guarantees it's of type Journal.
1262  @param sortField specifies the JournalSortField.
1263  @param sortDirection specifies the SortDirection.
1264 
1265  @return the list of all unfiltered journal instances sorted as specified.
1266  */
1267  virtual Journal::List journalInstances(const Incidence::Ptr &journal,
1269  SortDirection sortDirection = SortDirectionAscending) const = 0;
1270 
1271  // Relations Specific Methods //
1272 
1273  /**
1274  Setup Relations for an Incidence.
1275  @param incidence is a pointer to the Incidence to have a Relation setup.
1276  @deprecated since 5.106
1277  */
1278  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "Relation API is going to be removed in KF6.")
1279  virtual void setupRelations(const Incidence::Ptr &incidence);
1280 
1281  /**
1282  Removes all Relations from an Incidence.
1283 
1284  @param incidence is a pointer to the Incidence to have a Relation removed.
1285  @deprecated since 5.106
1286  */
1287  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "Relation API is going to be removed in KF6.")
1288  virtual void removeRelations(const Incidence::Ptr &incidence);
1289 
1290  /**
1291  Checks if @p ancestor is an ancestor of @p incidence
1292 
1293  @param ancestor is the incidence we are testing to be an ancestor.
1294  @param incidence is the incidence we are testing to be descended from @p ancestor.
1295  @deprecated since 5.106
1296  */
1297  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "Relation API is going to be removed in KF6.")
1298  bool isAncestorOf(const Incidence::Ptr &ancestor, const Incidence::Ptr &incidence) const;
1299 
1300  /**
1301  Returns a list of incidences that have a relation of RELTYPE parent
1302  to incidence @p uid.
1303 
1304  @param uid The parent identifier whose children we want to obtain.
1305  @deprecated since 5.106
1306  */
1307  KCALENDARCORE_DEPRECATED_VERSION(5, 106, "Relation API is going to be removed in KF6.")
1308  Incidence::List relations(const QString &uid) const;
1309 
1310  // Filter Specific Methods //
1311 
1312  /**
1313  Sets the calendar filter.
1314 
1315  @param filter a pointer to a CalFilter object which will be
1316  used to filter Calendar Incidences. The Calendar takes
1317  ownership of @p filter.
1318 
1319  @see filter()
1320  */
1321  void setFilter(CalFilter *filter);
1322 
1323  /**
1324  Returns the calendar filter.
1325 
1326  @return a pointer to the calendar CalFilter.
1327  A null pointer is returned if no such CalFilter exists.
1328 
1329  @see setFilter()
1330  */
1331  CalFilter *filter() const;
1332 
1333  // Alarm Specific Methods //
1334 
1335  /**
1336  Returns a list of Alarms within a time range for this Calendar.
1337 
1338  @param from is the starting timestamp.
1339  @param to is the ending timestamp.
1340  @param excludeBlockedAlarms if true, alarms belonging to blocked collections aren't returned.
1341 
1342  @return the list of Alarms for the for the specified time range.
1343  */
1344  virtual Alarm::List alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms = false) const = 0;
1345 
1346  /**
1347  Return a list of Alarms that occur before the specified timestamp.
1348 
1349  @param to is the ending timestamp.
1350  @return the list of Alarms occurring before the specified QDateTime.
1351  @since 5.77
1352  */
1353  Q_REQUIRED_RESULT Alarm::List alarmsTo(const QDateTime &to) const;
1354 
1355  // Observer Specific Methods //
1356 
1357  /**
1358  @class CalendarObserver
1359 
1360  The CalendarObserver class.
1361  */
1362  class KCALENDARCORE_EXPORT CalendarObserver // krazy:exclude=dpointer
1363  {
1364  public:
1365  /**
1366  Destructor.
1367  */
1368  virtual ~CalendarObserver();
1369 
1370  /**
1371  Notify the Observer that a Calendar has been modified.
1372 
1373  @param modified set if the calendar has been modified.
1374  @param calendar is a pointer to the Calendar object that
1375  is being observed.
1376  */
1377  virtual void calendarModified(bool modified, Calendar *calendar);
1378 
1379  /**
1380  Notify the Observer that an Incidence has been inserted.
1381  @param incidence is a pointer to the Incidence that was inserted.
1382  */
1383  virtual void calendarIncidenceAdded(const Incidence::Ptr &incidence);
1384 
1385  /**
1386  Notify the Observer that an Incidence has been modified.
1387  @param incidence is a pointer to the Incidence that was modified.
1388  */
1389  virtual void calendarIncidenceChanged(const Incidence::Ptr &incidence);
1390 
1391  /**
1392  Notify the Observer that an Incidence will be removed.
1393  @param incidence is a pointer to the Incidence that will be removed.
1394  */
1395  virtual void calendarIncidenceAboutToBeDeleted(const Incidence::Ptr &incidence);
1396 
1397  /**
1398  Notify the Observer that an Incidence has been removed.
1399  @param incidence is a pointer to the Incidence that was removed.
1400  @param calendar is a pointer to the calendar where the incidence was part of,
1401  because the incidence was deleted, there is now way to determine the calendar
1402  @since 4.83.0
1403  */
1404  virtual void calendarIncidenceDeleted(const Incidence::Ptr &incidence, const Calendar *calendar);
1405 
1406  /**
1407  Notify the Observer that an addition of Incidence has been canceled.
1408  @param incidence is a pointer to the Incidence that was removed.
1409  */
1410  virtual void calendarIncidenceAdditionCanceled(const Incidence::Ptr &incidence);
1411  };
1412 
1413  /**
1414  Registers an Observer for this Calendar.
1415 
1416  @param observer is a pointer to an Observer object that will be
1417  watching this Calendar.
1418 
1419  @see unregisterObserver()
1420  */
1421  void registerObserver(CalendarObserver *observer);
1422 
1423  /**
1424  Unregisters an Observer for this Calendar.
1425 
1426  @param observer is a pointer to an Observer object that has been
1427  watching this Calendar.
1428 
1429  @see registerObserver()
1430  */
1431  void unregisterObserver(CalendarObserver *observer);
1432 
1433  using QObject::event; // prevent warning about hidden virtual method
1434 
1435 protected:
1436  /**
1437  The Observer interface. So far not implemented.
1438  @param uid is the UID for the Incidence that has been updated.
1439  @param recurrenceId is possible recurrenceid of incidence.
1440  */
1441  void incidenceUpdated(const QString &uid, const QDateTime &recurrenceId) override;
1442 
1443  /**
1444  Let Calendar subclasses set the time specification.
1445  @param timeZone is the time specification (time zone, etc.) for
1446  viewing Incidence dates.\n
1447  */
1448  virtual void doSetTimeZone(const QTimeZone &timeZone);
1449 
1450  /**
1451  Let Calendar subclasses notify that they inserted an Incidence.
1452  @param incidence is a pointer to the Incidence object that was inserted.
1453  */
1454  void notifyIncidenceAdded(const Incidence::Ptr &incidence);
1455 
1456  /**
1457  Let Calendar subclasses notify that they modified an Incidence.
1458  @param incidence is a pointer to the Incidence object that was modified.
1459  */
1460  void notifyIncidenceChanged(const Incidence::Ptr &incidence);
1461 
1462  /**
1463  Let Calendar subclasses notify that they will remove an Incidence.
1464  @param incidence is a pointer to the Incidence object that will be removed.
1465  */
1466  void notifyIncidenceAboutToBeDeleted(const Incidence::Ptr &incidence);
1467 
1468  /**
1469  Let Calendar subclasses notify that they removed an Incidence.
1470  @param incidence is a pointer to the Incidence object that has been removed.
1471  */
1472  void notifyIncidenceDeleted(const Incidence::Ptr &incidence);
1473 
1474  /**
1475  Let Calendar subclasses notify that they canceled addition of an Incidence.
1476  @param incidence is a pointer to the Incidence object that addition as canceled.
1477  */
1478  void notifyIncidenceAdditionCanceled(const Incidence::Ptr &incidence);
1479 
1480  /**
1481  @copydoc
1482  CustomProperties::customPropertyUpdated()
1483  */
1484  void customPropertyUpdated() override;
1485 
1486  /**
1487  Let Calendar subclasses notify that they enabled an Observer.
1488 
1489  @param enabled if true tells the calendar that a subclass has
1490  enabled an Observer.
1491  */
1492  void setObserversEnabled(bool enabled);
1493 
1494  /**
1495  Appends alarms of incidence in interval to list of alarms.
1496 
1497  @param alarms is a List of Alarms to be appended onto.
1498  @param incidence is a pointer to an Incidence containing the Alarm
1499  to be appended.
1500  @param from is the lower range of the next Alarm repetition.
1501  @param to is the upper range of the next Alarm repetition.
1502  */
1503  void appendAlarms(Alarm::List &alarms, const Incidence::Ptr &incidence, const QDateTime &from, const QDateTime &to) const;
1504 
1505  /**
1506  Appends alarms of recurring events in interval to list of alarms.
1507 
1508  @param alarms is a List of Alarms to be appended onto.
1509  @param incidence is a pointer to an Incidence containing the Alarm
1510  to be appended.
1511  @param from is the lower range of the next Alarm repetition.
1512  @param to is the upper range of the next Alarm repetition.
1513  */
1514  void appendRecurringAlarms(Alarm::List &alarms, const Incidence::Ptr &incidence, const QDateTime &from, const QDateTime &to) const;
1515 
1516  /**
1517  Enables or disabled deletion tracking.
1518  Default is true.
1519  @see deletedEvent()
1520  @see deletedTodo()
1521  @see deletedJournal()
1522  @since 4.11
1523  */
1524  void setDeletionTracking(bool enable);
1525 
1526  /**
1527  Returns if deletion tracking is enabled.
1528  Default is true.
1529  @since 4.11
1530  */
1531  bool deletionTracking() const;
1532 
1533  /**
1534  * Sets the loading state of this calendar.
1535  * This is false by default and only needs to be called for calendars
1536  * that implement asynchronous loading.
1537  * @since 5.96
1538  * @see isLoading()
1539  */
1540  void setIsLoading(bool isLoading);
1541 
1542  /**
1543  @copydoc
1544  IncidenceBase::virtual_hook()
1545  */
1546  virtual void virtual_hook(int id, void *data);
1547 
1548 Q_SIGNALS:
1549  /**
1550  Emitted when setFilter() is called.
1551  @since 4.11
1552  */
1553  void filterChanged();
1554 
1555  /**
1556  * Emitted when the id changes.
1557  * @since 5.85
1558  * @see id()
1559  */
1560  void idChanged();
1561 
1562  /**
1563  * Emitted when the name changes.
1564  * @since 5.85
1565  * @see name()
1566  */
1567  void nameChanged();
1568 
1569  /**
1570  * Emitted when the icon name changes.
1571  * @since 5.85
1572  * @see icon()
1573  */
1574  void iconChanged();
1575 
1576  /**
1577  * Emitted when the AccessMode changes.
1578  * @since 5.85
1579  * @see accessMode()
1580  */
1581  void accessModeChanged();
1582 
1583  /**
1584  * Emitted when the owner changes.
1585  * @since 5.85
1586  * @see owner()
1587  */
1588  void ownerChanged();
1589 
1590  /**
1591  * Emitted when the loading state changed.
1592  * @since 5.96
1593  * @see isLoading()
1594  */
1595  void isLoadingChanged();
1596 
1597 private:
1598  friend class ICalFormat;
1599 
1600  //@cond PRIVATE
1601  class Private;
1602  Private *const d;
1603  //@endcond
1604 
1605  Q_DISABLE_COPY(Calendar)
1606 };
1607 
1608 }
1609 
1610 Q_DECLARE_METATYPE(KCalendarCore::Calendar::Ptr)
1611 
1612 #endif
@ TodoSortUnsorted
Do not sort Todos.
Definition: calendar.h:81
@ JournalSortDate
Sort Journals chronologically by date.
Definition: calendar.h:96
TodoSortField
Calendar Todo sort keys.
Definition: calendar.h:80
JournalSortField
Calendar Journal sort keys.
Definition: calendar.h:94
Namespace for all KCalendarCore types.
Definition: alarm.h:36
QSharedPointer< Calendar > Ptr
A shared pointer to a Calendar.
Definition: calendar.h:147
@ TodoSortCategories
Sort Todos by categories (tags)
Definition: calendar.h:88
Q_SCRIPTABLE Q_NOREPLY void start()
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition: incidence.h:59
@ TodoSortPercentComplete
Sort Todos by percentage completed.
Definition: calendar.h:85
Q_SCRIPTABLE bool setFilter(const QString &filter)
QSharedPointer< Journal > Ptr
A shared pointer to a Journal object.
Definition: journal.h:38
AccessMode
The calendar's access mode, i.e.
Definition: calendar.h:104
@ EventSortStartDate
Sort Events chronologically, by start date.
Definition: calendar.h:72
@ TodoSortSummary
Sort Todos alphabetically, by summary.
Definition: calendar.h:86
An abstract class that provides a common base for all calendar incidence classes.
Definition: incidencebase.h:98
Represents the main calendar class.
Definition: calendar.h:132
EventSortField
Calendar Event sort keys.
Definition: calendar.h:70
virtual bool event(QEvent *e)
QSharedPointer< Incidence > Ptr
A shared pointer to an Incidence.
Definition: incidence.h:121
@ EventSortUnsorted
Do not sort Events.
Definition: calendar.h:71
@ TodoSortStartDate
Sort Todos chronologically, by start date.
Definition: calendar.h:82
@ SortDirectionDescending
Sort in descending order (last to first)
Definition: calendar.h:64
QSharedPointer< Todo > Ptr
A shared pointer to a Todo object.
Definition: todo.h:39
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
@ JournalSortUnsorted
Do not sort Journals.
Definition: calendar.h:95
SortDirection
Calendar Incidence sort directions.
Definition: calendar.h:62
@ TodoSortDueDate
Sort Todos chronologically, by due date.
Definition: calendar.h:83
iCalendar format implementation.
Definition: icalformat.h:44
QVector< Ptr > List
List of incidences.
Definition: incidence.h:126
AKONADI_CALENDAR_EXPORT KCalendarCore::Journal::Ptr journal(const Akonadi::Item &item)
@ EventSortEndDate
Sort Events chronologically, by end date.
Definition: calendar.h:73
@ EventSortSummary
Sort Events alphabetically, by summary.
Definition: calendar.h:74
@ JournalSortSummary
Sort Journals alphabetically, by summary.
Definition: calendar.h:97
@ TodoSortCreated
Sort Todos chronologically, by creation date.
Definition: calendar.h:87
@ SortDirectionAscending
Sort in ascending order (first to last)
Definition: calendar.h:63
Represents a person, by name and email address.
Definition: person.h:37
QVector< Ptr > List
List of events.
Definition: event.h:55
QVector< Ptr > List
List of journals.
Definition: journal.h:43
@ TodoSortPriority
Sort Todos by priority.
Definition: calendar.h:84
A class to manage custom calendar properties.
AKONADI_CALENDAR_EXPORT KCalendarCore::Todo::Ptr todo(const Akonadi::Item &item)
QSharedPointer< Event > Ptr
A shared pointer to an Event object.
Definition: event.h:50
QVector< Ptr > List
List of to-dos.
Definition: todo.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 2 2023 04:01:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.