Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a0de1e80 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Adapt to KCalCore recurrence API changes

parent 9f96bbdb
......@@ -187,11 +187,11 @@ bool ListView::Private::ListItemVisitor::visit(const Event::Ptr &e)
mItem->end = e->dtEnd().toLocalZone().dateTime();
if (e->recurs()) {
const int duration = e->dtStart().secsTo(e->dtEnd());
KDateTime kdt(mStartDate, QTime(0,0,0));
QDateTime kdt(mStartDate, QTime(0,0,0));
kdt = kdt.addSecs(-1);
mItem->start = e->recurrence()->getNextDateTime(kdt).toLocalZone().dateTime();
mItem->start = e->recurrence()->getNextDateTime(kdt).toLocalTime();
mItem->end = mItem->start.addSecs(duration);
next = e->recurrence()->getNextDateTime(KDateTime(mItem->start)).toLocalZone().dateTime();
next = e->recurrence()->getNextDateTime(mItem->start).toLocalTime();
}
mItem->setText(Summary_Column, cleanSummary(e->summary(), next));
......
......@@ -487,7 +487,7 @@ QString IncidenceMonthItem::text(bool end) const
QTime time;
if (mIncidence->recurs()) {
const auto start = mIncidence->dtStart().addDays(mRecurDayOffset).addSecs(-1);
time = mIncidence->recurrence()->getNextDateTime(start).toLocalZone().time();
time = mIncidence->recurrence()->getNextDateTime(KCalCore::k2q(start)).toLocalTime().time();
} else {
time = mIncidence->dtStart().toLocalZone().time();
}
......
......@@ -30,6 +30,8 @@
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
#include <KCalCore/Utils>
#include <QBoxLayout>
#include <QPainter>
#include <QPaintEvent>
......@@ -107,10 +109,11 @@ public:
// timesInInterval only return events that have their start inside the interval
// so we resize the interval by -eventDuration
KCalCore::DateTimeList times = e->recurrence()->timesInInterval(
selectedStart.addSecs(-eventDuration), selectedEnd);
const auto times = e->recurrence()->timesInInterval(
KCalCore::k2q(selectedStart).addSecs(-eventDuration), KCalCore::k2q(selectedEnd));
foreach (const KDateTime &kdt, times) {
foreach (const QDateTime &dt, times) {
const auto kdt = KCalCore::q2k(dt);
// either the event's start or the event's end must be in the view's interval
if (kdt >= selectedStart ||
kdt.addSecs(eventDuration) >= selectedStart) {
......
......@@ -29,6 +29,7 @@
#include <CalendarSupport/Utils>
#include <KCalUtils/IncidenceFormatter>
#include <KCalCore/Utils>
#include <KIconLoader>
......@@ -127,24 +128,24 @@ void WhatsNextView::updateView()
} else {
KCalCore::Recurrence *recur = ev->recurrence();
int duration = ev->dtStart().secsTo(ev->dtEnd());
KDateTime start = recur->getPreviousDateTime(KDateTime(mStartDate, QTime(), KDateTime::LocalZone));
KDateTime start = KCalCore::q2k(recur->getPreviousDateTime(QDateTime(mStartDate, QTime(), Qt::LocalTime)));
KDateTime end = start.addSecs(duration);
KDateTime endDate(mEndDate, QTime(23, 59, 59), KDateTime::LocalZone);
if (end.date() >= mStartDate) {
appendEvent(ev, start.toLocalZone().dateTime(), end.toLocalZone().dateTime());
}
KCalCore::DateTimeList times = recur->timesInInterval(start, endDate);
const auto times = recur->timesInInterval(KCalCore::k2q(start), KCalCore::k2q(endDate));
int count = times.count();
if (count > 0) {
int i = 0;
if (times[0] == start) {
if (times[0] == KCalCore::k2q(start)) {
++i; // start has already been appended
}
if (!times[count - 1].isValid()) {
--count; // list overflow
}
for (; i < count && times[i].date() <= mEndDate; ++i) {
appendEvent(ev, times[i].toLocalZone().dateTime());
appendEvent(ev, times[i].toLocalTime());
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment