Commit 4a74c17b authored by Glen Ditchfield's avatar Glen Ditchfield 🐛
Browse files

Fix corner cases in the Agenda and Month views

 * If an incidence starts and also ends or is due at 00:00 of a day, the
   month view displayed it as a thin rectangle on the border between days.
 * Events that begin and end at 00:00 of the same day were displayed in
   the agenda across the whole day, as if they had 24-hour duration.
 * One-day events starting after 23:52:30 and ending at or before midnight
   were displayed below the bottom of the agenda.
parent 1c9c5afa
Pipeline #65111 skipped
......@@ -1763,6 +1763,10 @@ AgendaItem::QPtr Agenda::insertItem(const KCalendarCore::Incidence::Ptr &inciden
return AgendaItem::QPtr();
}
if (YTop >= d->mRows) {
YBottom -= YTop - (d->mRows - 1); // Slide the item up into view.
YTop = d->mRows - 1;
}
if (YBottom <= YTop) {
qCDebug(CALENDARVIEW_LOG) << "Text:" << agendaItem->text() << " YSize<0";
YBottom = YTop;
......
......@@ -563,9 +563,10 @@ void AgendaView::Private::insertIncidence(const KCalendarCore::Incidence::Ptr &i
if (event) {
const QDate firstVisibleDate = mSelectedDates.first();
QDateTime dtEnd = event->dtEnd().toLocalTime();
if (!event->allDay()) {
// If dtEnd's time portion is 00:00, the event ends on the previous day.
dtEnd = dtEnd.addSecs(-1);
if (!event->allDay() && dtEnd > event->dtStart()) {
// If dtEnd's time portion is 00:00:00, the event ends on the previous day
// unless it also starts at 00:00:00 (a duration of 0).
dtEnd = dtEnd.addMSecs(-1);
}
const int duration = event->dtStart().toLocalTime().daysTo(dtEnd);
if (insertAtDate < firstVisibleDate) {
......@@ -643,8 +644,10 @@ void AgendaView::Private::insertIncidence(const KCalendarCore::Incidence::Ptr &i
QTime endTime = startTime.addSecs(durationOfFirstOccurrence);
startY = mAgenda->timeToY(startTime);
if (endTime == QTime(0, 0, 0)) {
endTime = QTime(23, 59, 59);
if (durationOfFirstOccurrence != 0 && endTime == QTime(0, 0, 0)) {
// If endTime is 00:00:00, the event ends on the previous day
// unless it also starts at 00:00:00 (a duration of 0).
endTime = endTime.addMSecs(-1);
}
endY = mAgenda->timeToY(endTime) - 1;
}
......
......@@ -359,9 +359,10 @@ QDate IncidenceMonthItem::realEndDate() const
}
QDateTime dt = mIncidence->dateTime(KCalendarCore::Incidence::RoleDisplayEnd);
if (!mIncidence->allDay()) {
// If dt's time portion is 00:00, the incidence ends on the previous day.
dt = dt.addSecs(-1);
if (!mIncidence->allDay() && dt > mIncidence->dateTime(KCalendarCore::Incidence::RoleDisplayStart)) {
// If dt's time portion is 00:00:00, the incidence ends on the previous day
// unless it also starts at 00:00:00 (a duration of 0).
dt = dt.addMSecs(-1);
}
const QDate end = dt.toLocalTime().date();
......
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