File indexing completed on 2024-04-21 03:52:52

0001 /*
0002   This file is part of the kcalcore library.
0003 
0004   SPDX-FileCopyrightText: 1998 Preston Brown <pbrown@kde.org>
0005   SPDX-FileCopyrightText: 2001, 2003 Cornelius Schumacher <schumacher@kde.org>
0006   SPDX-FileCopyrightText: 2002, 2006 David Jarvie <djarvie@kde.org>
0007   SPDX-FileCopyrightText: 2005 Reinhold Kainhofer <reinhold@kainhofer.com>
0008 
0009   SPDX-License-Identifier: LGPL-2.0-or-later
0010 */
0011 #ifndef KCALCORE_RECURRENCE_H
0012 #define KCALCORE_RECURRENCE_H
0013 
0014 #include "kcalendarcore_export.h"
0015 #include "recurrencerule.h"
0016 #include "period.h"
0017 
0018 class QBitArray;
0019 class QTimeZone;
0020 
0021 namespace KCalendarCore
0022 {
0023 class RecurrenceRule;
0024 
0025 /**
0026   This class represents a recurrence rule for a calendar incidence.
0027 
0028   It manages all recurrence rules, recurrence date/times, exception rules
0029   and exception date times that can appear inside calendar items.
0030   Each recurrence rule and exception rule is represented as an object
0031   of type RecurrenceRule.
0032 
0033   For the simple case where at most one recurrence
0034   rule is present, this class provides shortcut methods to set the type:
0035     setMinutely()
0036     setHourly()
0037     setDaily()
0038     setWeekly()
0039     setMonthly()
0040     setYearly()
0041   to set/get general information about the recurrence:
0042     setEndDate()
0043     setEndDateTime()
0044     duration()
0045     durationTo()
0046     setDuration()
0047     frequency()
0048     setFrequency()
0049   and to set/get specific information about the recurrence within the interval:
0050     days()
0051     monthDays()
0052     monthPositions()
0053     yearDays()
0054     yearDates()
0055     yearMonths()
0056     yearPositions()
0057     addMonthlyPos()
0058     addMonthlyDate()
0059     addYearlyDay()
0060     addYearlyDate()
0061     addYearlyPos()
0062     addYearlyMonth()
0063   These are all available so that you don't have to work on the RecurrenceRule
0064   objects themselves.
0065   In other words, in that simple situation the interface stays almost the
0066   same compared to the old Recurrence class, which allowed only one
0067   recurrence rule.
0068 
0069   As soon as your recurrence consists of multiple recurrence rules or exception
0070   rules, you cannot use the methods mentioned above any more (since each rule
0071   will have a different type and different settings). If you still call
0072   any of them, the set*ly methods will remove all rules and add one rule with
0073   the specified type. The add* and the other set* methods will change only
0074   the first recurrence rule, but leave the others untouched.
0075 */
0076 class KCALENDARCORE_EXPORT Recurrence : public RecurrenceRule::RuleObserver
0077 {
0078 public:
0079     class RecurrenceObserver
0080     {
0081     public:
0082         virtual ~RecurrenceObserver();
0083         /** This method will be called on each change of the recurrence object */
0084         virtual void recurrenceUpdated(Recurrence *r) = 0;
0085     };
0086 
0087     /** enumeration for describing how an event recurs, if at all. */
0088     enum {
0089         rNone = 0,
0090         rMinutely = 0x001,
0091         rHourly = 0x0002,
0092         rDaily = 0x0003,
0093         rWeekly = 0x0004,
0094         rMonthlyPos = 0x0005,
0095         rMonthlyDay = 0x0006,
0096         rYearlyMonth = 0x0007,
0097         rYearlyDay = 0x0008,
0098         rYearlyPos = 0x0009,
0099         rOther = 0x000A,
0100         rMax = 0x00FF,
0101     };
0102 
0103     /**
0104       Constructs an empty recurrence.
0105     */
0106     Recurrence();
0107 
0108     /**
0109       Copy constructor.
0110       @param r instance to copy from
0111     */
0112     Recurrence(const Recurrence &r);
0113 
0114     /**
0115       Destructor.
0116     */
0117     ~Recurrence() override;
0118 
0119     /**
0120       Comparison operator for equality.
0121       @param r instance to compare with
0122       @return true if recurrences are the same, false otherwise
0123     */
0124     bool operator==(const Recurrence &r) const;
0125 
0126     /**
0127       Comparison operator for inequality.
0128       @param r instance to compare with
0129       @return true if recurrences are the different, false if the same
0130     */
0131     bool operator!=(const Recurrence &r) const
0132     {
0133         return !operator==(r);
0134     }
0135 
0136     Recurrence &operator=(const Recurrence &r) = delete;
0137 
0138     /** Return the start date/time of the recurrence (Time for all-day recurrences will be 0:00).
0139      @return the current start/time of the recurrence. */
0140     Q_REQUIRED_RESULT QDateTime startDateTime() const;
0141     /** Return the start date/time of the recurrence */
0142     Q_REQUIRED_RESULT QDate startDate() const;
0143     /** Set start of recurrence.
0144        @param start the new start date or date/time of the recurrence.
0145        @param isAllDay if true, the recurrence is set to all-day.  Otherwise the recurrence is set
0146        to non-all-day.
0147     */
0148     void setStartDateTime(const QDateTime &start, bool isAllDay);
0149 
0150     /** Set whether the recurrence has no time, just a date.
0151      * All-day means -- according to rfc2445 -- that the event has no time
0152      * associated.
0153      * N.B. This property is derived by default from whether setStartDateTime() is
0154      * called with a date-only or date/time parameter.
0155      * @return whether the recurrence has a time (false) or it is just a date (true). */
0156     Q_REQUIRED_RESULT bool allDay() const;
0157     /** Sets whether the dtstart is a all-day (i.e. has no time attached)
0158        @param allDay If the recurrence is for all-day item (true) or has a time associated (false).
0159        */
0160     void setAllDay(bool allDay);
0161 
0162     /** Set if recurrence is read-only or can be changed. */
0163     void setRecurReadOnly(bool readOnly);
0164 
0165     /** Returns true if the recurrence is read-only, or false if it can be changed. */
0166     Q_REQUIRED_RESULT bool recurReadOnly() const;
0167 
0168     /** Returns whether the event recurs at all. */
0169     Q_REQUIRED_RESULT bool recurs() const;
0170 
0171     /** Returns the event's recurrence status.  See the enumeration at the top
0172      * of this file for possible values. */
0173     Q_REQUIRED_RESULT ushort recurrenceType() const;
0174 
0175     /** Returns the recurrence status for a recurrence rule.
0176      * See the enumeration at the top of this file for possible values.
0177      *
0178      * @param rrule the recurrence rule to get the type for
0179      */
0180     static ushort recurrenceType(const RecurrenceRule *rrule);
0181 
0182     /**
0183       Returns true if the date specified is one on which the event will recur.
0184 
0185       @param date date to check.
0186       @param timeZone time zone for the @p date.
0187     */
0188     bool recursOn(const QDate &date, const QTimeZone &timeZone) const;
0189 
0190     /**
0191       Returns true if the date/time specified is one at which the event will
0192       recur. Times are rounded down to the nearest minute to determine the
0193       result.
0194 
0195       @param dt is the date/time to check.
0196     */
0197     bool recursAt(const QDateTime &dt) const;
0198 
0199     /**
0200       Removes all recurrence rules. Recurrence dates and exceptions are
0201       not removed.
0202     */
0203     void unsetRecurs();
0204 
0205     /**
0206       Removes all recurrence and exception rules and dates.
0207     */
0208     void clear();
0209 
0210     /** Returns a list of the times on the specified date at which the
0211      * recurrence will occur. The returned times should be interpreted in the
0212      * context of @p timeSpec.
0213      * @param date the date for which to find the recurrence times
0214      * @param timeZone timezone for @p date
0215      */
0216     Q_REQUIRED_RESULT TimeList recurTimesOn(const QDate &date, const QTimeZone &timeZone) const;
0217 
0218     /** Returns a list of all the times at which the recurrence will occur
0219      * between two specified times.
0220      *
0221      * There is a (large) maximum limit to the number of times returned. If due to
0222      * this limit the list is incomplete, this is indicated by the last entry being
0223      * set to an invalid QDateTime value. If you need further values, call the
0224      * method again with a start time set to just after the last valid time returned.
0225      *
0226      * @param start inclusive start of interval
0227      * @param end inclusive end of interval
0228      * @return list of date/time values
0229      */
0230     Q_REQUIRED_RESULT QList<QDateTime> timesInInterval(const QDateTime &start, const QDateTime &end) const;
0231 
0232     /** Returns the start date/time of the earliest recurrence with a start date/time after
0233      * the specified date/time.
0234      * If the recurrence has no time, the next date after the specified date is returned.
0235      * @param preDateTime the date/time after which to find the recurrence.
0236      * @return start date/time of next recurrence (strictly later than the given
0237      *         QDateTime), or invalid date if none.
0238      */
0239     Q_REQUIRED_RESULT QDateTime getNextDateTime(const QDateTime &preDateTime) const;
0240 
0241     /** Returns the date and time of the last previous recurrence, before the specified date/time.
0242      * If a time later than 00:00:00 is specified and the recurrence has no time, 00:00:00 on
0243      * the specified date is returned if that date recurs.
0244      *
0245      * @param afterDateTime the date/time before which to find the recurrence.
0246      * @return date/time of previous recurrence (strictly earlier than the given
0247      *         QDateTime), or invalid date if none.
0248      */
0249     Q_REQUIRED_RESULT QDateTime getPreviousDateTime(const QDateTime &afterDateTime) const;
0250 
0251     /** Returns frequency of recurrence, in terms of the recurrence time period type. */
0252     Q_REQUIRED_RESULT int frequency() const;
0253 
0254     /** Sets the frequency of recurrence, in terms of the recurrence time period type. */
0255     void setFrequency(int freq);
0256 
0257     /**
0258      * Returns -1 if the event recurs infinitely, 0 if the end date is set,
0259      * otherwise the total number of recurrences, including the initial occurrence.
0260      */
0261     Q_REQUIRED_RESULT int duration() const;
0262 
0263     /** Sets the total number of times the event is to occur, including both the
0264      * first and last. */
0265     void setDuration(int duration);
0266 
0267     /** Returns the number of recurrences up to and including the date/time specified.
0268      *  @warning This function can be very time consuming - use it sparingly!
0269      */
0270     Q_REQUIRED_RESULT int durationTo(const QDateTime &dt) const;
0271 
0272     /** Returns the number of recurrences up to and including the date specified.
0273      *  @warning This function can be very time consuming - use it sparingly!
0274      */
0275     Q_REQUIRED_RESULT int durationTo(const QDate &date) const;
0276 
0277     /** Returns the date/time of the last recurrence.
0278      * An invalid date is returned if the recurrence has no end.
0279      */
0280     Q_REQUIRED_RESULT QDateTime endDateTime() const;
0281 
0282     /** Returns the date of the last recurrence.
0283      * An invalid date is returned if the recurrence has no end.
0284      */
0285     Q_REQUIRED_RESULT QDate endDate() const;
0286 
0287     /** Sets the date of the last recurrence. The end time is set to the recurrence start time.
0288      * @param endDate the ending date after which to stop recurring. If the
0289      *   recurrence is not all-day, the end time will be 23:59.*/
0290     void setEndDate(const QDate &endDate);
0291 
0292     /** Sets the date and time of the last recurrence.
0293      * @param endDateTime the ending date/time after which to stop recurring. */
0294     void setEndDateTime(const QDateTime &endDateTime);
0295 
0296     /**
0297       Shift the times of the recurrence so that they appear at the same clock
0298       time as before but in a new time zone. The shift is done from a viewing
0299       time zone rather than from the actual recurrence time zone.
0300 
0301       For example, shifting a recurrence whose start time is 09:00 America/New York,
0302       using an old viewing time zone (@p oldSpec) of Europe/London, to a new time
0303       zone (@p newSpec) of Europe/Paris, will result in the time being shifted
0304       from 14:00 (which is the London time of the recurrence start) to 14:00 Paris
0305       time.
0306 
0307       @param oldZone the time specification which provides the clock times
0308       @param newZone the new time specification
0309     */
0310     void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone);
0311 
0312     /** Sets an event to recur minutely. By default infinite recurrence is used.
0313         To set an end date use the method setEndDate and to set the number
0314         of occurrences use setDuration.
0315 
0316         This method clears all recurrence rules and adds one rule with a
0317         minutely recurrence. All other recurrence components (recurrence
0318         date/times, exception date/times and exception rules) are not
0319         modified.
0320      * @param freq the frequency to recur, e.g. 2 is every other minute
0321      */
0322     void setMinutely(int freq);
0323 
0324     /** Sets an event to recur hourly. By default infinite recurrence is used.
0325         The minute of the recurrence is taken from the start date (if you
0326         need to change it, you will have to modify the defaultRRule's
0327         byMinute list manually.
0328         To set an end date use the method setEndDate and to set the number
0329         of occurrences use setDuration.
0330 
0331         This method clears all recurrence rules and adds one rule with a
0332         hourly recurrence. All other recurrence components (recurrence
0333         date/times, exception date/times and exception rules) are not
0334         modified.
0335      * @param freq the frequency to recur, e.g. 2 is every other hour
0336      */
0337     void setHourly(int freq);
0338 
0339     /** Sets an event to recur daily. By default infinite recurrence is used.
0340         The minute and second of the recurrence is taken from the start date
0341         (if you need to change them, you will have to modify the defaultRRule's
0342         byMinute list manually.
0343         To set an end date use the method setEndDate and to set the number
0344         of occurrences use setDuration.
0345 
0346         This method clears all recurrence rules and adds one rule with a
0347         daily recurrence. All other recurrence components (recurrence
0348         date/times, exception date/times and exception rules) are not
0349         modified.
0350      * @param freq the frequency to recur, e.g. 2 is every other day
0351      */
0352     void setDaily(int freq);
0353 
0354     /** Sets an event to recur weekly. By default infinite recurrence is used.
0355         To set an end date use the method setEndDate and to set the number
0356         of occurrences use setDuration.
0357 
0358         This method clears all recurrence rules and adds one rule with a
0359         weekly recurrence. All other recurrence components (recurrence
0360         date/times, exception date/times and exception rules) are not
0361         modified.
0362      * @param freq the frequency to recur, e.g. every other week etc.
0363      * @param weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday).
0364      */
0365     void setWeekly(int freq, int weekStart = 1);
0366     /** Sets an event to recur weekly. By default infinite recurrence is used.
0367         To set an end date use the method setEndDate and to set the number
0368         of occurrences use setDuration.
0369 
0370         This method clears all recurrence rules and adds one rule with a
0371         weekly recurrence. All other recurrence components (recurrence
0372         date/times, exception date/times and exception rules) are not
0373         modified.
0374      * @param freq the frequency to recur, e.g. every other week etc.
0375      * @param days a 7 bit array indicating which days on which to recur (bit 0 = Monday).
0376      * @param weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday).
0377      */
0378     void setWeekly(int freq, const QBitArray &days, int weekStart = 1);
0379 
0380     /** Adds days to the weekly day recurrence list.
0381      * @param days a 7 bit array indicating which days on which to recur (bit 0 = Monday).
0382      */
0383     void addWeeklyDays(const QBitArray &days);
0384     /** Returns the first day of the week.  Uses only the
0385      * first RRULE if present (i.e. a second RRULE as well as all EXRULES are
0386      * ignored!
0387      * @return Weekday of the first day of the week (Monday=1 .. Sunday=7)
0388      */
0389     int weekStart() const;
0390 
0391     /** Returns week day mask (bit 0 = Monday). */
0392     Q_REQUIRED_RESULT QBitArray days() const; // Emulate the old behavior
0393 
0394     /** Sets an event to recur monthly. By default infinite recurrence is used.
0395         The date of the monthly recurrence will be taken from the start date
0396         unless you explicitly add one or more recurrence dates with
0397         addMonthlyDate or a recurrence position in the month (e.g. first
0398         monday) using addMonthlyPos.
0399         To set an end date use the method setEndDate and to set the number
0400         of occurrences use setDuration.
0401 
0402         This method clears all recurrence rules and adds one rule with a
0403         monthly recurrence. All other recurrence components (recurrence
0404         date/times, exception date/times and exception rules) are not
0405         modified.
0406      * @param freq the frequency to recur, e.g. 3 for every third month.
0407      */
0408     void setMonthly(int freq);
0409 
0410     /** Adds a position (e.g. first monday) to the monthly recurrence rule.
0411      * @param pos the position in the month for the recurrence, with valid
0412      * values being 1-5 (5 weeks max in a month).
0413      * @param days the days for the position to recur on (bit 0 = Monday).
0414      * Example: pos = 2, and bits 0 and 2 are set in days:
0415      * the rule is to repeat every 2nd Monday and Wednesday in the month.
0416      */
0417     void addMonthlyPos(short pos, const QBitArray &days);
0418     void addMonthlyPos(short pos, ushort day);
0419 
0420     void setMonthlyPos(const QList<RecurrenceRule::WDayPos> &monthlyDays);
0421 
0422     /** Adds a date (e.g. the 15th of each month) to the monthly day
0423      *  recurrence list.
0424      * @param day the date in the month to recur.
0425      */
0426     void addMonthlyDate(short day);
0427 
0428     void setMonthlyDate(const QList<int> &monthlyDays);
0429 
0430     /** Returns list of day positions in months. */
0431     Q_REQUIRED_RESULT QList<RecurrenceRule::WDayPos> monthPositions() const;
0432 
0433     /** Returns list of day numbers of a  month. */
0434     // Emulate old behavior
0435     Q_REQUIRED_RESULT QList<int> monthDays() const;
0436 
0437     /** Sets an event to recur yearly. By default, this will recur every year
0438      *  on the same date (e.g. every year on April 15 if the start date was
0439      *  April 15).
0440      *  The day of the year can be specified with addYearlyDay().
0441      *  The day of the month can be specified with addYearlyByDate
0442      *  If both a month and a day ar specified with addYearlyMonth and
0443      *  addYearlyDay, the day is understood as day number within the month.
0444      *
0445      *  A position (e.g. 3rd Sunday of year/month, or last Friday of year/month)
0446      *  can be specified with addYearlyPos. Again, if a month is specified,
0447      *  this position is understood as within that month, otherwise within
0448      *  the year.
0449      *
0450      *  By default infinite recurrence is used. To set an end date use the
0451      *  method setEndDate and to set the number of occurrences use setDuration.
0452 
0453         This method clears all recurrence rules and adds one rule with a
0454         yearly recurrence. All other recurrence components (recurrence
0455         date/times, exception date/times and exception rules) are not
0456         modified.
0457      * @param freq the frequency to recur, e.g. 3 for every third year.
0458      */
0459     void setYearly(int freq);
0460 
0461     /** Adds day number of year within a yearly recurrence.
0462      *  By default infinite recurrence is used. To set an end date use the
0463      *  method setEndDate and to set the number of occurrences use setDuration.
0464      * @param day the day of the year for the event. E.g. if day is 60, this
0465      *            means Feb 29 in leap years and March 1 in non-leap years.
0466      */
0467     void addYearlyDay(int day);
0468 
0469     void setYearlyDay(const QList<int> &days);
0470 
0471     /** Adds date within a yearly recurrence. The month(s) for the recurrence
0472      *  can be specified with addYearlyMonth(), otherwise the month of the
0473      *  start date is used.
0474      *
0475      *   By default infinite recurrence is used. To set an end date use the
0476      *   method setEndDate and to set the number of occurrences use setDuration.
0477      * @param date the day of the month for the event
0478      */
0479     void addYearlyDate(int date);
0480 
0481     void setYearlyDate(const QList<int> &dates);
0482 
0483     /** Adds month in yearly recurrence. You can specify specific day numbers
0484      *  within the months (by calling addYearlyDate()) or specific day positions
0485      *  within the month (by calling addYearlyPos).
0486      * @param _rNum the month in which the event shall recur.
0487      */
0488     void addYearlyMonth(short _rNum);
0489 
0490     void setYearlyMonth(const QList<int> &months);
0491 
0492     /** Adds position within month/year within a yearly recurrence. If months
0493      *  are specified (via addYearlyMonth()), the parameters are understood as
0494      *  position within these months, otherwise within the year.
0495      *
0496      *  By default infinite recurrence is used.
0497      *   To set an end date use the method setEndDate and to set the number
0498      *   of occurrences use setDuration.
0499      * @param pos the position in the month/year for the recurrence, with valid
0500      * values being 1 to 53 and -1 to -53 (53 weeks max in a year).
0501      * @param days the days for the position to recur on (bit 0 = Monday).
0502      * Example: pos = 2, and bits 0 and 2 are set in days
0503      *   If months are specified (via addYearlyMonth), e.g. March, the rule is
0504      *   to repeat every year on the 2nd Monday and Wednesday of March.
0505      *   If no months are specified, the file is to repeat every year on the
0506      *   2nd Monday and Wednesday of the year.
0507      */
0508     void addYearlyPos(short pos, const QBitArray &days);
0509 
0510     void setYearlyPos(const QList<RecurrenceRule::WDayPos> &days);
0511 
0512     /** Returns the day numbers within a yearly recurrence.
0513      * @return the days of the year for the event. E.g. if the list contains
0514      *         60, this means the recurrence happens on day 60 of the year, i.e.
0515      *         on Feb 29 in leap years and March 1 in non-leap years.
0516      */
0517     Q_REQUIRED_RESULT QList<int> yearDays() const;
0518 
0519     /** Returns the dates within a yearly recurrence.
0520      * @return the days of the month for the event. E.g. if the list contains
0521      *         13, this means the recurrence happens on the 13th of the month.
0522      *         The months for the recurrence can be obtained through
0523      *         yearlyMonths(). If this list is empty, the month of the start
0524      *         date is used.
0525      */
0526     Q_REQUIRED_RESULT QList<int> yearDates() const;
0527 
0528     /** Returns the months within a yearly recurrence.
0529      * @return the months for the event. E.g. if the list contains
0530      *         11, this means the recurrence happens in November.
0531      *         The days for the recurrence can be obtained either through
0532      *         yearDates() if they are given as dates within the month or
0533      *         through yearlyPositions() if they are given as positions within the
0534      *         month. If none is specified, the date of the start date is used.
0535      */
0536     Q_REQUIRED_RESULT QList<int> yearMonths() const;
0537 
0538     /** Returns the positions within a yearly recurrence.
0539      * @return the positions for the event, either within a month (if months
0540      *         are set through addYearlyMonth()) or within the year.
0541      *         E.g. if the list contains {Pos=3, Day=5}, this means the third
0542      *         friday. If a month is set this position is understoodas third
0543      *         Friday in the given months, otherwise as third Friday of the
0544      *         year.
0545      */
0546     /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */
0547     Q_REQUIRED_RESULT QList<RecurrenceRule::WDayPos> yearPositions() const;
0548 
0549     /** Upper date limit for recurrences */
0550     static const QDate MAX_DATE;
0551 
0552     /**
0553       Debug output.
0554     */
0555     void dump() const;
0556 
0557     // RRULE
0558     Q_REQUIRED_RESULT RecurrenceRule::List rRules() const;
0559     /**
0560       Add a recurrence rule to the recurrence.
0561       @param rrule the recurrence rule to add
0562      */
0563     void addRRule(RecurrenceRule *rrule);
0564 
0565     /**
0566       Remove a recurrence rule from the recurrence.
0567       @p rrule is not deleted; it is the responsibility of the caller
0568       to ensure that it is deleted.
0569       @param rrule the recurrence rule to remove
0570      */
0571     void removeRRule(RecurrenceRule *rrule);
0572 
0573     /**
0574       Remove a recurrence rule from the recurrence and delete it.
0575       @param rrule the recurrence rule to remove
0576      */
0577     void deleteRRule(RecurrenceRule *rrule);
0578 
0579     // EXRULE
0580     Q_REQUIRED_RESULT RecurrenceRule::List exRules() const;
0581 
0582     /**
0583       Add an exception rule to the recurrence.
0584       @param exrule the exception rule to add
0585      */
0586     void addExRule(RecurrenceRule *exrule);
0587 
0588     /**
0589       Remove an exception rule from the recurrence.
0590       @p exrule is not deleted; it is the responsibility of the caller
0591       to ensure that it is deleted.
0592       @param exrule the exception rule to remove
0593      */
0594     void removeExRule(RecurrenceRule *exrule);
0595 
0596     /**
0597       Remove an exception rule from the recurrence and delete it.
0598       @param exrule the exception rule to remove
0599      */
0600     void deleteExRule(RecurrenceRule *exrule);
0601 
0602     // RDATE
0603     Q_REQUIRED_RESULT QList<QDateTime> rDateTimes() const;
0604     Q_REQUIRED_RESULT DateList rDates() const;
0605     /**
0606       Inquire if the given RDATE is associated to a PERIOD.
0607       @param rdate a given RDATE in date time format.
0608       @return a Period, invalid if there is no period associated to @param rdate.
0609       @since 5.87
0610      */
0611     Q_REQUIRED_RESULT Period rDateTimePeriod(const QDateTime &rdate) const;
0612     void setRDateTimes(const QList<QDateTime> &rdates);
0613     void setRDates(const DateList &rdates);
0614     void addRDateTime(const QDateTime &rdate);
0615     void addRDate(const QDate &rdate);
0616     /**
0617       Add a RDATE defined as a PERIOD. The start date-time of the period is added
0618       to the recurring date time list, and will be listed by a call to
0619       rDateTimes(). Use then rDateTimePeriod() to fetch the associated
0620       period defintion.
0621       @param period a given RDATE in period defintion.
0622       @since 5.87
0623      */
0624     void addRDateTimePeriod(const Period &period);
0625 
0626     // ExDATE
0627     Q_REQUIRED_RESULT QList<QDateTime> exDateTimes() const;
0628     Q_REQUIRED_RESULT DateList exDates() const;
0629     void setExDateTimes(const QList<QDateTime> &exdates);
0630     void setExDates(const DateList &exdates);
0631     void addExDateTime(const QDateTime &exdate);
0632     void addExDate(const QDate &exdate);
0633 
0634     RecurrenceRule *defaultRRule(bool create = false) const;
0635     RecurrenceRule *defaultRRuleConst() const;
0636     void updated();
0637 
0638     /**
0639       Installs an observer. Whenever some setting of this recurrence
0640       object is changed, the recurrenceUpdated( Recurrence* ) method
0641       of each observer will be called to inform it of changes.
0642       @param observer the Recurrence::Observer-derived object, which
0643       will be installed as an observer of this object.
0644     */
0645     void addObserver(RecurrenceObserver *observer);
0646     /**
0647       Removes an observer that was added with addObserver. If the
0648       given object was not an observer, it does nothing.
0649       @param observer the Recurrence::Observer-derived object to
0650       be removed from the list of observers of this object.
0651     */
0652     void removeObserver(RecurrenceObserver *observer);
0653 
0654     void recurrenceChanged(RecurrenceRule *) override;
0655 
0656 protected:
0657     RecurrenceRule *setNewRecurrenceType(RecurrenceRule::PeriodType type, int freq);
0658 
0659 private:
0660     //@cond PRIVATE
0661     class Private;
0662     Private *const d;
0663     //@endcond
0664 
0665     friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, KCalendarCore::Recurrence *);
0666     friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalendarCore::Recurrence *);
0667 };
0668 
0669 /**
0670  * Recurrence serializer and deserializer.
0671  * @since 4.12
0672  */
0673 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, KCalendarCore::Recurrence *);
0674 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalendarCore::Recurrence *);
0675 
0676 }
0677 
0678 #endif