File indexing completed on 2024-04-21 07:39:34
0001 /* 0002 This file is part of the kcalcore library. 0003 0004 SPDX-FileCopyrightText: 1998 Preston Brown <pbrown@kde.org> 0005 SPDX-FileCopyrightText: 2001, 2003 Cornelius Schumacher <schumacher@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 /** 0010 @file 0011 This file is part of the API for handling calendar data and 0012 defines the MemoryCalendar class. 0013 0014 Very simple implementation of a Calendar that is only in memory 0015 0016 @author Preston Brown \<pbrown@kde.org\> 0017 @author Cornelius Schumacher \<schumacher@kde.org\> 0018 */ 0019 #ifndef KCALCORE_MEMORYCALENDAR_H 0020 #define KCALCORE_MEMORYCALENDAR_H 0021 0022 #include "calendar.h" 0023 #include "kcalendarcore_export.h" 0024 0025 namespace KCalendarCore 0026 { 0027 /** 0028 @brief 0029 This class provides a calendar stored in memory. 0030 */ 0031 class KCALENDARCORE_EXPORT MemoryCalendar : public Calendar 0032 { 0033 Q_OBJECT 0034 public: 0035 /** 0036 A shared pointer to a MemoryCalendar 0037 */ 0038 typedef QSharedPointer<MemoryCalendar> Ptr; 0039 0040 /** 0041 @copydoc Calendar::Calendar(const QTimeZone &) 0042 */ 0043 explicit MemoryCalendar(const QTimeZone &timeZone); 0044 0045 /** 0046 @copydoc Calendar::Calendar(const QString &) 0047 */ 0048 explicit MemoryCalendar(const QByteArray &timeZoneId); 0049 0050 /** 0051 @copydoc Calendar::~Calendar() 0052 */ 0053 ~MemoryCalendar() override; 0054 0055 /** 0056 @copydoc Calendar::doSetTimeZone() 0057 */ 0058 void doSetTimeZone(const QTimeZone &timeZone) override; 0059 0060 /** 0061 @copydoc Calendar::deleteIncidence() 0062 */ 0063 bool deleteIncidence(const Incidence::Ptr &incidence) override; 0064 0065 /** 0066 @copydoc Calendar::deleteIncidenceInstances 0067 */ 0068 bool deleteIncidenceInstances(const Incidence::Ptr &incidence) override; 0069 0070 /** 0071 @copydoc Calendar::addIncidence() 0072 */ 0073 bool addIncidence(const Incidence::Ptr &incidence) override; 0074 0075 // Event Specific Methods // 0076 0077 /** 0078 @copydoc Calendar::addEvent() 0079 */ 0080 bool addEvent(const Event::Ptr &event) override; 0081 0082 /** 0083 @copydoc Calendar::deleteEvent() 0084 */ 0085 bool deleteEvent(const Event::Ptr &event) override; 0086 0087 /** 0088 @copydoc Calendar::deleteEventInstances() 0089 */ 0090 bool deleteEventInstances(const Event::Ptr &event) override; 0091 0092 /** 0093 @copydoc Calendar::rawEvents(EventSortField, SortDirection)const 0094 */ 0095 Q_REQUIRED_RESULT Event::List rawEvents(EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override; 0096 0097 /** 0098 @copydoc Calendar::rawEvents(const QDate &, const QDate &, const QTimeZone &, bool)const 0099 */ 0100 Q_REQUIRED_RESULT Event::List rawEvents(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const override; 0101 0102 /** 0103 Returns an unfiltered list of all Events which occur on the given date. 0104 0105 @param date request unfiltered Event list for this QDate only. 0106 @param timeZone time zone to interpret @p date, or the calendar's 0107 default time zone if none is specified 0108 @param sortField specifies the EventSortField. 0109 @param sortDirection specifies the SortDirection. 0110 0111 @return the list of unfiltered Events occurring on the specified QDate. 0112 */ 0113 Q_REQUIRED_RESULT Event::List rawEventsForDate(const QDate &date, 0114 const QTimeZone &timeZone = {}, 0115 EventSortField sortField = EventSortUnsorted, 0116 SortDirection sortDirection = SortDirectionAscending) const override; 0117 0118 /** 0119 * Returns an incidence by identifier. 0120 * @see Incidence::instanceIdentifier() 0121 * @since 4.11 0122 */ 0123 Incidence::Ptr instance(const QString &identifier) const; 0124 0125 /** 0126 @copydoc Calendar::event() 0127 */ 0128 Q_REQUIRED_RESULT Event::Ptr event(const QString &uid, const QDateTime &recurrenceId = {}) const override; 0129 0130 /** 0131 @copydoc Calendar::eventInstances(const Incidence::Ptr &, EventSortField, SortDirection)const 0132 */ 0133 Q_REQUIRED_RESULT Event::List eventInstances(const Incidence::Ptr &event, 0134 EventSortField sortField = EventSortUnsorted, 0135 SortDirection sortDirection = SortDirectionAscending) const override; 0136 0137 // To-do Specific Methods // 0138 0139 /** 0140 @copydoc Calendar::addTodo() 0141 */ 0142 bool addTodo(const Todo::Ptr &todo) override; 0143 0144 /** 0145 @copydoc Calendar::deleteTodo() 0146 */ 0147 bool deleteTodo(const Todo::Ptr &todo) override; 0148 0149 /** 0150 @copydoc Calendar::deleteTodoInstances() 0151 */ 0152 bool deleteTodoInstances(const Todo::Ptr &todo) override; 0153 0154 /** 0155 @copydoc Calendar::rawTodos(TodoSortField, SortDirection)const 0156 */ 0157 Q_REQUIRED_RESULT Todo::List rawTodos(TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override; 0158 0159 /** 0160 @copydoc Calendar::rawTodos(const QDate &, const QDate &, const QTimeZone &, bool)const 0161 */ 0162 Q_REQUIRED_RESULT Todo::List rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const override; 0163 0164 /** 0165 @copydoc Calendar::rawTodosForDate() 0166 */ 0167 Q_REQUIRED_RESULT Todo::List rawTodosForDate(const QDate &date) const override; 0168 0169 /** 0170 @copydoc Calendar::todo() 0171 */ 0172 Q_REQUIRED_RESULT Todo::Ptr todo(const QString &uid, const QDateTime &recurrenceId = {}) const override; 0173 0174 /** 0175 @copydoc Calendar::todoInstances(const Incidence::Ptr &, TodoSortField, SortDirection)const 0176 */ 0177 Q_REQUIRED_RESULT Todo::List 0178 todoInstances(const Incidence::Ptr &todo, TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const override; 0179 0180 // Journal Specific Methods // 0181 0182 /** 0183 @copydoc Calendar::addJournal() 0184 */ 0185 bool addJournal(const Journal::Ptr &journal) override; 0186 0187 /** 0188 @copydoc Calendar::deleteJournal() 0189 */ 0190 bool deleteJournal(const Journal::Ptr &journal) override; 0191 0192 /** 0193 @copydoc Calendar::deleteJournalInstances() 0194 */ 0195 bool deleteJournalInstances(const Journal::Ptr &journal) override; 0196 0197 /** 0198 @copydoc Calendar::rawJournals() 0199 */ 0200 Q_REQUIRED_RESULT Journal::List rawJournals(JournalSortField sortField = JournalSortUnsorted, 0201 SortDirection sortDirection = SortDirectionAscending) const override; 0202 0203 /** 0204 @copydoc Calendar::rawJournalsForDate() 0205 */ 0206 Q_REQUIRED_RESULT Journal::List rawJournalsForDate(const QDate &date) const override; 0207 0208 /** 0209 @copydoc Calendar::journal() 0210 */ 0211 Journal::Ptr journal(const QString &uid, const QDateTime &recurrenceId = {}) const override; 0212 0213 /** 0214 @copydoc Calendar::journalInstances(const Incidence::Ptr &, 0215 JournalSortField, SortDirection)const 0216 */ 0217 Q_REQUIRED_RESULT Journal::List journalInstances(const Incidence::Ptr &journal, 0218 JournalSortField sortField = JournalSortUnsorted, 0219 SortDirection sortDirection = SortDirectionAscending) const override; 0220 0221 // Alarm Specific Methods // 0222 0223 /** 0224 @copydoc Calendar::alarms() 0225 */ 0226 Q_REQUIRED_RESULT Alarm::List alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms = false) const override; 0227 0228 /** 0229 Return true if the memory calendar is updating the lastModified field 0230 of incidence owned by the calendar on any incidence change. 0231 0232 @since 5.80 0233 */ 0234 bool updateLastModifiedOnChange() const; 0235 0236 /** 0237 Govern if the memory calendar is changing the lastModified field of incidence 0238 it owns, on incidence updates. 0239 0240 @param update, when true, the lastModified field of an incidence owned by the 0241 calendar is set to the current date time on any change of the incidence. 0242 0243 @since 5.80 0244 */ 0245 void setUpdateLastModifiedOnChange(bool update); 0246 0247 /** 0248 @copydoc Calendar::incidenceUpdate(const QString &,const QDateTime &) 0249 */ 0250 void incidenceUpdate(const QString &uid, const QDateTime &recurrenceId) override; 0251 0252 /** 0253 @copydoc Calendar::incidenceUpdated(const QString &,const QDateTime &) 0254 */ 0255 void incidenceUpdated(const QString &uid, const QDateTime &recurrenceId) override; 0256 0257 using QObject::event; // prevent warning about hidden virtual method 0258 0259 protected: 0260 /** 0261 @copydoc IncidenceBase::virtual_hook() 0262 */ 0263 void virtual_hook(int id, void *data) override; 0264 0265 private: 0266 //@cond PRIVATE 0267 class Private; 0268 Private *const d; 0269 //@endcond 0270 0271 Q_DISABLE_COPY(MemoryCalendar) 0272 }; 0273 0274 } 0275 0276 #endif