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 
17 class QBitArray;
18 class QTimeZone;
19 
20 namespace KCalendarCore
21 {
22 
23 class RecurrenceRule;
24 
76 class KCALENDARCORE_EXPORT Recurrence : public RecurrenceRule::RuleObserver
77 {
78 public:
79  class RecurrenceObserver
80  {
81  public:
82  virtual ~RecurrenceObserver();
84  virtual void recurrenceUpdated(Recurrence *r) = 0;
85  };
86 
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 
106  Recurrence();
107 
112  Recurrence(const Recurrence &r);
113 
117  ~Recurrence() override;
118 
124  bool operator==(const Recurrence &r) const;
125 
131  bool operator!=(const Recurrence &r) const
132  {
133  return !operator==(r);
134  }
135 
136 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 64)
137 
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 
151  Q_REQUIRED_RESULT QDateTime startDateTime() const;
153  Q_REQUIRED_RESULT QDate startDate() const;
159  void setStartDateTime(const QDateTime &start, bool isAllDay);
160 
167  Q_REQUIRED_RESULT bool allDay() const;
171  void setAllDay(bool allDay);
172 
174  void setRecurReadOnly(bool readOnly);
175 
177  Q_REQUIRED_RESULT bool recurReadOnly() const;
178 
180  Q_REQUIRED_RESULT bool recurs() const;
181 
184  Q_REQUIRED_RESULT ushort recurrenceType() const;
185 
191  static ushort recurrenceType(const RecurrenceRule *rrule);
192 
199  bool recursOn(const QDate &date, const QTimeZone &timeZone) const;
200 
208  bool recursAt(const QDateTime &dt) const;
209 
214  void unsetRecurs();
215 
219  void clear();
220 
227  Q_REQUIRED_RESULT TimeList recurTimesOn(const QDate &date, const QTimeZone &timeZone) const;
228 
241  Q_REQUIRED_RESULT QList<QDateTime> timesInInterval(const QDateTime &start, const QDateTime &end) const;
242 
250  Q_REQUIRED_RESULT QDateTime getNextDateTime(const QDateTime &preDateTime) const;
251 
260  Q_REQUIRED_RESULT QDateTime getPreviousDateTime(const QDateTime &afterDateTime) const;
261 
263  Q_REQUIRED_RESULT int frequency() const;
264 
266  void setFrequency(int freq);
267 
272  Q_REQUIRED_RESULT int duration() const;
273 
276  void setDuration(int duration);
277 
281  Q_REQUIRED_RESULT int durationTo(const QDateTime &dt) const;
282 
286  Q_REQUIRED_RESULT int durationTo(const QDate &date) const;
287 
291  Q_REQUIRED_RESULT QDateTime endDateTime() const;
292 
296  Q_REQUIRED_RESULT QDate endDate() const;
297 
301  void setEndDate(const QDate &endDate);
302 
305  void setEndDateTime(const QDateTime &endDateTime);
306 
321  void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone);
322 
333  void setMinutely(int freq);
334 
348  void setHourly(int freq);
349 
363  void setDaily(int freq);
364 
376  void setWeekly(int freq, int weekStart = 1);
389  void setWeekly(int freq, const QBitArray &days, int weekStart = 1);
390 
394  void addWeeklyDays(const QBitArray &days);
400  int weekStart() const;
401 
403  Q_REQUIRED_RESULT QBitArray days() const; // Emulate the old behavior
404 
419  void setMonthly(int freq);
420 
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 
437  void addMonthlyDate(short day);
438 
439  void setMonthlyDate(const QList<int> &monthlyDays);
440 
442  Q_REQUIRED_RESULT QList<RecurrenceRule::WDayPos> monthPositions() const;
443 
445  // Emulate old behavior
446  Q_REQUIRED_RESULT QList<int> monthDays() const;
447 
470  void setYearly(int freq);
471 
478  void addYearlyDay(int day);
479 
480  void setYearlyDay(const QList<int> &days);
481 
490  void addYearlyDate(int date);
491 
492  void setYearlyDate(const QList<int> &dates);
493 
499  void addYearlyMonth(short _rNum);
500 
501  void setYearlyMonth(const QList< int > &months);
502 
519  void addYearlyPos(short pos, const QBitArray &days);
520 
521  void setYearlyPos(const QList<RecurrenceRule::WDayPos> &days);
522 
528  Q_REQUIRED_RESULT QList<int> yearDays() const;
529 
537  Q_REQUIRED_RESULT QList<int> yearDates() const;
538 
547  Q_REQUIRED_RESULT QList<int> yearMonths() const;
548 
558  Q_REQUIRED_RESULT QList<RecurrenceRule::WDayPos> yearPositions() const;
559 
561  static const QDate MAX_DATE;
562 
566  void dump() const;
567 
568  // RRULE
569  Q_REQUIRED_RESULT RecurrenceRule::List rRules() const;
574  void addRRule(RecurrenceRule *rrule);
575 
582  void removeRRule(RecurrenceRule *rrule);
583 
588  void deleteRRule(RecurrenceRule *rrule);
589 
590  // EXRULE
591  Q_REQUIRED_RESULT RecurrenceRule::List exRules() const;
592 
597  void addExRule(RecurrenceRule *exrule);
598 
605  void removeExRule(RecurrenceRule *exrule);
606 
611  void deleteExRule(RecurrenceRule *exrule);
612 
613  // RDATE
614  Q_REQUIRED_RESULT QList<QDateTime> rDateTimes() const;
615  Q_REQUIRED_RESULT DateList rDates() const;
616  void setRDateTimes(const QList<QDateTime> &rdates);
617  void setRDates(const DateList &rdates);
618  void addRDateTime(const QDateTime &rdate);
619  void addRDate(const QDate &rdate);
620 
621  // ExDATE
622  Q_REQUIRED_RESULT QList<QDateTime> exDateTimes() const;
623  Q_REQUIRED_RESULT DateList exDates() const;
624  void setExDateTimes(const QList<QDateTime> &exdates);
625  void setExDates(const DateList &exdates);
626  void addExDateTime(const QDateTime &exdate);
627  void addExDate(const QDate &exdate);
628 
629  RecurrenceRule *defaultRRule(bool create = false) const;
630  RecurrenceRule *defaultRRuleConst() const;
631  void updated();
632 
640  void addObserver(RecurrenceObserver *observer);
647  void removeObserver(RecurrenceObserver *observer);
648 
649  void recurrenceChanged(RecurrenceRule *) override;
650 
651 protected:
652  RecurrenceRule *setNewRecurrenceType(RecurrenceRule::PeriodType type, int freq);
653 
654 private:
655  //@cond PRIVATE
656  class Private;
657  Private *const d;
658  //@endcond
659 
660  friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, KCalendarCore::Recurrence *);
661  friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalendarCore::Recurrence *);
662 };
663 
668 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, KCalendarCore::Recurrence *);
669 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalendarCore::Recurrence *);
670 
671 }
672 
673 #endif
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:825
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:849
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-2020 The KDE developers.
Generated on Mon Sep 21 2020 22:51:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.