KCalendarCore

recurrence.h
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 1998 Preston Brown <[email protected]>
5  SPDX-FileCopyrightText: 2001, 2003 Cornelius Schumacher <[email protected]>
6  SPDX-FileCopyrightText: 2002, 2006 David Jarvie <[email protected]>
7  SPDX-FileCopyrightText: 2005 Reinhold Kainhofer <[email protected]>
8 
9  SPDX-License-Identifier: LGPL-2.0-or-later
10 */
11 #ifndef KCALCORE_RECURRENCE_H
12 #define KCALCORE_RECURRENCE_H
13 
14 #include "kcalendarcore_export.h"
15 #include "recurrencerule.h"
16 #include "period.h"
17 
18 class QBitArray;
19 class QTimeZone;
20 
21 namespace KCalendarCore
22 {
23 class RecurrenceRule;
24 
25 /**
26  This class represents a recurrence rule for a calendar incidence.
27 
28  It manages all recurrence rules, recurrence date/times, exception rules
29  and exception date times that can appear inside calendar items.
30  Each recurrence rule and exception rule is represented as an object
31  of type RecurrenceRule.
32 
33  For the simple case where at most one recurrence
34  rule is present, this class provides shortcut methods to set the type:
35  setMinutely()
36  setHourly()
37  setDaily()
38  setWeekly()
39  setMonthly()
40  setYearly()
41  to set/get general information about the recurrence:
42  setEndDate()
43  setEndDateTime()
44  duration()
45  durationTo()
46  setDuration()
47  frequency()
48  setFrequency()
49  and to set/get specific information about the recurrence within the interval:
50  days()
51  monthDays()
52  monthPositions()
53  yearDays()
54  yearDates()
55  yearMonths()
56  yearPositions()
57  addMonthlyPos()
58  addMonthlyDate()
59  addYearlyDay()
60  addYearlyDate()
61  addYearlyPos()
62  addYearlyMonth()
63  These are all available so that you don't have to work on the RecurrenceRule
64  objects themselves.
65  In other words, in that simple situation the interface stays almost the
66  same compared to the old Recurrence class, which allowed only one
67  recurrence rule.
68 
69  As soon as your recurrence consists of multiple recurrence rules or exception
70  rules, you cannot use the methods mentioned above any more (since each rule
71  will have a different type and different settings). If you still call
72  any of them, the set*ly methods will remove all rules and add one rule with
73  the specified type. The add* and the other set* methods will change only
74  the first recurrence rule, but leave the others untouched.
75 */
76 class KCALENDARCORE_EXPORT Recurrence : public RecurrenceRule::RuleObserver
77 {
78 public:
79  class RecurrenceObserver
80  {
81  public:
82  virtual ~RecurrenceObserver();
83  /** This method will be called on each change of the recurrence object */
84  virtual void recurrenceUpdated(Recurrence *r) = 0;
85  };
86 
87  /** enumeration for describing how an event recurs, if at all. */
88  enum {
89  rNone = 0,
90  rMinutely = 0x001,
91  rHourly = 0x0002,
92  rDaily = 0x0003,
93  rWeekly = 0x0004,
94  rMonthlyPos = 0x0005,
95  rMonthlyDay = 0x0006,
96  rYearlyMonth = 0x0007,
97  rYearlyDay = 0x0008,
98  rYearlyPos = 0x0009,
99  rOther = 0x000A,
100  rMax = 0x00FF,
101  };
102 
103  /**
104  Constructs an empty recurrence.
105  */
106  Recurrence();
107 
108  /**
109  Copy constructor.
110  @param r instance to copy from
111  */
112  Recurrence(const Recurrence &r);
113 
114  /**
115  Destructor.
116  */
117  ~Recurrence() override;
118 
119  /**
120  Comparison operator for equality.
121  @param r instance to compare with
122  @return true if recurrences are the same, false otherwise
123  */
124  bool operator==(const Recurrence &r) const;
125 
126  /**
127  Comparison operator for inequality.
128  @param r instance to compare with
129  @return true if recurrences are the different, false if the same
130  */
131  bool operator!=(const Recurrence &r) const
132  {
133  return !operator==(r);
134  }
135 
136 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 64)
137  /**
138  Assignment operator.
139  @param r the recurrence which will be assigned to this.
140  @deprecated Do not use, will be removed in KF6
141  @warning Broken implementation, do not use!
142  */
143  KCALENDARCORE_DEPRECATED_VERSION(5, 64, "Do not use")
144  Recurrence &operator=(const Recurrence &r);
145 #else
146  Recurrence &operator=(const Recurrence &r) = delete;
147 #endif
148 
149  /** Return the start date/time of the recurrence (Time for all-day recurrences will be 0:00).
150  @return the current start/time of the recurrence. */
151  Q_REQUIRED_RESULT QDateTime startDateTime() const;
152  /** Return the start date/time of the recurrence */
153  Q_REQUIRED_RESULT QDate startDate() const;
154  /** Set start of recurrence.
155  @param start the new start date or date/time of the recurrence.
156  @param isAllDay if true, the recurrence is set to all-day. Otherwise the recurrence is set
157  to non-all-day.
158  */
159  void setStartDateTime(const QDateTime &start, bool isAllDay);
160 
161  /** Set whether the recurrence has no time, just a date.
162  * All-day means -- according to rfc2445 -- that the event has no time
163  * associated.
164  * N.B. This property is derived by default from whether setStartDateTime() is
165  * called with a date-only or date/time parameter.
166  * @return whether the recurrence has a time (false) or it is just a date (true). */
167  Q_REQUIRED_RESULT bool allDay() const;
168  /** Sets whether the dtstart is a all-day (i.e. has no time attached)
169  @param allDay If the recurrence is for all-day item (true) or has a time associated (false).
170  */
171  void setAllDay(bool allDay);
172 
173  /** Set if recurrence is read-only or can be changed. */
174  void setRecurReadOnly(bool readOnly);
175 
176  /** Returns true if the recurrence is read-only, or false if it can be changed. */
177  Q_REQUIRED_RESULT bool recurReadOnly() const;
178 
179  /** Returns whether the event recurs at all. */
180  Q_REQUIRED_RESULT bool recurs() const;
181 
182  /** Returns the event's recurrence status. See the enumeration at the top
183  * of this file for possible values. */
184  Q_REQUIRED_RESULT ushort recurrenceType() const;
185 
186  /** Returns the recurrence status for a recurrence rule.
187  * See the enumeration at the top of this file for possible values.
188  *
189  * @param rrule the recurrence rule to get the type for
190  */
191  static ushort recurrenceType(const RecurrenceRule *rrule);
192 
193  /**
194  Returns true if the date specified is one on which the event will recur.
195 
196  @param date date to check.
197  @param timeZone time zone for the @p date.
198  */
199  bool recursOn(const QDate &date, const QTimeZone &timeZone) const;
200 
201  /**
202  Returns true if the date/time specified is one at which the event will
203  recur. Times are rounded down to the nearest minute to determine the
204  result.
205 
206  @param dt is the date/time to check.
207  */
208  bool recursAt(const QDateTime &dt) const;
209 
210  /**
211  Removes all recurrence rules. Recurrence dates and exceptions are
212  not removed.
213  */
214  void unsetRecurs();
215 
216  /**
217  Removes all recurrence and exception rules and dates.
218  */
219  void clear();
220 
221  /** Returns a list of the times on the specified date at which the
222  * recurrence will occur. The returned times should be interpreted in the
223  * context of @p timeSpec.
224  * @param date the date for which to find the recurrence times
225  * @param timeZone timezone for @p date
226  */
227  Q_REQUIRED_RESULT TimeList recurTimesOn(const QDate &date, const QTimeZone &timeZone) const;
228 
229  /** Returns a list of all the times at which the recurrence will occur
230  * between two specified times.
231  *
232  * There is a (large) maximum limit to the number of times returned. If due to
233  * this limit the list is incomplete, this is indicated by the last entry being
234  * set to an invalid QDateTime value. If you need further values, call the
235  * method again with a start time set to just after the last valid time returned.
236  *
237  * @param start inclusive start of interval
238  * @param end inclusive end of interval
239  * @return list of date/time values
240  */
241  Q_REQUIRED_RESULT QList<QDateTime> timesInInterval(const QDateTime &start, const QDateTime &end) const;
242 
243  /** Returns the start date/time of the earliest recurrence with a start date/time after
244  * the specified date/time.
245  * If the recurrence has no time, the next date after the specified date is returned.
246  * @param preDateTime the date/time after which to find the recurrence.
247  * @return start date/time of next recurrence (strictly later than the given
248  * QDateTime), or invalid date if none.
249  */
250  Q_REQUIRED_RESULT QDateTime getNextDateTime(const QDateTime &preDateTime) const;
251 
252  /** Returns the date and time of the last previous recurrence, before the specified date/time.
253  * If a time later than 00:00:00 is specified and the recurrence has no time, 00:00:00 on
254  * the specified date is returned if that date recurs.
255  *
256  * @param afterDateTime the date/time before which to find the recurrence.
257  * @return date/time of previous recurrence (strictly earlier than the given
258  * QDateTime), or invalid date if none.
259  */
260  Q_REQUIRED_RESULT QDateTime getPreviousDateTime(const QDateTime &afterDateTime) const;
261 
262  /** Returns frequency of recurrence, in terms of the recurrence time period type. */
263  Q_REQUIRED_RESULT int frequency() const;
264 
265  /** Sets the frequency of recurrence, in terms of the recurrence time period type. */
266  void setFrequency(int freq);
267 
268  /**
269  * Returns -1 if the event recurs infinitely, 0 if the end date is set,
270  * otherwise the total number of recurrences, including the initial occurrence.
271  */
272  Q_REQUIRED_RESULT int duration() const;
273 
274  /** Sets the total number of times the event is to occur, including both the
275  * first and last. */
276  void setDuration(int duration);
277 
278  /** Returns the number of recurrences up to and including the date/time specified.
279  * @warning This function can be very time consuming - use it sparingly!
280  */
281  Q_REQUIRED_RESULT int durationTo(const QDateTime &dt) const;
282 
283  /** Returns the number of recurrences up to and including the date specified.
284  * @warning This function can be very time consuming - use it sparingly!
285  */
286  Q_REQUIRED_RESULT int durationTo(const QDate &date) const;
287 
288  /** Returns the date/time of the last recurrence.
289  * An invalid date is returned if the recurrence has no end.
290  */
291  Q_REQUIRED_RESULT QDateTime endDateTime() const;
292 
293  /** Returns the date of the last recurrence.
294  * An invalid date is returned if the recurrence has no end.
295  */
296  Q_REQUIRED_RESULT QDate endDate() const;
297 
298  /** Sets the date of the last recurrence. The end time is set to the recurrence start time.
299  * @param endDate the ending date after which to stop recurring. If the
300  * recurrence is not all-day, the end time will be 23:59.*/
301  void setEndDate(const QDate &endDate);
302 
303  /** Sets the date and time of the last recurrence.
304  * @param endDateTime the ending date/time after which to stop recurring. */
305  void setEndDateTime(const QDateTime &endDateTime);
306 
307  /**
308  Shift the times of the recurrence so that they appear at the same clock
309  time as before but in a new time zone. The shift is done from a viewing
310  time zone rather than from the actual recurrence time zone.
311 
312  For example, shifting a recurrence whose start time is 09:00 America/New York,
313  using an old viewing time zone (@p oldSpec) of Europe/London, to a new time
314  zone (@p newSpec) of Europe/Paris, will result in the time being shifted
315  from 14:00 (which is the London time of the recurrence start) to 14:00 Paris
316  time.
317 
318  @param oldZone the time specification which provides the clock times
319  @param newZone the new time specification
320  */
321  void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone);
322 
323  /** Sets an event to recur minutely. By default infinite recurrence is used.
324  To set an end date use the method setEndDate and to set the number
325  of occurrences use setDuration.
326 
327  This method clears all recurrence rules and adds one rule with a
328  minutely recurrence. All other recurrence components (recurrence
329  date/times, exception date/times and exception rules) are not
330  modified.
331  * @param freq the frequency to recur, e.g. 2 is every other minute
332  */
333  void setMinutely(int freq);
334 
335  /** Sets an event to recur hourly. By default infinite recurrence is used.
336  The minute of the recurrence is taken from the start date (if you
337  need to change it, you will have to modify the defaultRRule's
338  byMinute list manually.
339  To set an end date use the method setEndDate and to set the number
340  of occurrences use setDuration.
341 
342  This method clears all recurrence rules and adds one rule with a
343  hourly recurrence. All other recurrence components (recurrence
344  date/times, exception date/times and exception rules) are not
345  modified.
346  * @param freq the frequency to recur, e.g. 2 is every other hour
347  */
348  void setHourly(int freq);
349 
350  /** Sets an event to recur daily. By default infinite recurrence is used.
351  The minute and second of the recurrence is taken from the start date
352  (if you need to change them, you will have to modify the defaultRRule's
353  byMinute list manually.
354  To set an end date use the method setEndDate and to set the number
355  of occurrences use setDuration.
356 
357  This method clears all recurrence rules and adds one rule with a
358  daily recurrence. All other recurrence components (recurrence
359  date/times, exception date/times and exception rules) are not
360  modified.
361  * @param freq the frequency to recur, e.g. 2 is every other day
362  */
363  void setDaily(int freq);
364 
365  /** Sets an event to recur weekly. By default infinite recurrence is used.
366  To set an end date use the method setEndDate and to set the number
367  of occurrences use setDuration.
368 
369  This method clears all recurrence rules and adds one rule with a
370  weekly recurrence. All other recurrence components (recurrence
371  date/times, exception date/times and exception rules) are not
372  modified.
373  * @param freq the frequency to recur, e.g. every other week etc.
374  * @param weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday).
375  */
376  void setWeekly(int freq, int weekStart = 1);
377  /** Sets an event to recur weekly. By default infinite recurrence is used.
378  To set an end date use the method setEndDate and to set the number
379  of occurrences use setDuration.
380 
381  This method clears all recurrence rules and adds one rule with a
382  weekly recurrence. All other recurrence components (recurrence
383  date/times, exception date/times and exception rules) are not
384  modified.
385  * @param freq the frequency to recur, e.g. every other week etc.
386  * @param days a 7 bit array indicating which days on which to recur (bit 0 = Monday).
387  * @param weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday).
388  */
389  void setWeekly(int freq, const QBitArray &days, int weekStart = 1);
390 
391  /** Adds days to the weekly day recurrence list.
392  * @param days a 7 bit array indicating which days on which to recur (bit 0 = Monday).
393  */
394  void addWeeklyDays(const QBitArray &days);
395  /** Returns the first day of the week. Uses only the
396  * first RRULE if present (i.e. a second RRULE as well as all EXRULES are
397  * ignored!
398  * @return Weekday of the first day of the week (Monday=1 .. Sunday=7)
399  */
400  int weekStart() const;
401 
402  /** Returns week day mask (bit 0 = Monday). */
403  Q_REQUIRED_RESULT QBitArray days() const; // Emulate the old behavior
404 
405  /** Sets an event to recur monthly. By default infinite recurrence is used.
406  The date of the monthly recurrence will be taken from the start date
407  unless you explicitly add one or more recurrence dates with
408  addMonthlyDate or a recurrence position in the month (e.g. first
409  monday) using addMonthlyPos.
410  To set an end date use the method setEndDate and to set the number
411  of occurrences use setDuration.
412 
413  This method clears all recurrence rules and adds one rule with a
414  monthly recurrence. All other recurrence components (recurrence
415  date/times, exception date/times and exception rules) are not
416  modified.
417  * @param freq the frequency to recur, e.g. 3 for every third month.
418  */
419  void setMonthly(int freq);
420 
421  /** Adds a position (e.g. first monday) to the monthly recurrence rule.
422  * @param pos the position in the month for the recurrence, with valid
423  * values being 1-5 (5 weeks max in a month).
424  * @param days the days for the position to recur on (bit 0 = Monday).
425  * Example: pos = 2, and bits 0 and 2 are set in days:
426  * the rule is to repeat every 2nd Monday and Wednesday in the month.
427  */
428  void addMonthlyPos(short pos, const QBitArray &days);
429  void addMonthlyPos(short pos, ushort day);
430 
431  void setMonthlyPos(const QList<RecurrenceRule::WDayPos> &monthlyDays);
432 
433  /** Adds a date (e.g. the 15th of each month) to the monthly day
434  * recurrence list.
435  * @param day the date in the month to recur.
436  */
437  void addMonthlyDate(short day);
438 
439  void setMonthlyDate(const QList<int> &monthlyDays);
440 
441  /** Returns list of day positions in months. */
442  Q_REQUIRED_RESULT QList<RecurrenceRule::WDayPos> monthPositions() const;
443 
444  /** Returns list of day numbers of a month. */
445  // Emulate old behavior
446  Q_REQUIRED_RESULT QList<int> monthDays() const;
447 
448  /** Sets an event to recur yearly. By default, this will recur every year
449  * on the same date (e.g. every year on April 15 if the start date was
450  * April 15).
451  * The day of the year can be specified with addYearlyDay().
452  * The day of the month can be specified with addYearlyByDate
453  * If both a month and a day ar specified with addYearlyMonth and
454  * addYearlyDay, the day is understood as day number within the month.
455  *
456  * A position (e.g. 3rd Sunday of year/month, or last Friday of year/month)
457  * can be specified with addYearlyPos. Again, if a month is specified,
458  * this position is understood as within that month, otherwise within
459  * the year.
460  *
461  * By default infinite recurrence is used. To set an end date use the
462  * method setEndDate and to set the number of occurrences use setDuration.
463 
464  This method clears all recurrence rules and adds one rule with a
465  yearly recurrence. All other recurrence components (recurrence
466  date/times, exception date/times and exception rules) are not
467  modified.
468  * @param freq the frequency to recur, e.g. 3 for every third year.
469  */
470  void setYearly(int freq);
471 
472  /** Adds day number of year within a yearly recurrence.
473  * By default infinite recurrence is used. To set an end date use the
474  * method setEndDate and to set the number of occurrences use setDuration.
475  * @param day the day of the year for the event. E.g. if day is 60, this
476  * means Feb 29 in leap years and March 1 in non-leap years.
477  */
478  void addYearlyDay(int day);
479 
480  void setYearlyDay(const QList<int> &days);
481 
482  /** Adds date within a yearly recurrence. The month(s) for the recurrence
483  * can be specified with addYearlyMonth(), otherwise the month of the
484  * start date is used.
485  *
486  * By default infinite recurrence is used. To set an end date use the
487  * method setEndDate and to set the number of occurrences use setDuration.
488  * @param date the day of the month for the event
489  */
490  void addYearlyDate(int date);
491 
492  void setYearlyDate(const QList<int> &dates);
493 
494  /** Adds month in yearly recurrence. You can specify specific day numbers
495  * within the months (by calling addYearlyDate()) or specific day positions
496  * within the month (by calling addYearlyPos).
497  * @param _rNum the month in which the event shall recur.
498  */
499  void addYearlyMonth(short _rNum);
500 
501  void setYearlyMonth(const QList<int> &months);
502 
503  /** Adds position within month/year within a yearly recurrence. If months
504  * are specified (via addYearlyMonth()), the parameters are understood as
505  * position within these months, otherwise within the year.
506  *
507  * By default infinite recurrence is used.
508  * To set an end date use the method setEndDate and to set the number
509  * of occurrences use setDuration.
510  * @param pos the position in the month/year for the recurrence, with valid
511  * values being 1 to 53 and -1 to -53 (53 weeks max in a year).
512  * @param days the days for the position to recur on (bit 0 = Monday).
513  * Example: pos = 2, and bits 0 and 2 are set in days
514  * If months are specified (via addYearlyMonth), e.g. March, the rule is
515  * to repeat every year on the 2nd Monday and Wednesday of March.
516  * If no months are specified, the file is to repeat every year on the
517  * 2nd Monday and Wednesday of the year.
518  */
519  void addYearlyPos(short pos, const QBitArray &days);
520 
521  void setYearlyPos(const QList<RecurrenceRule::WDayPos> &days);
522 
523  /** Returns the day numbers within a yearly recurrence.
524  * @return the days of the year for the event. E.g. if the list contains
525  * 60, this means the recurrence happens on day 60 of the year, i.e.
526  * on Feb 29 in leap years and March 1 in non-leap years.
527  */
528  Q_REQUIRED_RESULT QList<int> yearDays() const;
529 
530  /** Returns the dates within a yearly recurrence.
531  * @return the days of the month for the event. E.g. if the list contains
532  * 13, this means the recurrence happens on the 13th of the month.
533  * The months for the recurrence can be obtained through
534  * yearlyMonths(). If this list is empty, the month of the start
535  * date is used.
536  */
537  Q_REQUIRED_RESULT QList<int> yearDates() const;
538 
539  /** Returns the months within a yearly recurrence.
540  * @return the months for the event. E.g. if the list contains
541  * 11, this means the recurrence happens in November.
542  * The days for the recurrence can be obtained either through
543  * yearDates() if they are given as dates within the month or
544  * through yearlyPositions() if they are given as positions within the
545  * month. If none is specified, the date of the start date is used.
546  */
547  Q_REQUIRED_RESULT QList<int> yearMonths() const;
548 
549  /** Returns the positions within a yearly recurrence.
550  * @return the positions for the event, either within a month (if months
551  * are set through addYearlyMonth()) or within the year.
552  * E.g. if the list contains {Pos=3, Day=5}, this means the third
553  * friday. If a month is set this position is understoodas third
554  * Friday in the given months, otherwise as third Friday of the
555  * year.
556  */
557  /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */
558  Q_REQUIRED_RESULT QList<RecurrenceRule::WDayPos> yearPositions() const;
559 
560  /** Upper date limit for recurrences */
561  static const QDate MAX_DATE;
562 
563  /**
564  Debug output.
565  */
566  void dump() const;
567 
568  // RRULE
569  Q_REQUIRED_RESULT RecurrenceRule::List rRules() const;
570  /**
571  Add a recurrence rule to the recurrence.
572  @param rrule the recurrence rule to add
573  */
574  void addRRule(RecurrenceRule *rrule);
575 
576  /**
577  Remove a recurrence rule from the recurrence.
578  @p rrule is not deleted; it is the responsibility of the caller
579  to ensure that it is deleted.
580  @param rrule the recurrence rule to remove
581  */
582  void removeRRule(RecurrenceRule *rrule);
583 
584  /**
585  Remove a recurrence rule from the recurrence and delete it.
586  @param rrule the recurrence rule to remove
587  */
588  void deleteRRule(RecurrenceRule *rrule);
589 
590  // EXRULE
591  Q_REQUIRED_RESULT RecurrenceRule::List exRules() const;
592 
593  /**
594  Add an exception rule to the recurrence.
595  @param exrule the exception rule to add
596  */
597  void addExRule(RecurrenceRule *exrule);
598 
599  /**
600  Remove an exception rule from the recurrence.
601  @p exrule is not deleted; it is the responsibility of the caller
602  to ensure that it is deleted.
603  @param exrule the exception rule to remove
604  */
605  void removeExRule(RecurrenceRule *exrule);
606 
607  /**
608  Remove an exception rule from the recurrence and delete it.
609  @param exrule the exception rule to remove
610  */
611  void deleteExRule(RecurrenceRule *exrule);
612 
613  // RDATE
614  Q_REQUIRED_RESULT QList<QDateTime> rDateTimes() const;
615  Q_REQUIRED_RESULT DateList rDates() const;
616  /**
617  Inquire if the given RDATE is associated to a PERIOD.
618  @param rdate a given RDATE in date time format.
619  @return a Period, invalid if there is no period associated to @param rdate.
620  @since 5.87
621  */
622  Q_REQUIRED_RESULT Period rDateTimePeriod(const QDateTime &rdate) const;
623  void setRDateTimes(const QList<QDateTime> &rdates);
624  void setRDates(const DateList &rdates);
625  void addRDateTime(const QDateTime &rdate);
626  void addRDate(const QDate &rdate);
627  /**
628  Add a RDATE defined as a PERIOD. The start date-time of the period is added
629  to the recurring date time list, and will be listed by a call to
630  rDateTimes(). Use then rDateTimePeriod() to fetch the associated
631  period defintion.
632  @param period a given RDATE in period defintion.
633  @since 5.87
634  */
635  void addRDateTimePeriod(const Period &period);
636 
637  // ExDATE
638  Q_REQUIRED_RESULT QList<QDateTime> exDateTimes() const;
639  Q_REQUIRED_RESULT DateList exDates() const;
640  void setExDateTimes(const QList<QDateTime> &exdates);
641  void setExDates(const DateList &exdates);
642  void addExDateTime(const QDateTime &exdate);
643  void addExDate(const QDate &exdate);
644 
645  RecurrenceRule *defaultRRule(bool create = false) const;
646  RecurrenceRule *defaultRRuleConst() const;
647  void updated();
648 
649  /**
650  Installs an observer. Whenever some setting of this recurrence
651  object is changed, the recurrenceUpdated( Recurrence* ) method
652  of each observer will be called to inform it of changes.
653  @param observer the Recurrence::Observer-derived object, which
654  will be installed as an observer of this object.
655  */
656  void addObserver(RecurrenceObserver *observer);
657  /**
658  Removes an observer that was added with addObserver. If the
659  given object was not an observer, it does nothing.
660  @param observer the Recurrence::Observer-derived object to
661  be removed from the list of observers of this object.
662  */
663  void removeObserver(RecurrenceObserver *observer);
664 
665  void recurrenceChanged(RecurrenceRule *) override;
666 
667 protected:
668  RecurrenceRule *setNewRecurrenceType(RecurrenceRule::PeriodType type, int freq);
669 
670 private:
671  //@cond PRIVATE
672  class Private;
673  Private *const d;
674  //@endcond
675 
676  friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, KCalendarCore::Recurrence *);
677  friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalendarCore::Recurrence *);
678 };
679 
680 /**
681  * Recurrence serializer and deserializer.
682  * @since 4.12
683  */
684 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, KCalendarCore::Recurrence *);
685 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalendarCore::Recurrence *);
686 
687 }
688 
689 #endif
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:820
This file is part of the API for handling calendar data and defines the Period class.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:833
The period can be defined by either a start time and an end time or by a start time and a duration...
Definition: period.h:37
PeriodType
enum for describing the frequency how an event recurs, if at all.
bool operator!=(const Recurrence &r) const
Comparison operator for inequality.
Definition: recurrence.h:131
This class represents a recurrence rule for a calendar incidence.
Definition: recurrence.h:76
static const QDate MAX_DATE
Upper date limit for recurrences.
Definition: recurrence.h:561
This class represents a recurrence rule for a calendar incidence.
Namespace for all KCalendarCore types.
Definition: alarm.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 22 2021 22:52:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.