13#include "recurrence.h"
14#include "recurrencehelper_p.h"
17#include "kcalendarcore_debug.h"
34 , mRecurReadOnly(false)
38 Private(
const Private &p)
39 : mRDateTimes(p.mRDateTimes)
40 , mRDateTimePeriods(p.mRDateTimePeriods)
42 , mExDateTimes(p.mExDateTimes)
43 , mExDates(p.mExDates)
44 , mStartDateTime(p.mStartDateTime)
45 , mCachedType(p.mCachedType)
47 , mRecurReadOnly(p.mRecurReadOnly)
64 mutable ushort mCachedType;
67 bool mRecurReadOnly =
false;
70bool Recurrence::Private::operator==(
const Recurrence::Private &p)
const
73 if (!
identical(mStartDateTime, p.mStartDateTime) || mAllDay != p.mAllDay
74 || mRecurReadOnly != p.mRecurReadOnly || mExDates != p.mExDates || mExDateTimes != p.mExDateTimes || mRDates != p.mRDates
75 || mRDateTimes != p.mRDateTimes || mRDateTimePeriods != p.mRDateTimePeriods) {
82 int end = mRRules.count();
83 if (end != p.mRRules.count()) {
86 for (i = 0; i <
end; ++i) {
87 if (*mRRules[i] != *p.mRRules[i]) {
91 end = mExRules.count();
92 if (end != p.mExRules.count()) {
95 for (i = 0; i <
end; ++i) {
96 if (*mExRules[i] != *p.mExRules[i]) {
115 d->mRRules.reserve(r.d->mRRules.count());
116 for (i = 0, end = r.d->mRRules.count(); i < end; ++i) {
117 RecurrenceRule *rule = new RecurrenceRule(*r.d->mRRules[i]);
118 d->mRRules.append(rule);
119 rule->addObserver(this);
121 d->mExRules.reserve(r.d->mExRules.count());
122 for (i = 0, end = r.d->mExRules.count(); i < end; ++i) {
123 RecurrenceRule *rule = new RecurrenceRule(*r.d->mExRules[i]);
124 d->mExRules.append(rule);
125 rule->addObserver(this);
131 qDeleteAll(d->mExRules);
132 qDeleteAll(d->mRRules);
138 return *d == *recurrence.d;
143 if (!d->mObservers.contains(observer)) {
144 d->mObservers.append(observer);
150 d->mObservers.removeAll(observer);
155 return d->mStartDateTime;
165 if (d->mRecurReadOnly ||
allDay == d->mAllDay) {
170 for (
int i = 0, end = d->mRRules.count(); i < end; ++i) {
171 d->mRRules[i]->setAllDay(
allDay);
173 for (
int i = 0, end = d->mExRules.count(); i < end; ++i) {
174 d->mExRules[i]->setAllDay(
allDay);
181 if (d->mRRules.isEmpty()) {
182 if (!create || d->mRecurReadOnly) {
190 return d->mRRules[0];
196 return d->mRRules.isEmpty() ? nullptr : d->mRRules[0];
199void Recurrence::updated()
202 d->mCachedType = rMax;
203 for (
int i = 0, end = d->mObservers.count(); i < end; ++i) {
204 if (d->mObservers[i]) {
205 d->mObservers[i]->recurrenceUpdated(
this);
212 return !d->mRRules.isEmpty() || !d->mRDates.isEmpty() || !d->mRDateTimes.isEmpty();
217 if (d->mCachedType == rMax) {
220 return d->mCachedType;
231 if (!rrule->bySetPos().isEmpty() || !rrule->bySeconds().isEmpty() || !rrule->byWeekNumbers().isEmpty()) {
237 if (!rrule->byMinutes().isEmpty() || !rrule->byHours().isEmpty()) {
246 if ((!rrule->byYearDays().isEmpty() && type != RecurrenceRule::rYearly) || (!rrule->byMonths().isEmpty() && type != RecurrenceRule::rYearly)) {
249 if (!rrule->byDays().isEmpty()) {
250 if (type != RecurrenceRule::rYearly && type != RecurrenceRule::rMonthly && type != RecurrenceRule::rWeekly) {
256 case RecurrenceRule::rNone:
258 case RecurrenceRule::rMinutely:
260 case RecurrenceRule::rHourly:
262 case RecurrenceRule::rDaily:
264 case RecurrenceRule::rWeekly:
266 case RecurrenceRule::rMonthly: {
267 if (rrule->byDays().isEmpty()) {
269 }
else if (rrule->byMonthDays().isEmpty()) {
275 case RecurrenceRule::rYearly: {
280 if (!rrule->byDays().isEmpty()) {
282 if (rrule->byMonthDays().isEmpty() && rrule->byYearDays().isEmpty()) {
287 }
else if (!rrule->byYearDays().isEmpty()) {
289 if (rrule->byMonths().isEmpty() && rrule->byMonthDays().isEmpty()) {
306 if (
QDateTime(qd,
QTime(23, 59, 59), timeZone) < d->mStartDateTime) {
311 if (std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), qd)) {
320 for (i = 0, end = d->mExRules.count(); i < end; ++i) {
321 if (d->mExRules[i]->recursOn(qd, timeZone)) {
327 if (std::binary_search(d->mRDates.constBegin(), d->mRDates.constEnd(), qd)) {
333 for (i = 0, end = d->mRDateTimes.count(); i < end && !
recurs; ++i) {
334 recurs = (d->mRDateTimes[i].toTimeZone(timeZone).date() == qd);
336 for (i = 0, end = d->mRRules.count(); i < end && !
recurs; ++i) {
337 recurs = d->mRRules[i]->recursOn(qd, timeZone);
346 for (i = 0, end = d->mExDateTimes.count(); i < end && !exon; ++i) {
347 exon = (d->mExDateTimes[i].toTimeZone(timeZone).date() == qd);
350 for (i = 0, end = d->mExRules.count(); i < end && !exon; ++i) {
351 exon = d->mExRules[i]->recursOn(qd, timeZone);
371 const auto dtrecur = dt.
toTimeZone(d->mStartDateTime.timeZone());
374 if (std::binary_search(d->mExDateTimes.constBegin(), d->mExDateTimes.constEnd(), dtrecur)
375 || std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), dtrecur.date())) {
380 for (i = 0, end = d->mExRules.count(); i < end; ++i) {
381 if (d->mExRules[i]->recursAt(dtrecur)) {
387 if (
startDateTime() == dtrecur || std::binary_search(d->mRDateTimes.constBegin(), d->mRDateTimes.constEnd(), dtrecur)) {
390 for (i = 0, end = d->mRRules.count(); i < end; ++i) {
391 if (d->mRRules[i]->recursAt(dtrecur)) {
406 if (!d->mRDates.isEmpty()) {
407 dts <<
QDateTime(d->mRDates.last(),
QTime(0, 0, 0), d->mStartDateTime.timeZone());
409 if (!d->mRDateTimes.isEmpty()) {
410 dts << d->mRDateTimes.
last();
412 for (
int i = 0, end = d->mRRules.count(); i < end; ++i) {
413 auto rl = d->mRRules[i]->endDt();
420 sortAndRemoveDuplicates(dts);
430 return end.isValid() ? end.date() :
QDate();
435 QDateTime dt(date, d->mStartDateTime.time(), d->mStartDateTime.timeZone());
444 if (d->mRecurReadOnly) {
471 return rrule ? rrule->
duration() : 0;
478 return rrule ? rrule->
durationTo(datetime) : 0;
488 if (d->mRecurReadOnly) {
505 if (d->mRecurReadOnly) {
509 d->mStartDateTime = d->mStartDateTime.toTimeZone(oldTz);
510 d->mStartDateTime.setTimeZone(newTz);
514 for (
auto &rDt : d->mRDateTimes) {
515 auto periodIt = oldPeriods.
find(rDt);
516 periodIt->shiftTimes(oldTz, newTz);
517 rDt = rDt.toTimeZone(oldTz);
518 rDt.setTimeZone(newTz);
520 d->mRDateTimePeriods.insert(rDt, *periodIt);
523 for (
auto &exDt : d->mExDateTimes) {
524 exDt = exDt.toTimeZone(oldTz);
525 exDt.setTimeZone(newTz);
528 for (
auto &rr : d->mRRules) {
529 rr->shiftTimes(oldTz, newTz);
532 for (
auto exR : d->mExRules) {
533 exR->shiftTimes(oldTz, newTz);
539 if (d->mRecurReadOnly) {
542 qDeleteAll(d->mRRules);
549 if (d->mRecurReadOnly) {
552 qDeleteAll(d->mRRules);
554 qDeleteAll(d->mExRules);
557 d->mRDateTimes.clear();
558 d->mRDateTimePeriods.clear();
560 d->mExDateTimes.clear();
561 d->mCachedType = rMax;
567 d->mRecurReadOnly = readOnly;
572 return d->mRecurReadOnly;
577 return d->mStartDateTime.date();
582 if (d->mRecurReadOnly) {
585 d->mStartDateTime =
start;
590 for (i = 0, end = d->mRRules.count(); i < end; ++i) {
591 d->mRRules[i]->setStartDt(
start);
593 for (i = 0, end = d->mExRules.count(); i < end; ++i) {
594 d->mExRules[i]->setStartDt(
start);
609 if (d->mRecurReadOnly || freq <= 0) {
625 return rrule ? rrule->weekStart() : 1;
636 for (
int i = 0; i < bydays.
size(); ++i) {
637 if (bydays.
at(i).pos() == 0) {
652 return rrule->byMonthDays();
670 return rrule ? rrule->byYearDays() :
QList<int>();
681 return rrule ? rrule->byMonths() :
QList<int>();
691 if (d->mRecurReadOnly || freq <= 0) {
700 qDeleteAll(d->mRRules);
707 rrule->setRecurrenceType(type);
715 if (setNewRecurrenceType(RecurrenceRule::rMinutely, _rFreq)) {
722 if (setNewRecurrenceType(RecurrenceRule::rHourly, _rFreq)) {
729 if (setNewRecurrenceType(RecurrenceRule::rDaily, _rFreq)) {
736 RecurrenceRule *rrule = setNewRecurrenceType(RecurrenceRule::rWeekly, freq);
757 if (setNewRecurrenceType(RecurrenceRule::rMonthly, freq)) {
765 if (d->mRecurReadOnly || pos > 53 || pos < -53) {
773 bool changed =
false;
776 for (
int i = 0; i < 7; ++i) {
786 rrule->setByDays(positions);
794 if (d->mRecurReadOnly || pos > 53 || pos < -53) {
807 setMonthlyPos(positions);
813 if (d->mRecurReadOnly) {
825 if (monthlyDays != rrule->byDays()) {
826 rrule->setByDays(monthlyDays);
833 if (d->mRecurReadOnly || day > 31 || day < -31) {
849void Recurrence::setMonthlyDate(
const QList<int> &monthlyDays)
851 if (d->mRecurReadOnly) {
863 sortAndRemoveDuplicates(mD);
864 sortAndRemoveDuplicates(rbD);
867 rrule->setByMonthDays(monthlyDays);
874 if (setNewRecurrenceType(RecurrenceRule::rYearly, freq)) {
888 if (!
days.contains(day)) {
894void Recurrence::setYearlyDay(
const QList<int> &days)
904 sortAndRemoveDuplicates(d);
905 sortAndRemoveDuplicates(bYD);
908 rrule->setByYearDays(
days);
919void Recurrence::setYearlyDate(
const QList<int> &dates)
921 setMonthlyDate(dates);
938 if (d->mRecurReadOnly || month < 1 || month > 12) {
950 setYearlyMonth(months);
954void Recurrence::setYearlyMonth(
const QList<int> &months)
956 if (d->mRecurReadOnly) {
968 sortAndRemoveDuplicates(m);
969 sortAndRemoveDuplicates(bM);
972 rrule->setByMonths(months);
985 if (std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), date)) {
992 for (i = 0, end = d->mExRules.count(); i < end; ++i) {
993 if (d->mExRules[i]->recursOn(date, timeZone)) {
1000 if (dt.
date() == date) {
1004 bool foundDate =
false;
1005 for (i = 0, end = d->mRDateTimes.count(); i < end; ++i) {
1007 if (dt.
date() == date) {
1010 }
else if (foundDate) {
1014 for (i = 0, end = d->mRRules.count(); i < end; ++i) {
1015 times += d->mRRules[i]->recurTimesOn(date, timeZone);
1017 sortAndRemoveDuplicates(times);
1021 for (i = 0, end = d->mExDateTimes.count(); i < end; ++i) {
1022 dt = d->mExDateTimes[i].
toTimeZone(timeZone);
1023 if (dt.
date() == date) {
1024 extimes << dt.
time();
1026 }
else if (foundDate) {
1031 for (i = 0, end = d->mExRules.count(); i < end; ++i) {
1032 extimes += d->mExRules[i]->recurTimesOn(date, timeZone);
1035 sortAndRemoveDuplicates(extimes);
1036 inplaceSetDifference(times, extimes);
1045 for (i = 0, count = d->mRRules.count(); i < count; ++i) {
1046 times += d->mRRules[i]->timesInInterval(
start, end);
1050 for (i = 0, count = d->mRDateTimes.count(); i < count; ++i) {
1051 if (d->mRDateTimes[i] >=
start && d->mRDateTimes[i] <= end) {
1052 times += d->mRDateTimes[i];
1058 for (i = 0, count = d->mRDates.count(); i < count; ++i) {
1060 if (kdt >=
start && kdt <= end) {
1070 if ((!d->mRDates.isEmpty() || !d->mRDateTimes.isEmpty()) && d->mRRules.isEmpty() &&
start <= d->mStartDateTime && end >= d->mStartDateTime) {
1071 times += d->mStartDateTime;
1074 sortAndRemoveDuplicates(times);
1078 int enddt = times.
count();
1079 for (i = 0, count = d->mExDates.count(); i < count && idt < enddt; ++i) {
1080 while (idt < enddt && times[idt].date() < d->mExDates[i]) {
1083 while (idt < enddt && times[idt].date() == d->mExDates[i]) {
1089 for (i = 0, count = d->mExRules.count(); i < count; ++i) {
1090 extimes += d->mExRules[i]->timesInInterval(
start, end);
1092 extimes += d->mExDateTimes;
1093 sortAndRemoveDuplicates(extimes);
1094 inplaceSetDifference(times, extimes);
1107 while (loop < 1000) {
1126 const auto it = std::upper_bound(d->mRDateTimes.constBegin(), d->mRDateTimes.constEnd(), nextDT);
1127 if (it != d->mRDateTimes.constEnd()) {
1132 for (
const auto &date : std::as_const(d->mRDates)) {
1141 for (
const auto &rule : std::as_const(d->mRRules)) {
1142 QDateTime dt = rule->getNextDate(nextDT);
1149 sortAndRemoveDuplicates(dates);
1153 nextDT = dates.
first();
1156 if (!std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), nextDT.
date())
1157 && !std::binary_search(d->mExDateTimes.constBegin(), d->mExDateTimes.constEnd(), nextDT)) {
1158 bool allowed =
true;
1159 for (
const auto &rule : std::as_const(d->mExRules)) {
1160 allowed = allowed && !rule->recursAt(nextDT);
1179 while (loop < 1000) {
1196 const auto it = strictLowerBound(d->mRDateTimes.constBegin(), d->mRDateTimes.constEnd(), prevDT);
1197 if (it != d->mRDateTimes.constEnd()) {
1202 for (
const auto &date : std::as_const(d->mRDates)) {
1211 for (
const auto &rule : std::as_const(d->mRRules)) {
1212 QDateTime dt = rule->getPreviousDate(prevDT);
1219 sortAndRemoveDuplicates(dates);
1223 prevDT = dates.
last();
1226 if (!std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), prevDT.
date())
1227 && !std::binary_search(d->mExDateTimes.constBegin(), d->mExDateTimes.constEnd(), prevDT)) {
1228 bool allowed =
true;
1229 for (
const auto &rule : std::as_const(d->mExRules)) {
1230 allowed = allowed && !rule->recursAt(prevDT);
1251 if (d->mRecurReadOnly || !rrule) {
1256 d->mRRules.append(rrule);
1263 if (d->mRecurReadOnly) {
1267 d->mRRules.removeAll(rrule);
1274 if (d->mRecurReadOnly) {
1278 d->mRRules.removeAll(rrule);
1290 if (d->mRecurReadOnly || !exrule) {
1295 d->mExRules.append(exrule);
1302 if (d->mRecurReadOnly) {
1306 d->mExRules.removeAll(exrule);
1313 if (d->mRecurReadOnly) {
1317 d->mExRules.removeAll(exrule);
1324 return d->mRDateTimes;
1329 if (d->mRecurReadOnly) {
1333 d->mRDateTimes = rdates;
1334 sortAndRemoveDuplicates(d->mRDateTimes);
1335 d->mRDateTimePeriods.clear();
1339void Recurrence::addRDateTime(
const QDateTime &rdate)
1341 if (d->mRecurReadOnly) {
1345 setInsert(d->mRDateTimes, rdate);
1351 if (d->mRecurReadOnly) {
1355 setInsert(d->mRDateTimes, period.
start());
1356 d->mRDateTimePeriods.insert(period.
start(), period);
1362 return d->mRDateTimePeriods.value(rdate);
1370void Recurrence::setRDates(
const DateList &rdates)
1372 if (d->mRecurReadOnly) {
1376 d->mRDates = rdates;
1377 sortAndRemoveDuplicates(d->mRDates);
1381void Recurrence::addRDate(
const QDate &rdate)
1383 if (d->mRecurReadOnly) {
1387 setInsert(d->mRDates, rdate);
1393 return d->mExDateTimes;
1398 if (d->mRecurReadOnly) {
1402 d->mExDateTimes = exdates;
1403 sortAndRemoveDuplicates(d->mExDateTimes);
1406void Recurrence::addExDateTime(
const QDateTime &exdate)
1408 if (d->mRecurReadOnly) {
1412 setInsert(d->mExDateTimes, exdate);
1416DateList Recurrence::exDates()
const
1421void Recurrence::setExDates(
const DateList &exdates)
1423 if (d->mRecurReadOnly) {
1428 sortAndRemoveDuplicates(l);
1430 if (d->mExDates != l) {
1436void Recurrence::addExDate(
const QDate &exdate)
1438 if (d->mRecurReadOnly) {
1442 setInsert(d->mExDates, exdate);
1456 int count = d->mRRules.count();
1457 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"RRULEs:";
1458 for (i = 0; i < count; ++i) {
1459 qCDebug(KCALCORE_LOG) <<
" -) RecurrenceRule: ";
1460 d->mRRules[i]->dump();
1462 count = d->mExRules.count();
1463 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"EXRULEs:";
1464 for (i = 0; i < count; ++i) {
1465 qCDebug(KCALCORE_LOG) <<
" -) ExceptionRule :";
1466 d->mExRules[i]->dump();
1469 count = d->mRDates.count();
1470 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"Recurrence Dates:";
1471 for (i = 0; i < count; ++i) {
1472 qCDebug(KCALCORE_LOG) <<
" " << d->mRDates[i];
1474 count = d->mRDateTimes.count();
1475 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"Recurrence Date/Times:";
1476 for (i = 0; i < count; ++i) {
1477 qCDebug(KCALCORE_LOG) <<
" " << d->mRDateTimes[i];
1479 count = d->mExDates.count();
1480 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"Exceptions Dates:";
1481 for (i = 0; i < count; ++i) {
1482 qCDebug(KCALCORE_LOG) <<
" " << d->mExDates[i];
1484 count = d->mExDateTimes.count();
1485 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"Exception Date/Times:";
1486 for (i = 0; i < count; ++i) {
1487 qCDebug(KCALCORE_LOG) <<
" " << d->mExDateTimes[i];
1491Recurrence::RecurrenceObserver::~RecurrenceObserver()
1501 serializeQDateTimeList(out, r->d->mRDateTimes);
1502 out << (qint32)r->d->mRDateTimePeriods.size();
1503 for (
auto it = r->d->mRDateTimePeriods.cbegin(); it != r->d->mRDateTimePeriods.cend(); ++it) {
1504 out << it.key() << it.value();
1506 serializeQDateTimeList(out, r->d->mExDateTimes);
1507 out << r->d->mRDates;
1508 serializeQDateTimeAsKDateTime(out, r->d->mStartDateTime);
1509 out << r->d->mCachedType << r->d->mAllDay << r->d->mRecurReadOnly << r->d->mExDates << (qint32)r->d->mExRules.count() << (qint32)r->d->mRRules.count();
1532 deserializeQDateTimeList(in, r->d->mRDateTimes);
1534 r->d->mRDateTimePeriods.
clear();
1535 r->d->mRDateTimePeriods.reserve(size);
1536 for (
int i = 0; i < size; ++i) {
1539 in >>
start >> period;
1540 r->d->mRDateTimes <<
start;
1541 r->d->mRDateTimePeriods.insert(
start, period);
1543 deserializeQDateTimeList(in, r->d->mExDateTimes);
1544 in >> r->d->mRDates;
1545 deserializeKDateTimeAsQDateTime(in, r->d->mStartDateTime);
1546 in >> r->d->mCachedType >> r->d->mAllDay >> r->d->mRecurReadOnly >> r->d->mExDates >> exruleCount >> rruleCount;
1548 r->d->mExRules.
clear();
1549 r->d->mRRules.
clear();
1551 for (
int i = 0; i < exruleCount; ++i) {
1555 r->d->mExRules.append(rule);
1558 for (
int i = 0; i < rruleCount; ++i) {
1562 r->d->mRRules.append(rule);
The period can be defined by either a start time and an end time or by a start time and a duration.
QDateTime start() const
Returns when this period starts.
structure for describing the n-th weekday of the month/year.
This class represents a recurrence rule for a calendar incidence.
void setAllDay(bool allDay)
Sets whether the dtstart is all-day (i.e.
QDateTime endDt(bool *result=nullptr) const
Returns the date and time of the last recurrence.
void setDuration(int duration)
Sets the total number of times the event is to occur, including both the first and last.
void setFrequency(int freq)
Sets the recurrence frequency, in terms of the recurrence time period type.
void setEndDt(const QDateTime &endDateTime)
Sets the date and time of the last recurrence.
uint frequency() const
Returns the recurrence frequency, in terms of the recurrence time period type.
int duration() const
Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the total number of re...
PeriodType
enum for describing the frequency how an event recurs, if at all.
void setStartDt(const QDateTime &start)
Sets the recurrence start date/time.
int durationTo(const QDateTime &dt) const
Returns the number of recurrences up to and including the date/time specified.
void addObserver(RuleObserver *observer)
Installs an observer.
void removeObserver(RuleObserver *observer)
Removes an observer that was added with addObserver.
This class represents a recurrence rule for a calendar incidence.
ushort recurrenceType() const
Returns the event's recurrence status.
void removeRRule(RecurrenceRule *rrule)
Remove a recurrence rule from the recurrence.
QList< RecurrenceRule::WDayPos > yearPositions() const
Returns the positions within a yearly recurrence.
void setRecurReadOnly(bool readOnly)
Set if recurrence is read-only or can be changed.
QList< int > yearDates() const
Returns the dates within a yearly recurrence.
int frequency() const
Returns frequency of recurrence, in terms of the recurrence time period type.
void addYearlyDay(int day)
Adds day number of year within a yearly recurrence.
void setYearly(int freq)
Sets an event to recur yearly.
void setWeekly(int freq, int weekStart=1)
Sets an event to recur weekly.
Period rDateTimePeriod(const QDateTime &rdate) const
Inquire if the given RDATE is associated to a PERIOD.
bool recurs() const
Returns whether the event recurs at all.
void addRDateTimePeriod(const Period &period)
Add a RDATE defined as a PERIOD.
void setMinutely(int freq)
Sets an event to recur minutely.
void setMonthly(int freq)
Sets an event to recur monthly.
void setFrequency(int freq)
Sets the frequency of recurrence, in terms of the recurrence time period type.
QList< int > monthDays() const
Returns list of day numbers of a month.
void setStartDateTime(const QDateTime &start, bool isAllDay)
Set start of recurrence.
QDateTime getNextDateTime(const QDateTime &preDateTime) const
Returns the start date/time of the earliest recurrence with a start date/time after the specified dat...
void deleteExRule(RecurrenceRule *exrule)
Remove an exception rule from the recurrence and delete it.
void addYearlyMonth(short _rNum)
Adds month in yearly recurrence.
void deleteRRule(RecurrenceRule *rrule)
Remove a recurrence rule from the recurrence and delete it.
bool recurReadOnly() const
Returns true if the recurrence is read-only, or false if it can be changed.
void removeObserver(RecurrenceObserver *observer)
Removes an observer that was added with addObserver.
bool allDay() const
Set whether the recurrence has no time, just a date.
QDate startDate() const
Return the start date/time of the recurrence.
int durationTo(const QDateTime &dt) const
Returns the number of recurrences up to and including the date/time specified.
void addMonthlyPos(short pos, const QBitArray &days)
Adds a position (e.g.
void addObserver(RecurrenceObserver *observer)
Installs an observer.
QDateTime endDateTime() const
Returns the date/time of the last recurrence.
void addYearlyDate(int date)
Adds date within a yearly recurrence.
void setEndDateTime(const QDateTime &endDateTime)
Sets the date and time of the last recurrence.
QList< QDateTime > timesInInterval(const QDateTime &start, const QDateTime &end) const
Returns a list of all the times at which the recurrence will occur between two specified times.
QBitArray days() const
Returns week day mask (bit 0 = Monday).
void removeExRule(RecurrenceRule *exrule)
Remove an exception rule from the recurrence.
void addYearlyPos(short pos, const QBitArray &days)
Adds position within month/year within a yearly recurrence.
void setAllDay(bool allDay)
Sets whether the dtstart is a all-day (i.e.
QDateTime startDateTime() const
Return the start date/time of the recurrence (Time for all-day recurrences will be 0:00).
void addRRule(RecurrenceRule *rrule)
Add a recurrence rule to the recurrence.
void setDaily(int freq)
Sets an event to recur daily.
void unsetRecurs()
Removes all recurrence rules.
void dump() const
Debug output.
void addExRule(RecurrenceRule *exrule)
Add an exception rule to the recurrence.
void setEndDate(const QDate &endDate)
Sets the date of the last recurrence.
int weekStart() const
Returns the first day of the week.
QList< int > yearMonths() const
Returns the months within a yearly recurrence.
int duration() const
Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the total number of re...
void setHourly(int freq)
Sets an event to recur hourly.
void clear()
Removes all recurrence and exception rules and dates.
bool recursOn(const QDate &date, const QTimeZone &timeZone) const
Returns true if the date specified is one on which the event will recur.
void addMonthlyDate(short day)
Adds a date (e.g.
QDateTime getPreviousDateTime(const QDateTime &afterDateTime) const
Returns the date and time of the last previous recurrence, before the specified date/time.
bool recursAt(const QDateTime &dt) const
Returns true if the date/time specified is one at which the event will recur.
QList< int > yearDays() const
Returns the day numbers within a yearly recurrence.
bool operator==(const Recurrence &r) const
Comparison operator for equality.
void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone)
Shift the times of the recurrence so that they appear at the same clock time as before but in a new t...
void addWeeklyDays(const QBitArray &days)
Adds days to the weekly day recurrence list.
QList< RecurrenceRule::WDayPos > monthPositions() const
Returns list of day positions in months.
QDate endDate() const
Returns the date of the last recurrence.
void setDuration(int duration)
Sets the total number of times the event is to occur, including both the first and last.
TimeList recurTimesOn(const QDate &date, const QTimeZone &timeZone) const
Returns a list of the times on the specified date at which the recurrence will occur.
~Recurrence() override
Destructor.
Recurrence()
Constructs an empty recurrence.
Q_SCRIPTABLE Q_NOREPLY void start()
This file is part of the API for handling calendar data and defines the IncidenceBase class.
Namespace for all KCalendarCore types.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
KCALENDARCORE_EXPORT bool identical(const QDateTime &dt1, const QDateTime &dt2)
Compare two QDateTimes for extended equality.
const QList< QKeySequence > & end()
bool operator==(const StyleDelim &l, const StyleDelim &r)
bool fill(bool value, qsizetype size)
bool testBit(qsizetype i) const const
bool isValid() const const
QDateTime toTimeZone(const QTimeZone &timeZone) const const
iterator find(const Key &key)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
bool contains(const AT &value) const const
qsizetype count() const const
bool isEmpty() const const
void removeAt(qsizetype i)
qsizetype size() const const