KCalendarCore

occurrenceiterator.h
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 2013 Christian Mollekopf <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 /**
9  @file
10  This file is part of the API for handling calendar data and
11  defines the OccurrenceIterator class.
12 
13  @author Christian Mollekopf <[email protected]>
14  */
15 
16 #ifndef KCALCORE_OCCURRENCEITERATOR_H
17 #define KCALCORE_OCCURRENCEITERATOR_H
18 
19 #include "incidence.h"
20 #include "kcalendarcore_export.h"
21 
22 namespace KCalendarCore
23 {
24 class Calendar;
25 /**
26  * Iterate over calendar items in a calendar.
27  *
28  * The iterator takes recurrences and exceptions to recurrences into account
29  *
30  * The iterator does not iterate the occurrences of all incidences chronologically.
31  * @since 4.11
32  */
33 class KCALENDARCORE_EXPORT OccurrenceIterator
34 {
35 public:
36  /**
37  * Creates iterator that iterates over all occurrences of all incidences
38  * between @param start and @param end (inclusive)
39  */
40  explicit OccurrenceIterator(const Calendar &calendar, const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime());
41 
42  /**
43  * Creates iterator that iterates over all occurrences
44  * of @param incidence between @param start and @param end (inclusive)
45  */
46  OccurrenceIterator(const Calendar &calendar,
47  const KCalendarCore::Incidence::Ptr &incidence,
48  const QDateTime &start = QDateTime(),
49  const QDateTime &end = QDateTime());
51  bool hasNext() const;
52 
53  /**
54  * Advance iterator to the next occurrence.
55  */
56  void next();
57 
58  /**
59  * Returns either main incidence or exception, depending on occurrence.
60  */
61  Incidence::Ptr incidence() const;
62 
63  /**
64  * Returns the start date of the occurrence
65  *
66  * This is either the occurrence date, or the start date of an exception
67  * which overrides that occurrence.
68  */
69  QDateTime occurrenceStartDate() const;
70 
71  /**
72  * Returns the end date of the occurrence
73  *
74  * For incidence that supports end date (events and due date for todos),
75  * this is computed from the duration or directly the end date of
76  * the occurrence or an exception overriding that occurrence. For incidences
77  * without end date, an invalid date is returned.
78  * @since 5.87
79  */
80  QDateTime occurrenceEndDate() const;
81 
82  /**
83  * Returns the recurrence Id.
84  *
85  * This is the date where the occurrence starts without exceptions,
86  * this id is used to identify one exact occurrence.
87  */
88  QDateTime recurrenceId() const;
89 
90 private:
91  Q_DISABLE_COPY(OccurrenceIterator)
92  //@cond PRIVATE
93  class Private;
95  //@endcond
96 };
97 
98 } // namespace
99 
100 #endif
Namespace for all KCalendarCore types.
Definition: alarm.h:36
Represents the main calendar class.
Definition: calendar.h:132
Q_SCRIPTABLE Q_NOREPLY void start()
Iterate over calendar items in a calendar.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 28 2023 03:53:12 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.