summaryrefslogtreecommitdiffabout
path: root/libkcal/recurrence.h
Unidiff
Diffstat (limited to 'libkcal/recurrence.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/recurrence.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/libkcal/recurrence.h b/libkcal/recurrence.h
index b13d14f..5b5aab1 100644
--- a/libkcal/recurrence.h
+++ b/libkcal/recurrence.h
@@ -1,401 +1,403 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (c) 2002 David Jarvie <software@astrojar.org.uk> 5 Copyright (c) 2002 David Jarvie <software@astrojar.org.uk>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_RECURRENCE_H 22#ifndef KCAL_RECURRENCE_H
23#define KCAL_RECURRENCE_H 23#define KCAL_RECURRENCE_H
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qbitarray.h> 26#include <qbitarray.h>
27#include <qptrlist.h> 27#include <q3ptrlist.h>
28//Added by qt3to4:
29#include <Q3ValueList>
28 30
29namespace KCal { 31namespace KCal {
30 32
31class Incidence; 33class Incidence;
32 34
33/** 35/**
34 This class represents a recurrence rule for a calendar incidence. 36 This class represents a recurrence rule for a calendar incidence.
35*/ 37*/
36class Recurrence 38class Recurrence
37{ 39{
38 public: 40 public:
39 /** enumeration for describing how an event recurs, if at all. */ 41 /** enumeration for describing how an event recurs, if at all. */
40 enum { rNone = 0, rMinutely = 0x001, rHourly = 0x0002, rDaily = 0x0003, 42 enum { rNone = 0, rMinutely = 0x001, rHourly = 0x0002, rDaily = 0x0003,
41 rWeekly = 0x0004, rMonthlyPos = 0x0005, rMonthlyDay = 0x0006, 43 rWeekly = 0x0004, rMonthlyPos = 0x0005, rMonthlyDay = 0x0006,
42 rYearlyMonth = 0x0007, rYearlyDay = 0x0008, rYearlyPos = 0x0009 }; 44 rYearlyMonth = 0x0007, rYearlyDay = 0x0008, rYearlyPos = 0x0009 };
43 45
44 /** Enumeration for specifying what date yearly recurrences of February 29th occur 46 /** Enumeration for specifying what date yearly recurrences of February 29th occur
45 * in non-leap years. */ 47 * in non-leap years. */
46 enum Feb29Type { 48 enum Feb29Type {
47 rMar1, // recur on March 1st (default) 49 rMar1, // recur on March 1st (default)
48 rFeb28, // recur on February 28th 50 rFeb28, // recur on February 28th
49 rFeb29 // only recur on February 29th, i.e. don't recur in non-leap years 51 rFeb29 // only recur on February 29th, i.e. don't recur in non-leap years
50 }; 52 };
51 53
52 /** structure for Recurs rMonthlyPos */ 54 /** structure for Recurs rMonthlyPos */
53 struct rMonthPos { 55 struct rMonthPos {
54 QBitArray rDays; 56 QBitArray rDays;
55 short rPos; 57 short rPos;
56 bool negative; 58 bool negative;
57 }; 59 };
58 60
59 Recurrence(Incidence *parent, int compatVersion = 0); 61 Recurrence(Incidence *parent, int compatVersion = 0);
60 Recurrence(const Recurrence&, Incidence *parent); 62 Recurrence(const Recurrence&, Incidence *parent);
61 ~Recurrence(); 63 ~Recurrence();
62 64
63 bool operator==( const Recurrence& ) const; 65 bool operator==( const Recurrence& ) const;
64 bool operator!=( const Recurrence& r ) const { return !operator==(r); } 66 bool operator!=( const Recurrence& r ) const { return !operator==(r); }
65 67
66 Incidence *parent() { return mParent; } 68 Incidence *parent() { return mParent; }
67 69
68 /** Return the start of the recurrence */ 70 /** Return the start of the recurrence */
69 QDateTime recurStart() const { return mRecurStart; } 71 QDateTime recurStart() const { return mRecurStart; }
70 /** Returns the number of exception dates for the recurrence */ 72 /** Returns the number of exception dates for the recurrence */
71 int recurExDatesCount() const { return mRecurExDatesCount; } 73 int recurExDatesCount() const { return mRecurExDatesCount; }
72 /** Set start of recurrence, as a date and time. */ 74 /** Set start of recurrence, as a date and time. */
73 void setRecurStart(const QDateTime &start); 75 void setRecurStart(const QDateTime &start);
74 /** Set start of recurrence, as a date with no time. 76 /** Set start of recurrence, as a date with no time.
75 * Recurrence types which are sub-daily (e.g. rHourly) always have a time; 77 * Recurrence types which are sub-daily (e.g. rHourly) always have a time;
76 * the time is set to 00:00:00 in these cases. */ 78 * the time is set to 00:00:00 in these cases. */
77 void setRecurStart(const QDate &start); 79 void setRecurStart(const QDate &start);
78 /** Set whether the recurrence has no time, just a date. 80 /** Set whether the recurrence has no time, just a date.
79 * Recurrence types which are sub-daily (e.g. rHourly) always have a time 81 * Recurrence types which are sub-daily (e.g. rHourly) always have a time
80 * and cannot be set to float. 82 * and cannot be set to float.
81 * N.B. This property is derived by default from the parent incidence, 83 * N.B. This property is derived by default from the parent incidence,
82 * or according to whether a time is specified in setRecurStart(). */ 84 * or according to whether a time is specified in setRecurStart(). */
83 void setFloats(bool f); 85 void setFloats(bool f);
84 /** 86 /**
85 Returns whether the recurrence has no time, just a date. 87 Returns whether the recurrence has no time, just a date.
86 */ 88 */
87 bool doesFloat() const { 89 bool doesFloat() const {
88 return mFloats; 90 return mFloats;
89 } 91 }
90 92
91 /** Set if recurrence is read-only or can be changed. */ 93 /** Set if recurrence is read-only or can be changed. */
92 void setRecurReadOnly(bool readOnly) { mRecurReadOnly = readOnly; } 94 void setRecurReadOnly(bool readOnly) { mRecurReadOnly = readOnly; }
93 bool recurReadOnly() const 95 bool recurReadOnly() const
94 { 96 {
95 return mRecurReadOnly; 97 return mRecurReadOnly;
96 } 98 }
97 99
98 100
99 /** Set number of exception dates. */ 101 /** Set number of exception dates. */
100 void setRecurExDatesCount(int count) { if (count >= 0) mRecurExDatesCount = count; } 102 void setRecurExDatesCount(int count) { if (count >= 0) mRecurExDatesCount = count; }
101 /** Set the calendar file version for backwards compatibility. 103 /** Set the calendar file version for backwards compatibility.
102 * @var version is the KOrganizer/libkcal version, e.g. 220 for KDE 2.2.0. 104 * @var version is the KOrganizer/libkcal version, e.g. 220 for KDE 2.2.0.
103 * Specify version = 0 to cancel compatibility mode. 105 * Specify version = 0 to cancel compatibility mode.
104 */ 106 */
105 void setCompatVersion(int version = 0); 107 void setCompatVersion(int version = 0);
106 108
107 /** Returns the event's recurrence status. See the enumeration at the top 109 /** Returns the event's recurrence status. See the enumeration at the top
108 * of this file for possible values. */ 110 * of this file for possible values. */
109 ushort doesRecur() const; 111 ushort doesRecur() const;
110 /** Returns true if the date specified is one on which the event will 112 /** Returns true if the date specified is one on which the event will
111 * recur. */ 113 * recur. */
112 bool recursOnPure(const QDate &qd) const; 114 bool recursOnPure(const QDate &qd) const;
113 /** Returns true if the date/time specified is one at which the event will 115 /** Returns true if the date/time specified is one at which the event will
114 * recur. Times are rounded down to the nearest minute to determine the result. */ 116 * recur. Times are rounded down to the nearest minute to determine the result. */
115 bool recursAtPure(const QDateTime &) const; 117 bool recursAtPure(const QDateTime &) const;
116 /** Turns off recurrence for the event. */ 118 /** Turns off recurrence for the event. */
117 void unsetRecurs(); 119 void unsetRecurs();
118 120
119 /** Returns the date of the next recurrence, after the specified date. 121 /** Returns the date of the next recurrence, after the specified date.
120 * @var preDate the date after which to find the recurrence. 122 * @var preDate the date after which to find the recurrence.
121 * @var last if non-null, *last is set to true if the next recurrence is the 123 * @var last if non-null, *last is set to true if the next recurrence is the
122 * last recurrence, else false. 124 * last recurrence, else false.
123 * Reply = date of next recurrence, or invalid date if none. 125 * Reply = date of next recurrence, or invalid date if none.
124 */ 126 */
125 QDate getNextDate(const QDate& preDate, bool* last = 0) const; 127 QDate getNextDate(const QDate& preDate, bool* last = 0) const;
126 /** Returns the date and time of the next recurrence, after the specified date/time. 128 /** Returns the date and time of the next recurrence, after the specified date/time.
127 * If the recurrence has no time, the next date after the specified date is returned. 129 * If the recurrence has no time, the next date after the specified date is returned.
128 * @var preDate the date/time after which to find the recurrence. 130 * @var preDate the date/time after which to find the recurrence.
129 * @var last if non-null, *last is set to true if the next recurrence is the 131 * @var last if non-null, *last is set to true if the next recurrence is the
130 * last recurrence, else false. 132 * last recurrence, else false.
131 * Reply = date/time of next recurrence, or invalid date if none. 133 * Reply = date/time of next recurrence, or invalid date if none.
132 */ 134 */
133 QDateTime getNextDateTime(const QDateTime& preDateTime, bool* last = 0) const; 135 QDateTime getNextDateTime(const QDateTime& preDateTime, bool* last = 0) const;
134 /** Returns the date of the last previous recurrence, before the specified date. 136 /** Returns the date of the last previous recurrence, before the specified date.
135 * @var afterDate the date before which to find the recurrence. 137 * @var afterDate the date before which to find the recurrence.
136 * @var last if non-null, *last is set to true if the previous recurrence is the 138 * @var last if non-null, *last is set to true if the previous recurrence is the
137 * last recurrence, else false. 139 * last recurrence, else false.
138 * Reply = date of previous recurrence, or invalid date if none. 140 * Reply = date of previous recurrence, or invalid date if none.
139 */ 141 */
140 QDate getPreviousDate(const QDate& afterDate, bool* last = 0) const; 142 QDate getPreviousDate(const QDate& afterDate, bool* last = 0) const;
141 /** Returns the date and time of the last previous recurrence, before the specified date/time. 143 /** Returns the date and time of the last previous recurrence, before the specified date/time.
142 * If a time later than 00:00:00 is specified and the recurrence has no time, 00:00:00 on 144 * If a time later than 00:00:00 is specified and the recurrence has no time, 00:00:00 on
143 * the specified date is returned if that date recurs. 145 * the specified date is returned if that date recurs.
144 * @var afterDate the date/time before which to find the recurrence. 146 * @var afterDate the date/time before which to find the recurrence.
145 * @var last if non-null, *last is set to true if the previous recurrence is the 147 * @var last if non-null, *last is set to true if the previous recurrence is the
146 * last recurrence, else false. 148 * last recurrence, else false.
147 * Reply = date/time of previous recurrence, or invalid date if none. 149 * Reply = date/time of previous recurrence, or invalid date if none.
148 */ 150 */
149 QDateTime getPreviousDateTime(const QDateTime& afterDateTime, bool* last = 0) const; 151 QDateTime getPreviousDateTime(const QDateTime& afterDateTime, bool* last = 0) const;
150 152
151 /** Returns frequency of recurrence, in terms of the recurrence time period type. */ 153 /** Returns frequency of recurrence, in terms of the recurrence time period type. */
152 int frequency() const; 154 int frequency() const;
153 /** Returns the total number of recurrences, including the initial occurrence. */ 155 /** Returns the total number of recurrences, including the initial occurrence. */
154 int duration() const; 156 int duration() const;
155 /** Sets the total number of times the event is to occur, including both the 157 /** Sets the total number of times the event is to occur, including both the
156 * first and last. */ 158 * first and last. */
157 void setDuration(int duration); 159 void setDuration(int duration);
158 /** Returns the number of recurrences up to and including the date specified. */ 160 /** Returns the number of recurrences up to and including the date specified. */
159 int durationTo(const QDate &) const; 161 int durationTo(const QDate &) const;
160 /** Returns the number of recurrences up to and including the date/time specified. */ 162 /** Returns the number of recurrences up to and including the date/time specified. */
161 int durationTo(const QDateTime &) const; 163 int durationTo(const QDateTime &) const;
162 164
163 /** Returns the date of the last recurrence. 165 /** Returns the date of the last recurrence.
164 * An invalid date is returned if the recurrence has no end. 166 * An invalid date is returned if the recurrence has no end.
165 * Note: for some recurrence types, endDate() can involve significant calculation. 167 * Note: for some recurrence types, endDate() can involve significant calculation.
166 */ 168 */
167 QDate endDate() const; 169 QDate endDate() const;
168 /** Returns the date and time of the last recurrence. 170 /** Returns the date and time of the last recurrence.
169 * An invalid date is returned if the recurrence has no end. 171 * An invalid date is returned if the recurrence has no end.
170 * Note: for some recurrence types, endDateTime() can involve significant calculation. 172 * Note: for some recurrence types, endDateTime() can involve significant calculation.
171 */ 173 */
172 QDateTime endDateTime() const; 174 QDateTime endDateTime() const;
173 /** Returns a string representing the recurrence end date in the format 175 /** Returns a string representing the recurrence end date in the format
174 according to the user's locale settings. */ 176 according to the user's locale settings. */
175 QString endDateStr(bool shortfmt=true) const; 177 QString endDateStr(bool shortfmt=true) const;
176 178
177 /** Sets an event to recur minutely. 179 /** Sets an event to recur minutely.
178 * @var _rFreq the frequency to recur, e.g. 2 is every other minute 180 * @var _rFreq the frequency to recur, e.g. 2 is every other minute
179 * @var duration the number of times the event is to occur, or -1 to recur indefinitely. 181 * @var duration the number of times the event is to occur, or -1 to recur indefinitely.
180 */ 182 */
181 void setMinutely(int _rFreq, int duration); 183 void setMinutely(int _rFreq, int duration);
182 /** Sets an event to recur minutely. 184 /** Sets an event to recur minutely.
183 * @var _rFreq the frequency to recur, e.g. 2 is every other minute 185 * @var _rFreq the frequency to recur, e.g. 2 is every other minute
184 * @var endDateTime the ending date/time after which to stop recurring 186 * @var endDateTime the ending date/time after which to stop recurring
185 */ 187 */
186 void setMinutely(int _rFreq, const QDateTime &endDateTime); 188 void setMinutely(int _rFreq, const QDateTime &endDateTime);
187 189
188 /** Sets an event to recur hourly. 190 /** Sets an event to recur hourly.
189 * @var _rFreq the frequency to recur, e.g. 2 is every other hour 191 * @var _rFreq the frequency to recur, e.g. 2 is every other hour
190 * @var duration the number of times the event is to occur, or -1 to recur indefinitely. 192 * @var duration the number of times the event is to occur, or -1 to recur indefinitely.
191 */ 193 */
192 void setHourly(int _rFreq, int duration); 194 void setHourly(int _rFreq, int duration);
193 /** Sets an event to recur hourly. 195 /** Sets an event to recur hourly.
194 * @var _rFreq the frequency to recur, e.g. 2 is every other hour 196 * @var _rFreq the frequency to recur, e.g. 2 is every other hour
195 * @var endDateTime the ending date/time after which to stop recurring 197 * @var endDateTime the ending date/time after which to stop recurring
196 */ 198 */
197 void setHourly(int _rFreq, const QDateTime &endDateTime); 199 void setHourly(int _rFreq, const QDateTime &endDateTime);
198 200
199 /** Sets an event to recur daily. 201 /** Sets an event to recur daily.
200 * @var _rFreq the frequency to recur, e.g. 2 is every other day 202 * @var _rFreq the frequency to recur, e.g. 2 is every other day
201 * @var duration the number of times the event is to occur, or -1 to recur indefinitely. 203 * @var duration the number of times the event is to occur, or -1 to recur indefinitely.
202 */ 204 */
203 void setDaily(int _rFreq, int duration); 205 void setDaily(int _rFreq, int duration);
204 /** Sets an event to recur daily. 206 /** Sets an event to recur daily.
205 * @var _rFreq the frequency to recur, e.g. 2 is every other day 207 * @var _rFreq the frequency to recur, e.g. 2 is every other day
206 * @var endDate the ending date after which to stop recurring 208 * @var endDate the ending date after which to stop recurring
207 */ 209 */
208 void setDaily(int _rFreq, const QDate &endDate); 210 void setDaily(int _rFreq, const QDate &endDate);
209 211
210 /** Sets an event to recur weekly. 212 /** Sets an event to recur weekly.
211 * @var _rFreq the frequency to recur, e.g. every other week etc. 213 * @var _rFreq the frequency to recur, e.g. every other week etc.
212 * @var _rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday). 214 * @var _rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday).
213 * @var duration the number of times the event is to occur, or -1 to recur indefinitely. 215 * @var duration the number of times the event is to occur, or -1 to recur indefinitely.
214 * @var weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday). 216 * @var weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday).
215 */ 217 */
216 void setWeekly(int _rFreq, const QBitArray &_rDays, int duration, int weekStart = 1); 218 void setWeekly(int _rFreq, const QBitArray &_rDays, int duration, int weekStart = 1);
217 /** Sets an event to recur weekly. 219 /** Sets an event to recur weekly.
218 * @var _rFreq the frequency to recur, e.g. every other week etc. 220 * @var _rFreq the frequency to recur, e.g. every other week etc.
219 * @var _rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday). 221 * @var _rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday).
220 * @var endDate the date on which to stop recurring. 222 * @var endDate the date on which to stop recurring.
221 * @var weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday). 223 * @var weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday).
222 */ 224 */
223 void setWeekly(int _rFreq, const QBitArray &_rDays, const QDate &endDate, int weekStart = 1); 225 void setWeekly(int _rFreq, const QBitArray &_rDays, const QDate &endDate, int weekStart = 1);
224 /** Returns the first day of the week. Monday=1 .. Sunday=7. */ 226 /** Returns the first day of the week. Monday=1 .. Sunday=7. */
225 int weekStart() const { return rWeekStart; } 227 int weekStart() const { return rWeekStart; }
226 /** Returns week day mask (bit 0 = Monday). */ 228 /** Returns week day mask (bit 0 = Monday). */
227 const QBitArray &days() const; 229 const QBitArray &days() const;
228 230
229 /** Sets an event to recur monthly. 231 /** Sets an event to recur monthly.
230 * @var type rMonthlyPos or rMonthlyDay 232 * @var type rMonthlyPos or rMonthlyDay
231 * @var _rFreq the frequency to recur, e.g. 3 for every third month. 233 * @var _rFreq the frequency to recur, e.g. 3 for every third month.
232 * @var duration the number of times the event is to occur, or -1 to recur indefinitely. 234 * @var duration the number of times the event is to occur, or -1 to recur indefinitely.
233 */ 235 */
234 void setMonthly(short type, int _rFreq, int duration); 236 void setMonthly(short type, int _rFreq, int duration);
235 /** same as above, but with ending date not number of recurrences */ 237 /** same as above, but with ending date not number of recurrences */
236 void setMonthly(short type, int _rFreq, const QDate &endDate); 238 void setMonthly(short type, int _rFreq, const QDate &endDate);
237 /** Adds a position to the recursMonthlyPos recurrence rule, if it is 239 /** Adds a position to the recursMonthlyPos recurrence rule, if it is
238 * set. 240 * set.
239 * @var _rPos the position in the month for the recurrence, with valid 241 * @var _rPos the position in the month for the recurrence, with valid
240 * values being 1-5 (5 weeks max in a month). 242 * values being 1-5 (5 weeks max in a month).
241 * @var _rDays the days for the position to recur on (bit 0 = Monday). 243 * @var _rDays the days for the position to recur on (bit 0 = Monday).
242 * Example: _rPos = 2, and bits 0 and 2 are set in _rDays: 244 * Example: _rPos = 2, and bits 0 and 2 are set in _rDays:
243 * the rule is to repeat every 2nd Monday and Wednesday in the month. 245 * the rule is to repeat every 2nd Monday and Wednesday in the month.
244 */ 246 */
245 void addMonthlyPos(short _rPos, const QBitArray &_rDays); 247 void addMonthlyPos(short _rPos, const QBitArray &_rDays);
246 /** Adds a position the the recursMonthlyDay list. 248 /** Adds a position the the recursMonthlyDay list.
247 * @var _rDay the date in the month to recur. 249 * @var _rDay the date in the month to recur.
248 */ 250 */
249 void addMonthlyDay(short _rDay); 251 void addMonthlyDay(short _rDay);
250 /** Returns list of day positions in months. */ 252 /** Returns list of day positions in months. */
251 const QPtrList<rMonthPos> &monthPositions() const; 253 const Q3PtrList<rMonthPos> &monthPositions() const;
252 /** Returns list of day numbers of a month. */ 254 /** Returns list of day numbers of a month. */
253 const QPtrList<int> &monthDays() const; 255 const Q3PtrList<int> &monthDays() const;
254 256
255 /** Sets an event to recur yearly. 257 /** Sets an event to recur yearly.
256 * @var type rYearlyMonth, rYearlyPos or rYearlyDay 258 * @var type rYearlyMonth, rYearlyPos or rYearlyDay
257 * @var freq the frequency to recur, e.g. 3 for every third year. 259 * @var freq the frequency to recur, e.g. 3 for every third year.
258 * @var duration the number of times the event is to occur, or -1 to recur indefinitely. 260 * @var duration the number of times the event is to occur, or -1 to recur indefinitely.
259 */ 261 */
260 void setYearly(int type, int freq, int duration); 262 void setYearly(int type, int freq, int duration);
261 /** Sets an event to recur yearly ending at \a endDate. */ 263 /** Sets an event to recur yearly ending at \a endDate. */
262 void setYearly(int type, int freq, const QDate &endDate); 264 void setYearly(int type, int freq, const QDate &endDate);
263 /** Sets an event to recur yearly on specified dates. 265 /** Sets an event to recur yearly on specified dates.
264 * The dates must be specified by calling addYearlyNum(). 266 * The dates must be specified by calling addYearlyNum().
265 * @var type the way recurrences of February 29th are to be handled in non-leap years. 267 * @var type the way recurrences of February 29th are to be handled in non-leap years.
266 * @var freq the frequency to recur, e.g. 3 for every third year. 268 * @var freq the frequency to recur, e.g. 3 for every third year.
267 * @var duration the number of times the event is to occur, or -1 to recur indefinitely. 269 * @var duration the number of times the event is to occur, or -1 to recur indefinitely.
268 */ 270 */
269 void setYearlyByDate(Feb29Type type, int freq, int duration); 271 void setYearlyByDate(Feb29Type type, int freq, int duration);
270 /** Sets an event to recur yearly ending at \a endDate. */ 272 /** Sets an event to recur yearly ending at \a endDate. */
271 void setYearlyByDate(Feb29Type type, int freq, const QDate &endDate); 273 void setYearlyByDate(Feb29Type type, int freq, const QDate &endDate);
272 /** Adds position of day or month in year. 274 /** Adds position of day or month in year.
273 * N.B. for recursYearlyPos, addYearlyMonthPos() must also be called 275 * N.B. for recursYearlyPos, addYearlyMonthPos() must also be called
274 * to add positions within the month. */ 276 * to add positions within the month. */
275 void addYearlyNum(short _rNum); 277 void addYearlyNum(short _rNum);
276 /** Adds a position to the recursYearlyPos recurrence rule, if it is set. 278 /** Adds a position to the recursYearlyPos recurrence rule, if it is set.
277 * N.B. addYearlyNum() must also be called to add recurrence months. 279 * N.B. addYearlyNum() must also be called to add recurrence months.
278 * Parameters are the same as for addMonthlyPos(). 280 * Parameters are the same as for addMonthlyPos().
279 */ 281 */
280 void addYearlyMonthPos(short _rPos, const QBitArray &_rDays); 282 void addYearlyMonthPos(short _rPos, const QBitArray &_rDays);
281 /** Returns positions of days or months in year. */ 283 /** Returns positions of days or months in year. */
282 const QPtrList<int> &yearNums() const; 284 const Q3PtrList<int> &yearNums() const;
283 /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */ 285 /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */
284 const QPtrList<rMonthPos> &yearMonthPositions() const; 286 const Q3PtrList<rMonthPos> &yearMonthPositions() const;
285 /** Returns how yearly recurrences of February 29th are handled. */ 287 /** Returns how yearly recurrences of February 29th are handled. */
286 Feb29Type feb29YearlyType() const { return mFeb29YearlyType; } 288 Feb29Type feb29YearlyType() const { return mFeb29YearlyType; }
287 /** Sets the default method for handling yearly recurrences of February 29th. */ 289 /** Sets the default method for handling yearly recurrences of February 29th. */
288 static void setFeb29YearlyTypeDefault(Feb29Type t) { mFeb29YearlyDefaultType = t; } 290 static void setFeb29YearlyTypeDefault(Feb29Type t) { mFeb29YearlyDefaultType = t; }
289 /** Returns the default method for handling yearly recurrences of February 29th. */ 291 /** Returns the default method for handling yearly recurrences of February 29th. */
290 static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; } 292 static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; }
291 void addYearlyMonth(short _rPos ); // added LR 293 void addYearlyMonth(short _rPos ); // added LR
292 /** 294 /**
293 Debug output. 295 Debug output.
294 */ 296 */
295 void dump() const; 297 void dump() const;
296 QString recurrenceText() const; 298 QString recurrenceText() const;
297 bool getYearlyMonthMonths(int day, QValueList<int>&, 299 bool getYearlyMonthMonths(int day, Q3ValueList<int>&,
298 QValueList<int> &leaplist) const; 300 Q3ValueList<int> &leaplist) const;
299 301
300 protected: 302 protected:
301 enum PeriodFunc { END_DATE_AND_COUNT, COUNT_TO_DATE, NEXT_AFTER_DATE }; 303 enum PeriodFunc { END_DATE_AND_COUNT, COUNT_TO_DATE, NEXT_AFTER_DATE };
302 struct MonthlyData; friend struct MonthlyData; 304 struct MonthlyData; friend struct MonthlyData;
303 struct YearlyMonthData; friend struct YearlyMonthData; 305 struct YearlyMonthData; friend struct YearlyMonthData;
304 struct YearlyPosData; friend struct YearlyPosData; 306 struct YearlyPosData; friend struct YearlyPosData;
305 struct YearlyDayData; friend struct YearlyDayData; 307 struct YearlyDayData; friend struct YearlyDayData;
306 308
307 bool recursSecondly(const QDate &, int secondFreq) const; 309 bool recursSecondly(const QDate &, int secondFreq) const;
308 bool recursMinutelyAt(const QDateTime &dt, int minuteFreq) const; 310 bool recursMinutelyAt(const QDateTime &dt, int minuteFreq) const;
309 bool recursDaily(const QDate &) const; 311 bool recursDaily(const QDate &) const;
310 bool recursWeekly(const QDate &) const; 312 bool recursWeekly(const QDate &) const;
311 bool recursMonthly(const QDate &) const; 313 bool recursMonthly(const QDate &) const;
312 bool recursYearlyByMonth(const QDate &) const; 314 bool recursYearlyByMonth(const QDate &) const;
313 bool recursYearlyByPos(const QDate &) const; 315 bool recursYearlyByPos(const QDate &) const;
314 bool recursYearlyByDay(const QDate &) const; 316 bool recursYearlyByDay(const QDate &) const;
315 317
316 QDate getNextDateNoTime(const QDate& preDate, bool* last) const; 318 QDate getNextDateNoTime(const QDate& preDate, bool* last) const;
317 QDate getPreviousDateNoTime(const QDate& afterDate, bool* last) const; 319 QDate getPreviousDateNoTime(const QDate& afterDate, bool* last) const;
318 320
319 void addMonthlyPos_(short _rPos, const QBitArray &_rDays); 321 void addMonthlyPos_(short _rPos, const QBitArray &_rDays);
320 void setDailySub(short type, int freq, int duration); 322 void setDailySub(short type, int freq, int duration);
321 void setYearly_(short type, Feb29Type, int freq, int duration); 323 void setYearly_(short type, Feb29Type, int freq, int duration);
322 int recurCalc(PeriodFunc, QDate &enddate) const; 324 int recurCalc(PeriodFunc, QDate &enddate) const;
323 int recurCalc(PeriodFunc, QDateTime &endtime) const; 325 int recurCalc(PeriodFunc, QDateTime &endtime) const;
324 int secondlyCalc(PeriodFunc, QDateTime& endtime, int freq) const; 326 int secondlyCalc(PeriodFunc, QDateTime& endtime, int freq) const;
325 int dailyCalc(PeriodFunc, QDate &enddate) const; 327 int dailyCalc(PeriodFunc, QDate &enddate) const;
326 int weeklyCalc(PeriodFunc, QDate &enddate) const; 328 int weeklyCalc(PeriodFunc, QDate &enddate) const;
327 int weeklyCalcEndDate(QDate& enddate, int daysPerWeek) const; 329 int weeklyCalcEndDate(QDate& enddate, int daysPerWeek) const;
328 int weeklyCalcToDate(const QDate& enddate, int daysPerWeek) const; 330 int weeklyCalcToDate(const QDate& enddate, int daysPerWeek) const;
329 int weeklyCalcNextAfter(QDate& enddate, int daysPerWeek) const; 331 int weeklyCalcNextAfter(QDate& enddate, int daysPerWeek) const;
330 int monthlyCalc(PeriodFunc, QDate &enddate) const; 332 int monthlyCalc(PeriodFunc, QDate &enddate) const;
331 int monthlyCalcEndDate(QDate& enddate, MonthlyData&) const; 333 int monthlyCalcEndDate(QDate& enddate, MonthlyData&) const;
332 int monthlyCalcToDate(const QDate& enddate, MonthlyData&) const; 334 int monthlyCalcToDate(const QDate& enddate, MonthlyData&) const;
333 int monthlyCalcNextAfter(QDate& enddate, MonthlyData&) const; 335 int monthlyCalcNextAfter(QDate& enddate, MonthlyData&) const;
334 int yearlyMonthCalc(PeriodFunc, QDate &enddate) const; 336 int yearlyMonthCalc(PeriodFunc, QDate &enddate) const;
335 int yearlyMonthCalcEndDate(QDate& enddate, YearlyMonthData&) const; 337 int yearlyMonthCalcEndDate(QDate& enddate, YearlyMonthData&) const;
336 int yearlyMonthCalcToDate(const QDate& enddate, YearlyMonthData&) const; 338 int yearlyMonthCalcToDate(const QDate& enddate, YearlyMonthData&) const;
337 int yearlyMonthCalcNextAfter(QDate& enddate, YearlyMonthData&) const; 339 int yearlyMonthCalcNextAfter(QDate& enddate, YearlyMonthData&) const;
338 int yearlyPosCalc(PeriodFunc, QDate &enddate) const; 340 int yearlyPosCalc(PeriodFunc, QDate &enddate) const;
339 int yearlyPosCalcEndDate(QDate& enddate, YearlyPosData&) const; 341 int yearlyPosCalcEndDate(QDate& enddate, YearlyPosData&) const;
340 int yearlyPosCalcToDate(const QDate& enddate, YearlyPosData&) const; 342 int yearlyPosCalcToDate(const QDate& enddate, YearlyPosData&) const;
341 int yearlyPosCalcNextAfter(QDate& enddate, YearlyPosData&) const; 343 int yearlyPosCalcNextAfter(QDate& enddate, YearlyPosData&) const;
342 int yearlyDayCalc(PeriodFunc, QDate &enddate) const; 344 int yearlyDayCalc(PeriodFunc, QDate &enddate) const;
343 int yearlyDayCalcEndDate(QDate& enddate, YearlyDayData&) const; 345 int yearlyDayCalcEndDate(QDate& enddate, YearlyDayData&) const;
344 int yearlyDayCalcToDate(const QDate& enddate, YearlyDayData&) const; 346 int yearlyDayCalcToDate(const QDate& enddate, YearlyDayData&) const;
345 int yearlyDayCalcNextAfter(QDate& enddate, YearlyDayData&) const; 347 int yearlyDayCalcNextAfter(QDate& enddate, YearlyDayData&) const;
346 348
347 int countMonthlyPosDays() const; 349 int countMonthlyPosDays() const;
348 void getMonthlyPosDays(QValueList<int>&, int daysInMonth, 350 void getMonthlyPosDays(Q3ValueList<int>&, int daysInMonth,
349 int startDayOfWeek) const; 351 int startDayOfWeek) const;
350 bool getMonthlyDayDays(QValueList<int>&, int daysInMonth) const; 352 bool getMonthlyDayDays(Q3ValueList<int>&, int daysInMonth) const;
351 353
352 int getFirstDayInWeek(int startDay, bool useWeekStart = true) const; 354 int getFirstDayInWeek(int startDay, bool useWeekStart = true) const;
353 int getLastDayInWeek(int endDay, bool useWeekStart = true) const; 355 int getLastDayInWeek(int endDay, bool useWeekStart = true) const;
354 QDate getFirstDateInMonth(const QDate& earliestDate) const; 356 QDate getFirstDateInMonth(const QDate& earliestDate) const;
355 QDate getLastDateInMonth(const QDate& latestDate) const; 357 QDate getLastDateInMonth(const QDate& latestDate) const;
356 QDate getFirstDateInYear(const QDate& earliestDate) const; 358 QDate getFirstDateInYear(const QDate& earliestDate) const;
357 QDate getLastDateInYear(const QDate& latestDate) const; 359 QDate getLastDateInYear(const QDate& latestDate) const;
358 360
359 private: 361 private:
360 // Prohibit copying 362 // Prohibit copying
361 Recurrence(const Recurrence&); 363 Recurrence(const Recurrence&);
362 Recurrence &operator=(const Recurrence&); 364 Recurrence &operator=(const Recurrence&);
363 365
364 short recurs; // should be one of the enums. 366 short recurs; // should be one of the enums.
365 367
366 int rWeekStart; // day which starts the week, Monday=1 .. Sunday=7 368 int rWeekStart; // day which starts the week, Monday=1 .. Sunday=7
367 QBitArray rDays; // array of days during week it recurs 369 QBitArray rDays; // array of days during week it recurs
368 370
369 QPtrList<rMonthPos> rMonthPositions; // list of positions during a month 371 Q3PtrList<rMonthPos> rMonthPositions; // list of positions during a month
370 // on which an event recurs 372 // on which an event recurs
371 373
372 QPtrList<int> rMonthDays; // list of days during a month on 374 Q3PtrList<int> rMonthDays; // list of days during a month on
373 // which the event recurs 375 // which the event recurs
374 376
375 QPtrList<int> rYearNums; // either months/days to recur on for rYearly, 377 Q3PtrList<int> rYearNums; // either months/days to recur on for rYearly,
376 // sorted in numerical order 378 // sorted in numerical order
377 379
378 int rFreq; // frequency of period 380 int rFreq; // frequency of period
379 381
380 // one of the following must be specified 382 // one of the following must be specified
381 int rDuration; // num times to recur (inc. first occurrence), -1 = infinite 383 int rDuration; // num times to recur (inc. first occurrence), -1 = infinite
382 QDateTime rEndDateTime; // date/time at which to end recurrence 384 QDateTime rEndDateTime; // date/time at which to end recurrence
383 385
384 QDateTime mRecurStart; // date/time of first recurrence 386 QDateTime mRecurStart; // date/time of first recurrence
385 bool mFloats; // the recurrence has no time, just a date 387 bool mFloats; // the recurrence has no time, just a date
386 bool mRecurReadOnly; 388 bool mRecurReadOnly;
387 int mRecurExDatesCount; // number of recurrences (in addition to rDuration) which are excluded 389 int mRecurExDatesCount; // number of recurrences (in addition to rDuration) which are excluded
388 Feb29Type mFeb29YearlyType; // how to handle yearly recurrences of February 29th 390 Feb29Type mFeb29YearlyType; // how to handle yearly recurrences of February 29th
389 static Feb29Type mFeb29YearlyDefaultType; // default value for mFeb29YearlyType 391 static Feb29Type mFeb29YearlyDefaultType; // default value for mFeb29YearlyType
390 392
391 // Backwards compatibility for KDE < 3.1. 393 // Backwards compatibility for KDE < 3.1.
392 int mCompatVersion; // calendar file version for backwards compatibility 394 int mCompatVersion; // calendar file version for backwards compatibility
393 short mCompatRecurs; // original 'recurs' in old calendar format, or rNone 395 short mCompatRecurs; // original 'recurs' in old calendar format, or rNone
394 int mCompatDuration; // original 'rDuration' in old calendar format, or 0 396 int mCompatDuration; // original 'rDuration' in old calendar format, or 0
395 397
396 Incidence *mParent; 398 Incidence *mParent;
397}; 399};
398 400
399} 401}
400 402
401#endif 403#endif