1 | /* |
2 | This file is part of the kcalcore library. |
3 | |
4 | Copyright (c) 2013 Christian Mollekopf <mollekopf@kolabsys.com> |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | /** |
22 | @file |
23 | This file is part of the API for handling calendar data and |
24 | defines the OccurrenceIterator class. |
25 | |
26 | @author Christian Mollekopf \<mollekopf@kolabsys.com\> |
27 | */ |
28 | |
29 | #ifndef KCALCORE_OCCURRENCEITERATOR_H |
30 | #define KCALCORE_OCCURRENCEITERATOR_H |
31 | |
32 | #include "kcalcore_export.h" |
33 | #include "incidence.h" |
34 | |
35 | namespace KCalCore { |
36 | |
37 | class Calendar; |
38 | /** |
39 | * Iterate over calendar items in a calendar. |
40 | * |
41 | * The iterator takes recurrences and exceptions to recurrences into account |
42 | * |
43 | * The iterator does not iterate the occurrences of all incidences chronologically. |
44 | * @since 4.11 |
45 | */ |
46 | class KCALCORE_EXPORT OccurrenceIterator |
47 | { |
48 | public: |
49 | /** |
50 | * Creates iterator that iterates over all occurrences of all incidences |
51 | * between @param start and @param end (inclusive) |
52 | */ |
53 | explicit OccurrenceIterator(const Calendar &calendar, |
54 | const KDateTime &start = KDateTime(), |
55 | const KDateTime &end = KDateTime()); |
56 | |
57 | /** |
58 | * Creates iterator that iterates over all occurrences |
59 | * of @param incidence between @param start and @param end (inclusive) |
60 | */ |
61 | OccurrenceIterator(const Calendar &calendar, |
62 | const KCalCore::Incidence::Ptr &incidence, |
63 | const KDateTime &start = KDateTime(), |
64 | const KDateTime &end = KDateTime()); |
65 | ~OccurrenceIterator(); |
66 | bool hasNext() const; |
67 | |
68 | /** |
69 | * Advance iterator to the next occurrence. |
70 | */ |
71 | void next(); |
72 | |
73 | /** |
74 | * Returns either main incidence or exception, depending on occurrence. |
75 | */ |
76 | Incidence::Ptr incidence() const; |
77 | |
78 | /** |
79 | * Returns the start date of the occurrence |
80 | * |
81 | * This is either the occurrence date, or the start date of an exception |
82 | * which overrides that occurrence. |
83 | */ |
84 | KDateTime occurrenceStartDate() const; |
85 | |
86 | private: |
87 | Q_DISABLE_COPY(OccurrenceIterator) |
88 | //@cond PRIVATE |
89 | class Private; |
90 | QScopedPointer<Private> d; |
91 | //@endcond |
92 | }; |
93 | |
94 | } //namespace |
95 | |
96 | #endif |
97 | |
98 | |