File indexing completed on 2024-04-21 03:52:51
0001 /* 0002 This file is part of the kcalcore library. 0003 0004 SPDX-FileCopyrightText: 2013 Christian Mollekopf <mollekopf@kolabsys.com> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 /** 0009 @file 0010 This file is part of the API for handling calendar data and 0011 defines the OccurrenceIterator class. 0012 0013 @author Christian Mollekopf \<mollekopf@kolabsys.com\> 0014 */ 0015 0016 #ifndef KCALCORE_OCCURRENCEITERATOR_H 0017 #define KCALCORE_OCCURRENCEITERATOR_H 0018 0019 #include "incidence.h" 0020 #include "kcalendarcore_export.h" 0021 0022 namespace KCalendarCore 0023 { 0024 class Calendar; 0025 /** 0026 * Iterate over calendar items in a calendar. 0027 * 0028 * The iterator takes recurrences and exceptions to recurrences into account 0029 * 0030 * The iterator does not iterate the occurrences of all incidences chronologically. 0031 * @since 4.11 0032 */ 0033 class KCALENDARCORE_EXPORT OccurrenceIterator 0034 { 0035 public: 0036 /** 0037 * Creates iterator that iterates over all occurrences of all incidences 0038 * between @param start and @param end (inclusive) 0039 */ 0040 explicit OccurrenceIterator(const Calendar &calendar, const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime()); 0041 0042 /** 0043 * Creates iterator that iterates over all occurrences 0044 * of @param incidence between @param start and @param end (inclusive) 0045 */ 0046 OccurrenceIterator(const Calendar &calendar, 0047 const KCalendarCore::Incidence::Ptr &incidence, 0048 const QDateTime &start = QDateTime(), 0049 const QDateTime &end = QDateTime()); 0050 ~OccurrenceIterator(); 0051 bool hasNext() const; 0052 0053 /** 0054 * Advance iterator to the next occurrence. 0055 */ 0056 void next(); 0057 0058 /** 0059 * Returns either main incidence or exception, depending on occurrence. 0060 */ 0061 Incidence::Ptr incidence() const; 0062 0063 /** 0064 * Returns the start date of the occurrence 0065 * 0066 * This is either the occurrence date, or the start date of an exception 0067 * which overrides that occurrence. 0068 */ 0069 QDateTime occurrenceStartDate() const; 0070 0071 /** 0072 * Returns the end date of the occurrence 0073 * 0074 * For incidence that supports end date (events and due date for todos), 0075 * this is computed from the duration or directly the end date of 0076 * the occurrence or an exception overriding that occurrence. For incidences 0077 * without end date, an invalid date is returned. 0078 * @since 5.87 0079 */ 0080 QDateTime occurrenceEndDate() const; 0081 0082 /** 0083 * Returns the recurrence Id. 0084 * 0085 * This is the date where the occurrence starts without exceptions, 0086 * this id is used to identify one exact occurrence. 0087 */ 0088 QDateTime recurrenceId() const; 0089 0090 private: 0091 Q_DISABLE_COPY(OccurrenceIterator) 0092 //@cond PRIVATE 0093 class Private; 0094 QScopedPointer<Private> d; 0095 //@endcond 0096 }; 0097 0098 } // namespace 0099 0100 #endif