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)
53 RecurrenceRule::List mExRules;
54 RecurrenceRule::List mRRules;
55 QList<QDateTime> mRDateTimes;
56 QHash<QDateTime, Period> mRDateTimePeriods;
58 QList<QDateTime> mExDateTimes;
60 QDateTime mStartDateTime;
61 QList<RecurrenceObserver *> mObservers;
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 if (periodIt != oldPeriods.
end()) {
517 periodIt->shiftTimes(oldTz, newTz);
518 rDt = rDt.toTimeZone(oldTz);
519 rDt.setTimeZone(newTz);
521 d->mRDateTimePeriods.insert(rDt, *periodIt);
525 for (
auto &exDt : d->mExDateTimes) {
526 exDt = exDt.toTimeZone(oldTz);
527 exDt.setTimeZone(newTz);
530 for (
auto &rr : d->mRRules) {
531 rr->shiftTimes(oldTz, newTz);
534 for (
auto exR : d->mExRules) {
535 exR->shiftTimes(oldTz, newTz);
541 if (d->mRecurReadOnly) {
544 qDeleteAll(d->mRRules);
551 if (d->mRecurReadOnly) {
554 qDeleteAll(d->mRRules);
556 qDeleteAll(d->mExRules);
559 d->mRDateTimes.clear();
560 d->mRDateTimePeriods.clear();
562 d->mExDateTimes.clear();
563 d->mCachedType = rMax;
569 d->mRecurReadOnly = readOnly;
574 return d->mRecurReadOnly;
579 return d->mStartDateTime.date();
584 if (d->mRecurReadOnly) {
587 d->mStartDateTime =
start;
592 for (i = 0, end = d->mRRules.count(); i < end; ++i) {
593 d->mRRules[i]->setStartDt(
start);
595 for (i = 0, end = d->mExRules.count(); i < end; ++i) {
596 d->mExRules[i]->setStartDt(
start);
611 if (d->mRecurReadOnly || freq <= 0) {
627 return rrule ? rrule->weekStart() : 1;
638 for (
int i = 0; i < bydays.
size(); ++i) {
639 if (bydays.
at(i).pos() == 0) {
640 days.setBit(bydays.
at(i).day() - 1);
654 return rrule->byMonthDays();
672 return rrule ? rrule->byYearDays() :
QList<int>();
683 return rrule ? rrule->byMonths() :
QList<int>();
693 if (d->mRecurReadOnly || freq <= 0) {
702 qDeleteAll(d->mRRules);
705 RecurrenceRule *rrule = defaultRRule(
true);
709 rrule->setRecurrenceType(type);
717 if (setNewRecurrenceType(RecurrenceRule::rMinutely, _rFreq)) {
724 if (setNewRecurrenceType(RecurrenceRule::rHourly, _rFreq)) {
731 if (setNewRecurrenceType(RecurrenceRule::rDaily, _rFreq)) {
738 RecurrenceRule *rrule = setNewRecurrenceType(RecurrenceRule::rWeekly, freq);
759 if (setNewRecurrenceType(RecurrenceRule::rMonthly, freq)) {
767 if (d->mRecurReadOnly || pos > 53 || pos < -53) {
775 bool changed =
false;
778 for (
int i = 0; i < 7; ++i) {
779 if (
days.testBit(i)) {
788 rrule->setByDays(positions);
796 if (d->mRecurReadOnly || pos > 53 || pos < -53) {
804 QList<RecurrenceRule::WDayPos> positions = rrule->byDays();
806 RecurrenceRule::WDayPos p(pos, day);
809 setMonthlyPos(positions);
813void Recurrence::setMonthlyPos(
const QList<RecurrenceRule::WDayPos> &monthlyDays)
815 if (d->mRecurReadOnly) {
819 RecurrenceRule *rrule = defaultRRule(
true);
827 if (monthlyDays != rrule->byDays()) {
828 rrule->setByDays(monthlyDays);
835 if (d->mRecurReadOnly || day > 31 || day < -31) {
851void Recurrence::setMonthlyDate(
const QList<int> &monthlyDays)
853 if (d->mRecurReadOnly) {
862 QList<int> mD(monthlyDays);
863 QList<int> rbD(rrule->byMonthDays());
865 sortAndRemoveDuplicates(mD);
866 sortAndRemoveDuplicates(rbD);
869 rrule->setByMonthDays(monthlyDays);
876 if (setNewRecurrenceType(RecurrenceRule::rYearly, freq)) {
890 if (!
days.contains(day)) {
896void Recurrence::setYearlyDay(
const QList<int> &days)
906 sortAndRemoveDuplicates(d);
907 sortAndRemoveDuplicates(bYD);
910 rrule->setByYearDays(
days);
921void Recurrence::setYearlyDate(
const QList<int> &dates)
923 setMonthlyDate(dates);
940 if (d->mRecurReadOnly || month < 1 || month > 12) {
952 setYearlyMonth(months);
956void Recurrence::setYearlyMonth(
const QList<int> &months)
958 if (d->mRecurReadOnly) {
967 QList<int> m(months);
968 QList<int> bM(rrule->byMonths());
970 sortAndRemoveDuplicates(m);
971 sortAndRemoveDuplicates(bM);
974 rrule->setByMonths(months);
987 if (std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), date)) {
994 for (i = 0, end = d->mExRules.count(); i < end; ++i) {
995 if (d->mExRules[i]->recursOn(date, timeZone)) {
1002 if (dt.
date() == date) {
1006 bool foundDate =
false;
1007 for (i = 0, end = d->mRDateTimes.count(); i < end; ++i) {
1009 if (dt.
date() == date) {
1012 }
else if (foundDate) {
1016 for (i = 0, end = d->mRRules.count(); i < end; ++i) {
1017 times += d->mRRules[i]->recurTimesOn(date, timeZone);
1019 sortAndRemoveDuplicates(times);
1023 for (i = 0, end = d->mExDateTimes.count(); i < end; ++i) {
1024 dt = d->mExDateTimes[i].
toTimeZone(timeZone);
1025 if (dt.
date() == date) {
1026 extimes << dt.
time();
1028 }
else if (foundDate) {
1033 for (i = 0, end = d->mExRules.count(); i < end; ++i) {
1034 extimes += d->mExRules[i]->recurTimesOn(date, timeZone);
1037 sortAndRemoveDuplicates(extimes);
1038 inplaceSetDifference(times, extimes);
1047 for (i = 0, count = d->mRRules.count(); i < count; ++i) {
1048 times += d->mRRules[i]->timesInInterval(
start, end);
1052 for (i = 0, count = d->mRDateTimes.count(); i < count; ++i) {
1053 if (d->mRDateTimes[i] >=
start && d->mRDateTimes[i] <= end) {
1054 times += d->mRDateTimes[i];
1060 for (i = 0, count = d->mRDates.count(); i < count; ++i) {
1062 if (kdt >=
start && kdt <= end) {
1072 if ((!d->mRDates.isEmpty() || !d->mRDateTimes.isEmpty()) && d->mRRules.isEmpty() &&
start <= d->mStartDateTime && end >= d->mStartDateTime) {
1073 times += d->mStartDateTime;
1076 sortAndRemoveDuplicates(times);
1080 int enddt = times.
count();
1081 for (i = 0, count = d->mExDates.count(); i < count && idt < enddt; ++i) {
1082 while (idt < enddt && times[idt].date() < d->mExDates[i]) {
1085 while (idt < enddt && times[idt].date() == d->mExDates[i]) {
1091 for (i = 0, count = d->mExRules.count(); i < count; ++i) {
1092 extimes += d->mExRules[i]->timesInInterval(
start, end);
1094 extimes += d->mExDateTimes;
1095 sortAndRemoveDuplicates(extimes);
1096 inplaceSetDifference(times, extimes);
1109 while (loop < 1000) {
1128 const auto it = std::upper_bound(d->mRDateTimes.constBegin(), d->mRDateTimes.constEnd(), nextDT);
1129 if (it != d->mRDateTimes.constEnd()) {
1134 for (
const auto &date : std::as_const(d->mRDates)) {
1143 for (
const auto &rule : std::as_const(d->mRRules)) {
1144 QDateTime dt = rule->getNextDate(nextDT);
1151 sortAndRemoveDuplicates(dates);
1155 nextDT = dates.
first();
1158 if (!std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), nextDT.
date())
1159 && !std::binary_search(d->mExDateTimes.constBegin(), d->mExDateTimes.constEnd(), nextDT)) {
1160 bool allowed =
true;
1161 for (
const auto &rule : std::as_const(d->mExRules)) {
1162 allowed = allowed && !rule->recursAt(nextDT);
1181 while (loop < 1000) {
1198 const auto it = strictLowerBound(d->mRDateTimes.constBegin(), d->mRDateTimes.constEnd(), prevDT);
1199 if (it != d->mRDateTimes.constEnd()) {
1204 for (
const auto &date : std::as_const(d->mRDates)) {
1213 for (
const auto &rule : std::as_const(d->mRRules)) {
1214 QDateTime dt = rule->getPreviousDate(prevDT);
1221 sortAndRemoveDuplicates(dates);
1225 prevDT = dates.
last();
1228 if (!std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), prevDT.
date())
1229 && !std::binary_search(d->mExDateTimes.constBegin(), d->mExDateTimes.constEnd(), prevDT)) {
1230 bool allowed =
true;
1231 for (
const auto &rule : std::as_const(d->mExRules)) {
1232 allowed = allowed && !rule->recursAt(prevDT);
1246RecurrenceRule::List Recurrence::rRules()
const
1253 if (d->mRecurReadOnly || !rrule) {
1258 d->mRRules.append(rrule);
1265 if (d->mRecurReadOnly) {
1269 d->mRRules.removeAll(rrule);
1276 if (d->mRecurReadOnly) {
1280 d->mRRules.removeAll(rrule);
1285RecurrenceRule::List Recurrence::exRules()
const
1292 if (d->mRecurReadOnly || !exrule) {
1297 d->mExRules.append(exrule);
1304 if (d->mRecurReadOnly) {
1308 d->mExRules.removeAll(exrule);
1315 if (d->mRecurReadOnly) {
1319 d->mExRules.removeAll(exrule);
1326 return d->mRDateTimes;
1331 if (d->mRecurReadOnly) {
1335 d->mRDateTimes = rdates;
1336 sortAndRemoveDuplicates(d->mRDateTimes);
1337 d->mRDateTimePeriods.clear();
1341void Recurrence::addRDateTime(
const QDateTime &rdate)
1343 if (d->mRecurReadOnly) {
1347 setInsert(d->mRDateTimes, rdate);
1353 if (d->mRecurReadOnly) {
1357 setInsert(d->mRDateTimes, period.
start());
1358 d->mRDateTimePeriods.insert(period.
start(), period);
1364 return d->mRDateTimePeriods.value(rdate);
1372void Recurrence::setRDates(
const DateList &rdates)
1374 if (d->mRecurReadOnly) {
1378 d->mRDates = rdates;
1379 sortAndRemoveDuplicates(d->mRDates);
1383void Recurrence::addRDate(
const QDate &rdate)
1385 if (d->mRecurReadOnly) {
1389 setInsert(d->mRDates, rdate);
1393QList<QDateTime> Recurrence::exDateTimes()
const
1395 return d->mExDateTimes;
1398void Recurrence::setExDateTimes(
const QList<QDateTime> &exdates)
1400 if (d->mRecurReadOnly) {
1404 d->mExDateTimes = exdates;
1405 sortAndRemoveDuplicates(d->mExDateTimes);
1408void Recurrence::addExDateTime(
const QDateTime &exdate)
1410 if (d->mRecurReadOnly) {
1414 setInsert(d->mExDateTimes, exdate);
1418DateList Recurrence::exDates()
const
1423void Recurrence::setExDates(
const DateList &exdates)
1425 if (d->mRecurReadOnly) {
1430 sortAndRemoveDuplicates(l);
1432 if (d->mExDates != l) {
1438void Recurrence::addExDate(
const QDate &exdate)
1440 if (d->mRecurReadOnly) {
1444 setInsert(d->mExDates, exdate);
1458 int count = d->mRRules.count();
1459 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"RRULEs:";
1460 for (i = 0; i < count; ++i) {
1461 qCDebug(KCALCORE_LOG) <<
" -) RecurrenceRule: ";
1462 d->mRRules[i]->dump();
1464 count = d->mExRules.count();
1465 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"EXRULEs:";
1466 for (i = 0; i < count; ++i) {
1467 qCDebug(KCALCORE_LOG) <<
" -) ExceptionRule :";
1468 d->mExRules[i]->dump();
1471 count = d->mRDates.count();
1472 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"Recurrence Dates:";
1473 for (i = 0; i < count; ++i) {
1474 qCDebug(KCALCORE_LOG) <<
" " << d->mRDates[i];
1476 count = d->mRDateTimes.count();
1477 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"Recurrence Date/Times:";
1478 for (i = 0; i < count; ++i) {
1479 qCDebug(KCALCORE_LOG) <<
" " << d->mRDateTimes[i];
1481 count = d->mExDates.count();
1482 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"Exceptions Dates:";
1483 for (i = 0; i < count; ++i) {
1484 qCDebug(KCALCORE_LOG) <<
" " << d->mExDates[i];
1486 count = d->mExDateTimes.count();
1487 qCDebug(KCALCORE_LOG) <<
" -)" << count <<
"Exception Date/Times:";
1488 for (i = 0; i < count; ++i) {
1489 qCDebug(KCALCORE_LOG) <<
" " << d->mExDateTimes[i];
1493Recurrence::RecurrenceObserver::~RecurrenceObserver()
1503 serializeQDateTimeList(out, r->d->mRDateTimes);
1504 out << (qint32)r->d->mRDateTimePeriods.size();
1505 for (
auto it = r->d->mRDateTimePeriods.cbegin(); it != r->d->mRDateTimePeriods.cend(); ++it) {
1506 out << it.key() << it.value();
1508 serializeQDateTimeList(out, r->d->mExDateTimes);
1509 out << r->d->mRDates;
1510 serializeQDateTimeAsKDateTime(out, r->d->mStartDateTime);
1511 out << r->d->mCachedType << r->d->mAllDay << r->d->mRecurReadOnly << r->d->mExDates << (qint32)r->d->mExRules.count() << (qint32)r->d->mRRules.count();
1534 deserializeQDateTimeList(in, r->d->mRDateTimes);
1536 r->d->mRDateTimePeriods.
clear();
1537 r->d->mRDateTimePeriods.reserve(size);
1538 for (
int i = 0; i < size; ++i) {
1541 in >>
start >> period;
1542 r->d->mRDateTimes <<
start;
1543 r->d->mRDateTimePeriods.insert(
start, period);
1545 deserializeQDateTimeList(in, r->d->mExDateTimes);
1546 in >> r->d->mRDates;
1547 deserializeKDateTimeAsQDateTime(in, r->d->mStartDateTime);
1548 in >> r->d->mCachedType >> r->d->mAllDay >> r->d->mRecurReadOnly >> r->d->mExDates >> exruleCount >> rruleCount;
1550 r->d->mExRules.
clear();
1551 r->d->mRRules.
clear();
1553 for (
int i = 0; i < exruleCount; ++i) {
1554 RecurrenceRule *rule =
new RecurrenceRule();
1557 r->d->mExRules.append(rule);
1560 for (
int i = 0; i < rruleCount; ++i) {
1561 RecurrenceRule *rule =
new RecurrenceRule();
1564 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 QString start(QString train="")
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.
QList< QDate > DateList
List of dates.
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.
KIOCORE_EXPORT bool operator==(const UDSEntry &entry, const UDSEntry &other)
const QList< QKeySequence > & end()
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