KCalendarCore

recurrencerule.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, 2007 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_RECURRENCERULE_H
12 #define KCALCORE_RECURRENCERULE_H
13 
14 #include "kcalendarcore_export.h"
15 
16 #include <QDateTime>
17 #include <QTimeZone>
18 
19 class QTimeZone;
20 
21 namespace KCalendarCore {
22 // These two are duplicates wrt. incidencebase.h
23 typedef QList<QDate> DateList;
24 /* List of times */
25 typedef QList<QTime> TimeList;
26 
30 class KCALENDARCORE_EXPORT RecurrenceRule
31 {
32 public:
33  class RuleObserver
34  {
35  public:
36  virtual ~RuleObserver();
38  virtual void recurrenceChanged(RecurrenceRule *) = 0;
39  };
41 
43  enum PeriodType {
44  rNone = 0,
45  rSecondly,
46  rMinutely,
47  rHourly,
48  rDaily,
49  rWeekly,
50  rMonthly,
51  rYearly
52  };
53 
55  class KCALENDARCORE_EXPORT WDayPos //krazy:exclude=dpointer
56  {
57  public:
58  explicit WDayPos(int ps = 0, short dy = 0);
59  void setDay(short dy);
60  short day() const;
61  void setPos(int ps);
62  int pos() const;
63 
64  bool operator==(const RecurrenceRule::WDayPos &pos2) const;
65  bool operator!=(const RecurrenceRule::WDayPos &pos2) const;
66 
67  protected:
68  short mDay; // Weekday, 1=monday, 7=sunday
69  int mPos; // week of the day (-1 for last, 1 for first, 0 for all weeks)
70  // Bounded by -366 and +366, 0 means all weeks in that period
71 
72  friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, const KCalendarCore::RecurrenceRule::WDayPos &);
73  friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalendarCore::RecurrenceRule::WDayPos &);
74  };
75 
78  ~RecurrenceRule();
79 
80  bool operator==(const RecurrenceRule &r) const;
81  bool operator!=(const RecurrenceRule &r) const
82  {
83  return !operator==(r);
84  }
85 
86  RecurrenceRule &operator=(const RecurrenceRule &r);
87 
89  void setReadOnly(bool readOnly);
90 
94  Q_REQUIRED_RESULT bool isReadOnly() const;
95 
100  Q_REQUIRED_RESULT bool recurs() const;
101  void setRecurrenceType(PeriodType period);
102  Q_REQUIRED_RESULT PeriodType recurrenceType() const;
103 
105  void clear();
106 
110  Q_REQUIRED_RESULT uint frequency() const;
111 
115  void setFrequency(int freq);
116 
122  Q_REQUIRED_RESULT QDateTime startDt() const;
123 
136  void setStartDt(const QDateTime &start);
137 
140  Q_REQUIRED_RESULT bool allDay() const;
141 
146  void setAllDay(bool allDay);
147 
153  Q_REQUIRED_RESULT QDateTime endDt(bool *result = nullptr) const;
154 
157  void setEndDt(const QDateTime &endDateTime);
158 
163  Q_REQUIRED_RESULT int duration() const;
164 
167  void setDuration(int duration);
168 
170  Q_REQUIRED_RESULT int durationTo(const QDateTime &dt) const;
171 
173  Q_REQUIRED_RESULT int durationTo(const QDate &date) const;
174 
189  void shiftTimes(const QTimeZone &oldTz, const QTimeZone &newTz);
190 
197  Q_REQUIRED_RESULT bool recursOn(const QDate &date, const QTimeZone &timeZone) const;
198 
205  Q_REQUIRED_RESULT bool recursAt(const QDateTime &dt) const;
206 
214  Q_REQUIRED_RESULT bool dateMatchesRules(const QDateTime &dt) const;
215 
222  Q_REQUIRED_RESULT TimeList recurTimesOn(const QDate &date, const QTimeZone &timeZone) const;
223 
235  Q_REQUIRED_RESULT QList<QDateTime> timesInInterval(const QDateTime &start, const QDateTime &end) const;
236 
242  Q_REQUIRED_RESULT QDateTime getNextDate(const QDateTime &preDateTime) const;
243 
250  Q_REQUIRED_RESULT QDateTime getPreviousDate(const QDateTime &afterDateTime) const;
251 
252  void setBySeconds(const QList<int> &bySeconds);
253  void setByMinutes(const QList<int> &byMinutes);
254  void setByHours(const QList<int> &byHours);
255 
256  void setByDays(const QList<WDayPos> &byDays);
257  void setByMonthDays(const QList<int> &byMonthDays);
258  void setByYearDays(const QList<int> &byYearDays);
259  void setByWeekNumbers(const QList<int> &byWeekNumbers);
260  void setByMonths(const QList<int> &byMonths);
261  void setBySetPos(const QList<int> &bySetPos);
262  void setWeekStart(short weekStart);
263 
264  const QList<int> &bySeconds() const;
265  const QList<int> &byMinutes() const;
266  const QList<int> &byHours() const;
267 
268  const QList<WDayPos> &byDays() const;
269  const QList<int> &byMonthDays() const;
270  const QList<int> &byYearDays() const;
271  const QList<int> &byWeekNumbers() const;
272  const QList<int> &byMonths() const;
273  const QList<int> &bySetPos() const;
274  short weekStart() const;
275 
283  void setRRule(const QString &rrule);
284  Q_REQUIRED_RESULT QString rrule() const;
285 
286  void setDirty();
294  void addObserver(RuleObserver *observer);
295 
302  void removeObserver(RuleObserver *observer);
303 
307  void dump() const;
308 
309 private:
310  //@cond PRIVATE
311  class Private;
312  Private *const d;
313  //@endcond
314 
315  friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, const KCalendarCore::RecurrenceRule *);
316  friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, const KCalendarCore::RecurrenceRule *);
317 };
318 
323 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, const KCalendarCore::RecurrenceRule *);
324 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, const KCalendarCore::RecurrenceRule *);
325 
330 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, const KCalendarCore::RecurrenceRule::WDayPos &);
332 }
333 
334 Q_DECLARE_TYPEINFO(KCalendarCore::RecurrenceRule::WDayPos, Q_MOVABLE_TYPE);
335 
336 #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
structure for describing the n-th weekday of the month/year.
PeriodType
enum for describing the frequency how an event recurs, if at all.
QList< QDate > DateList
List of dates.
Definition: incidencebase.h:63
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 Wed Sep 23 2020 22:51:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.