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 87ae75bf authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Adapt to KCalCore API changes

parent 11632007
......@@ -43,11 +43,15 @@ find_package(KF5Akonadi ${AKONADI_LIB_VERSION} CONFIG REQUIRED)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets UiTools)
find_package(KF5I18n ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5Codecs ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5LibkdepimAkonadi ${LIBKDEPIM_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5GuiAddons ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5IconThemes ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5Service ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5Completion ${KF5_VERSION} CONFIG REQUIRED)
set(KDIAGRAM_LIB_VERSION "1.4.0")
find_package(KGantt ${KDIAGRAM_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5LibkdepimAkonadi ${LIBKDEPIM_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarSupport ${CALENDARSUPPORT_LIB_VERSION} CONFIG REQUIRED)
......
......@@ -93,6 +93,11 @@ PUBLIC
KF5::CalendarUtils
KF5::AkonadiCalendar
PRIVATE
KF5::Completion
KF5::Service
KF5::IconThemes
KF5::GuiAddons
KF5::I18n
KF5::LibkdepimAkonadi
KF5::Codecs
KGantt
......
......@@ -78,7 +78,7 @@ public:
Agenda *mAgenda = nullptr;
QTimer *mTimer = nullptr;
QLabel *mTimeBox = nullptr; // Label showing the current time
KDateTime mOldDateTime;
QDateTime mOldDateTime;
int mOldTodayCol;
};
......@@ -125,7 +125,7 @@ void MarcusBains::updateLocationRecalc(bool recalculate)
const bool showSeconds = d->mEventView->preferences()->marcusBainsShowSeconds();
const QColor color = d->mEventView->preferences()->agendaMarcusBainsLineLineColor();
const KDateTime now = KDateTime::currentLocalDateTime();
const QDateTime now = QDateTime::currentDateTimeUtc();
const QTime time = now.time();
if (now.date() != d->mOldDateTime.date()) {
......
......@@ -834,7 +834,7 @@ void AgendaItem::paintEvent(QPaintEvent *ev)
!mEventView->preferences()->todosUseCategoryColors()) {
Todo::Ptr todo = CalendarSupport::todo(mIncidence);
Q_ASSERT(todo);
const QDate dueDate = todo->dtDue().toLocalZone().date();
const QDate dueDate = todo->dtDue().toLocalTime().date();
const QDate today = QDate::currentDate();
const QDate occurrenceDate = this->occurrenceDate();
if (todo->isOverdue() && today >= occurrenceDate) {
......@@ -921,20 +921,20 @@ void AgendaItem::paintEvent(QPaintEvent *ev)
QString shortH;
QString longH;
if (!isMultiItem()) {
shortH = QLocale().toString(mIncidence->dateTime(KCalCore::Incidence::RoleDisplayStart).toLocalZone().time(), QLocale::ShortFormat);
shortH = QLocale().toString(mIncidence->dateTime(KCalCore::Incidence::RoleDisplayStart).toLocalTime().time(), QLocale::ShortFormat);
if (CalendarSupport::hasEvent(mIncidence)) {
longH = i18n("%1 - %2",
shortH,
QLocale().toString(mIncidence->dateTime(KCalCore::Incidence::RoleEnd).toLocalZone().time(), QLocale::ShortFormat));
QLocale().toString(mIncidence->dateTime(KCalCore::Incidence::RoleEnd).toLocalTime().time(), QLocale::ShortFormat));
} else {
longH = shortH;
}
} else if (!mMultiItemInfo->mFirstMultiItem) {
shortH = QLocale().toString(mIncidence->dtStart().toLocalZone().time(), QLocale::ShortFormat);
shortH = QLocale().toString(mIncidence->dtStart().toLocalTime().time(), QLocale::ShortFormat);
longH = shortH;
} else {
shortH = QLocale().toString(mIncidence->dateTime(KCalCore::Incidence::RoleEnd).toLocalZone().time(), QLocale::ShortFormat);
shortH = QLocale().toString(mIncidence->dateTime(KCalCore::Incidence::RoleEnd).toLocalTime().time(), QLocale::ShortFormat);
longH = i18n("- %1", shortH);
}
......@@ -1024,8 +1024,8 @@ void AgendaItem::paintEvent(QPaintEvent *ev)
// multi-day, all-day event
shortH =
i18n("%1 - %2",
QLocale().toString(mIncidence->dtStart().toLocalZone().date()),
QLocale().toString(mIncidence->dateTime(KCalCore::Incidence::RoleEnd).toLocalZone().date()));
QLocale().toString(mIncidence->dtStart().toLocalTime().date()),
QLocale().toString(mIncidence->dateTime(KCalCore::Incidence::RoleEnd).toLocalTime().date()));
longH = shortH;
// paint headline
......
......@@ -45,7 +45,6 @@
#include <KCalCore/CalFilter>
#include <KCalCore/CalFormat>
#include <KCalCore/OccurrenceIterator>
#include <KCalCore/Utils>
#include <KIconLoader> // for SmallIcon()
#include <KMessageBox>
......@@ -301,10 +300,10 @@ private:
bool AgendaView::Private::datesEqual(const KCalCore::Incidence::Ptr &one, const KCalCore::Incidence::Ptr &two) const
{
const auto start1 = one->dtStart().dateTime();
const auto start2 = two->dtStart().dateTime();
const auto end1 = one->dateTime(KCalCore::Incidence::RoleDisplayEnd).dateTime();
const auto end2 = two->dateTime(KCalCore::Incidence::RoleDisplayEnd).dateTime();
const auto start1 = one->dtStart();
const auto start2 = two->dtStart();
const auto end1 = one->dateTime(KCalCore::Incidence::RoleDisplayEnd);
const auto end2 = two->dateTime(KCalCore::Incidence::RoleDisplayEnd);
if (start1.isValid() ^ start2.isValid()) {
return false;
......@@ -573,7 +572,7 @@ void AgendaView::Private::insertIncidence(const KCalCore::Incidence::Ptr &incide
if (event) {
const QDate firstVisibleDate = mSelectedDates.first();
// its crossing bounderies, lets calculate beginX and endX
const int duration = event->dtStart().toLocalZone().daysTo(event->dtEnd());
const int duration = event->dtStart().toLocalTime().daysTo(event->dtEnd());
if (insertAtDate < firstVisibleDate) {
beginX = curCol + firstVisibleDate.daysTo(insertAtDate);
endX = beginX + duration;
......@@ -661,11 +660,11 @@ void AgendaView::Private::insertIncidence(const KCalCore::Incidence::Ptr &incide
QTime t;
if (todo->recurs()) {
// The time we get depends on the insertAtDate, because of daylight savings changes
const KDateTime ocurrrenceDateTime = KDateTime(insertAtDate, todo->dtDue().time(),
todo->dtDue().timeSpec());
t = ocurrrenceDateTime.toLocalZone().time();
const QDateTime ocurrrenceDateTime = QDateTime(insertAtDate, todo->dtDue().time(),
todo->dtDue().timeZone());
t = ocurrrenceDateTime.toLocalTime().time();
} else {
t = todo->dtDue().toLocalZone().time();
t = todo->dtDue().toLocalTime().time();
}
if (t == QTime(0, 0) && !todo->recurs()) {
......@@ -1477,7 +1476,7 @@ void AgendaView::updateEventDates(AgendaItem *item, bool addIncidence,
<< "; item->itemPos(): " << item->itemPos()
<< "; item->itemCount(): " << item->itemCount();
KDateTime startDt, endDt;
QDateTime startDt, endDt;
// Start date of this incidence, calculate the offset from it
// (so recurring and non-recurring items can be treated exactly the same,
......@@ -1543,16 +1542,16 @@ void AgendaView::updateEventDates(AgendaItem *item, bool addIncidence,
startDt = incidence->dtStart();
// convert to calendar timespec because we then manipulate it
// with time coming from the calendar
startDt = startDt.toLocalZone();
startDt = startDt.toLocalTime();
startDt = startDt.addDays(daysOffset);
if (!startDt.isDateOnly()) {
if (!incidence->allDay()) {
startDt.setTime(startTime);
}
endDt = startDt.addDays(daysLength);
if (!endDt.isDateOnly()) {
if (!incidence->allDay()) {
endDt.setTime(endTime);
}
if (incidence->dtStart().toLocalZone() == startDt && ev->dtEnd().toLocalZone() == endDt) {
if (incidence->dtStart().toLocalTime() == startDt && ev->dtEnd().toLocalTime() == endDt) {
// No change
QTimer::singleShot(0, this, SLOT(updateView()));
return;
......@@ -1561,19 +1560,19 @@ void AgendaView::updateEventDates(AgendaItem *item, bool addIncidence,
startDt = td->hasStartDate() ? td->dtStart() : td->dtDue();
// convert to calendar timespec because we then manipulate it with time coming from
// the calendar
startDt = startDt.toLocalZone();
startDt = startDt.toLocalTime();
startDt.setDate(thisDate.addDays(td->dtDue().daysTo(startDt)));
if (!startDt.isDateOnly()) {
if (!td->allDay()) {
startDt.setTime(startTime);
}
endDt = startDt;
endDt.setDate(thisDate);
if (!endDt.isDateOnly()) {
if (!td->allDay()) {
endDt.setTime(endTime);
}
if (td->dtDue().toLocalZone() == endDt) {
if (td->dtDue().toLocalTime() == endDt) {
// No change
QMetaObject::invokeMethod(this, "updateView", Qt::QueuedConnection);
return;
......@@ -1601,7 +1600,7 @@ void AgendaView::updateEventDates(AgendaItem *item, bool addIncidence,
}
if (!incidence->hasRecurrenceId()) {
item->setOccurrenceDateTime(KCalCore::k2q(startDt));
item->setOccurrenceDateTime(startDt);
}
bool result;
......@@ -1701,21 +1700,21 @@ void AgendaView::showIncidences(const Akonadi::Item::List &incidences, const QDa
calendar()->setFilter(nullptr);
}
KDateTime start = CalendarSupport::incidence(incidences.first())->dtStart().toLocalZone();
KDateTime end = CalendarSupport::incidence(incidences.first())->dateTime(KCalCore::Incidence::RoleEnd).toLocalZone();
QDateTime start = CalendarSupport::incidence(incidences.first())->dtStart().toLocalTime();
QDateTime end = CalendarSupport::incidence(incidences.first())->dateTime(KCalCore::Incidence::RoleEnd).toLocalTime();
Akonadi::Item first = incidences.first();
Q_FOREACH (const Akonadi::Item &aitem, incidences) {
if (CalendarSupport::incidence(aitem)->dtStart().toLocalZone() < start) {
if (CalendarSupport::incidence(aitem)->dtStart().toLocalTime() < start) {
first = aitem;
}
start = qMin(start,
CalendarSupport::incidence(aitem)->dtStart().toLocalZone());
CalendarSupport::incidence(aitem)->dtStart().toLocalTime());
end = qMax(start,
CalendarSupport::incidence(aitem)->dateTime(
KCalCore::Incidence::RoleEnd).toLocalZone());
KCalCore::Incidence::RoleEnd).toLocalTime());
}
end.toTimeSpec(start); // allow direct comparison of dates
end.toTimeZone(start.timeZone()); // allow direct comparison of dates
if (start.date().daysTo(end.date()) + 1 <= currentDateCount()) {
showDates(start.date(), end.date());
} else {
......@@ -1823,8 +1822,8 @@ bool AgendaView::displayIncidence(const KCalCore::Incidence::Ptr &incidence, bo
firstVisibleDateTime.setTime(QTime(0, 0));
KCalCore::SortableList<QDateTime> dateTimeList;
const QDateTime incDtStart = KCalCore::k2q(incidence->dtStart().toLocalZone());
const QDateTime incDtEnd = KCalCore::k2q(incidence->dateTime(KCalCore::Incidence::RoleEnd).toLocalZone());
const QDateTime incDtStart = incidence->dtStart().toLocalTime();
const QDateTime incDtEnd = incidence->dateTime(KCalCore::Incidence::RoleEnd).toLocalTime();
bool alreadyAddedToday = false;
......@@ -1865,7 +1864,7 @@ bool AgendaView::displayIncidence(const KCalCore::Incidence::Ptr &incidence, bo
if (todo && todo->hasDueDate() && !todo->isOverdue()) {
// If it's not overdue it will be shown at the original date (not today)
dateToAdd = KCalCore::k2q(todo->dtDue().toLocalZone());
dateToAdd = todo->dtDue().toLocalTime();
// To-dos are drawn with the bottom of the rectangle at dtDue
// if dtDue is at 00:00, then it should be displayed in the previous day, at 23:59
......@@ -2000,9 +1999,8 @@ void AgendaView::slotIncidencesDropped(const KCalCore::Incidence::List &incidenc
const QDate day = d->mSelectedDates[gpos.x()];
const QTime time = d->mAgenda->gyToTime(gpos.y());
KDateTime newTime(day, KDateTime::LocalZone);
newTime.setDateOnly(allDay);
QDateTime newTime(day, {}, Qt::LocalTime);
Q_FOREACH (const KCalCore::Incidence::Ptr &incidence, incidences) {
const Akonadi::Item existingItem = calendar()->item(incidence);
const bool existsInSameCollection = existingItem.isValid() &&
......
......@@ -115,7 +115,7 @@ void EventView::setHolidayRegion(const KHolidays::HolidayRegionPtr &holidayRegio
int EventView::showMoveRecurDialog(const Incidence::Ptr &inc, const QDate &date)
{
QDateTime dateTime(date, QTime(0, 0), Qt::LocalTime);
QDateTime dateTime(date, {}, Qt::LocalTime);
int availableOccurrences = KCalUtils::RecurrenceActions::availableOccurrences(inc, dateTime);
......
......@@ -318,7 +318,7 @@ void JournalFrame::readJournal(const Akonadi::Item &j)
dateFormat.setFontWeight(QFont::Bold);
dateFormat.setFontPointSize(baseFontSize + 1);
cursor.insertText(KCalUtils::IncidenceFormatter::dateTimeToString(
journal->dtStart().dateTime(), journal->allDay()), dateFormat);
journal->dtStart(), journal->allDay()), dateFormat);
cursor.insertBlock();
cursor.insertBlock();
cursor.setBlockCharFormat(bodyFormat);
......
......@@ -99,10 +99,10 @@ bool ListViewItem::operator<(const QTreeWidgetItem &other) const
}
case EndDateTime_Column: {
Incidence::Ptr thisInc = CalendarSupport::incidence(mIncidence);
const auto thisEnd = thisInc->dateTime(Incidence::RoleEnd).toLocalZone().dateTime();
const auto thisEnd = thisInc->dateTime(Incidence::RoleEnd).toLocalTime();
Incidence::Ptr otherInc = CalendarSupport::incidence(otheritem->mIncidence);
const auto otherEnd = otherInc->dateTime(Incidence::RoleEnd).toLocalZone().dateTime();
const auto otherEnd = otherInc->dateTime(Incidence::RoleEnd).toLocalTime();
return otherEnd < thisEnd;
}
......@@ -183,8 +183,8 @@ bool ListView::Private::ListItemVisitor::visit(const Event::Ptr &e)
mItem->setIcon(Summary_Column, eventPxmp);
QDateTime next;
mItem->start = e->dtStart().toLocalZone().dateTime();
mItem->end = e->dtEnd().toLocalZone().dateTime();
mItem->start = e->dtStart().toLocalTime();
mItem->end = e->dtEnd().toLocalTime();
if (e->recurs()) {
const int duration = e->dtStart().secsTo(e->dtEnd());
QDateTime kdt(mStartDate, QTime(0,0,0));
......@@ -217,18 +217,18 @@ bool ListView::Private::ListItemVisitor::visit(const Todo::Ptr &t)
if (t->hasStartDate()) {
if (t->allDay())
mItem->setText(StartDateTime_Column, QLocale().toString(t->dtStart().toLocalZone().date(), QLocale::ShortFormat));
mItem->setText(StartDateTime_Column, QLocale().toString(t->dtStart().toLocalTime().date(), QLocale::ShortFormat));
else
mItem->setText(StartDateTime_Column, QLocale().toString(t->dtStart().toLocalZone().dateTime(), QLocale::ShortFormat));
mItem->setText(StartDateTime_Column, QLocale().toString(t->dtStart().toLocalTime(), QLocale::ShortFormat));
} else {
mItem->setText(StartDateTime_Column, QStringLiteral("---"));
}
if (t->hasDueDate()) {
if (t->allDay())
mItem->setText(EndDateTime_Column, QLocale().toString(t->dtDue().toLocalZone().date(), QLocale::ShortFormat));
mItem->setText(EndDateTime_Column, QLocale().toString(t->dtDue().toLocalTime().date(), QLocale::ShortFormat));
else
mItem->setText(EndDateTime_Column, QLocale().toString(t->dtDue().toLocalZone().dateTime(), QLocale::ShortFormat));
mItem->setText(EndDateTime_Column, QLocale().toString(t->dtDue().toLocalTime(), QLocale::ShortFormat));
} else {
mItem->setText(EndDateTime_Column, QStringLiteral("---"));
}
......@@ -249,9 +249,9 @@ bool ListView::Private::ListItemVisitor::visit(const Journal::Ptr &j)
mItem->setText(Summary_Column, cleanSummary(j->summary(), QDateTime()));
}
if (j->allDay())
mItem->setText(StartDateTime_Column, QLocale().toString(j->dtStart().toLocalZone().date(), QLocale::ShortFormat));
mItem->setText(StartDateTime_Column, QLocale().toString(j->dtStart().toLocalTime().date(), QLocale::ShortFormat));
else
mItem->setText(StartDateTime_Column, QLocale().toString(j->dtStart().toLocalZone().dateTime(), QLocale::ShortFormat));
mItem->setText(StartDateTime_Column, QLocale().toString(j->dtStart().toLocalTime(), QLocale::ShortFormat));
return true;
}
......@@ -455,9 +455,9 @@ void ListView::changeIncidenceDisplay(const Akonadi::Item &aitem, int action)
QDate date;
if (CalendarSupport::hasTodo(aitem)) {
date = CalendarSupport::todo(aitem)->dtDue().toLocalZone().date();
date = CalendarSupport::todo(aitem)->dtDue().toLocalTime().date();
} else {
date = incidence->dtStart().toLocalZone().date();
date = incidence->dtStart().toLocalTime().date();
}
switch (action) {
......
......@@ -32,7 +32,6 @@
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
#include <KCalCore/Utils>
#include <KCalUtils/IncidenceFormatter>
#include <KCalUtils/RecurrenceActions>
......@@ -365,8 +364,8 @@ QDate IncidenceMonthItem::realStartDate() const
return QDate();
}
const KDateTime dt = mIncidence->dateTime(Incidence::RoleDisplayStart);
const QDate start = dt.isDateOnly() ? dt.date() : dt.toLocalZone().date();
const QDateTime dt = mIncidence->dateTime(Incidence::RoleDisplayStart);
const QDate start = dt.toLocalTime().date();
return start.addDays(mRecurDayOffset);
}
......@@ -376,8 +375,8 @@ QDate IncidenceMonthItem::realEndDate() const
return QDate();
}
const KDateTime dt = mIncidence->dateTime(KCalCore::Incidence::RoleDisplayEnd);
const QDate end = dt.isDateOnly() ? dt.date() : dt.toLocalZone().date();
const QDateTime dt = mIncidence->dateTime(KCalCore::Incidence::RoleDisplayEnd);
const QDate end = dt.toLocalTime().date();
return end.addDays(mRecurDayOffset);
}
......@@ -441,7 +440,7 @@ void IncidenceMonthItem::updateDates(int startOffset, int endOffset)
case KCalUtils::RecurrenceActions::SelectedOccurrence: // Just this occurrence
case KCalUtils::RecurrenceActions::FutureOccurrences: { // All future occurrences
const bool thisAndFuture = (res == KCalUtils::RecurrenceActions::FutureOccurrences);
QDateTime occurrenceDate(KCalCore::k2q(mIncidence->dtStart()));
QDateTime occurrenceDate(mIncidence->dtStart());
occurrenceDate.setDate(startDate());
KCalCore::Incidence::Ptr newIncidence(KCalCore::Calendar::createException(
mIncidence, occurrenceDate, thisAndFuture));
......@@ -481,20 +480,20 @@ QString IncidenceMonthItem::text(bool end) const
QString timeStr;
if (mIsTodo) {
KCalCore::Todo::Ptr todo = mIncidence.staticCast<Todo>();
timeStr = QLocale().toString(todo->dtDue().toLocalZone().time(), QLocale::ShortFormat);
timeStr = QLocale().toString(todo->dtDue().toLocalTime().time(), QLocale::ShortFormat);
} else {
if (!end) {
QTime time;
if (mIncidence->recurs()) {
const auto start = mIncidence->dtStart().addDays(mRecurDayOffset).addSecs(-1);
time = mIncidence->recurrence()->getNextDateTime(KCalCore::k2q(start)).toLocalTime().time();
time = mIncidence->recurrence()->getNextDateTime(start).toLocalTime().time();
} else {
time = mIncidence->dtStart().toLocalZone().time();
time = mIncidence->dtStart().toLocalTime().time();
}
timeStr = QLocale().toString(time, QLocale::ShortFormat);
} else {
KCalCore::Event::Ptr event = mIncidence.staticCast<Event>();
timeStr = QLocale().toString(event->dtEnd().toLocalZone().time(), QLocale::ShortFormat);
timeStr = QLocale().toString(event->dtEnd().toLocalTime().time(), QLocale::ShortFormat);
}
}
if (!timeStr.isEmpty()) {
......@@ -562,7 +561,7 @@ QVector<QPixmap> IncidenceMonthItem::icons() const
} else if ((mIsTodo || mIsJournal) && icons.contains(mIsTodo ?
EventView::TaskIcon :
EventView::JournalIcon)) {
QDateTime occurrenceDateTime = KCalCore::k2q(mIncidence->dateTime(Incidence::RoleRecurrenceStart));
QDateTime occurrenceDateTime = mIncidence->dateTime(Incidence::RoleRecurrenceStart);
occurrenceDateTime.setDate(realStartDate());
const QString incidenceIconName = mIncidence->iconName(occurrenceDateTime);
......@@ -615,7 +614,7 @@ QColor IncidenceMonthItem::bgColor() const
Q_ASSERT(todo);
if (todo) {
const QDate dtRecurrence = // this is dtDue if there's no dtRecurrence
todo->dtRecurrence().toLocalZone().date();
todo->dtRecurrence().toLocalTime().date();
const QDate today = QDate::currentDate();
if (todo->isOverdue() && today > startDate() && startDate() >= dtRecurrence) {
bgColor = prefs->todoOverdueColor();
......@@ -689,8 +688,8 @@ void IncidenceMonthItem::setNewDates(const KCalCore::Incidence::Ptr &incidence,
const int offset = startOffset;
KCalCore::Todo::Ptr todo = incidence.staticCast<Todo>();
KDateTime due = todo->dtDue();
KDateTime start = todo->dtStart();
QDateTime due = todo->dtDue();
QDateTime start = todo->dtStart();
if (due.isValid()) { // Due has priority over start.
// We will only move the due date, unlike events where we move both.
due = due.addDays(offset);
......
......@@ -35,6 +35,7 @@
#include <KCalCore/OccurrenceIterator>
#include <KCheckableProxyModel>
#include <KLocalizedString>
#include <QIcon>
#include "calendarview_debug.h"
......
......@@ -48,10 +48,10 @@ void TimelineItem::insertIncidence(const Akonadi::Item &aitem,
QDateTime start(_start);
QDateTime end(_end);
if (!start.isValid()) {
start = incidence->dtStart().toLocalZone().dateTime();
start = incidence->dtStart().toLocalTime();
}
if (!end.isValid()) {
end = incidence->dateTime(Incidence::RoleEnd).toLocalZone().dateTime();
end = incidence->dateTime(Incidence::RoleEnd).toLocalTime();
}
if (incidence->allDay()) {
end = end.addDays(1);
......
......@@ -32,7 +32,6 @@
#include <CalendarSupport/Utils>
#include <Akonadi/Calendar/IncidenceChanger>
#include <KCalCore/OccurrenceIterator>
#include <KCalCore/Utils>
#include "calendarview_debug.h"
......@@ -130,7 +129,7 @@ void TimelineView::Private::insertIncidence(const Akonadi::Item &aitem, const QD
occurIter.next();
const Akonadi::Item akonadiItem = q->calendar()->item(occurIter.incidence());
const QDateTime startOfOccurrence = occurIter.occurrenceStartDate();
const QDateTime endOfOccurrence = KCalCore::k2q(occurIter.incidence()->endDateForStart(KCalCore::q2k(startOfOccurrence)));
const QDateTime endOfOccurrence = occurIter.incidence()->endDateForStart(startOfOccurrence);
item->insertIncidence(akonadiItem, startOfOccurrence.toLocalTime(), endOfOccurrence.toLocalTime());
}
} else {
......
......@@ -30,8 +30,6 @@
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
#include <KCalCore/Utils>
#include <QBoxLayout>
#include <QPainter>
#include <QPaintEvent>
......@@ -90,9 +88,9 @@ public:
foreach (const KCalCore::Event::Ptr &e, mEventList)
{
Q_ASSERT(e);
QDateTime selectedStart(mTimeSpentView->mStartDate, QTime(0, 0), KCalCore::specToZone(e->dtStart().timeSpec()));
QDateTime selectedStart(mTimeSpentView->mStartDate, QTime(0, 0), e->dtStart().timeZone());
QDateTime selectedEnd(mTimeSpentView->mEndDate.addDays(1), QTime(0, 0), KCalCore::specToZone(e->dtEnd().timeSpec()));
QDateTime selectedEnd(mTimeSpentView->mEndDate.addDays(1), QTime(0, 0), e->dtEnd().timeZone());
QDateTime start;
QDateTime end;
......@@ -119,8 +117,8 @@ public:
} else {
// The event's start can be before the view's start date or end after the view's end
start = KCalCore::k2q(e->dtStart()) > selectedStart ? KCalCore::k2q(e->dtStart()) : selectedStart;
end = KCalCore::k2q(e->dtEnd()) < selectedEnd ? KCalCore::k2q(e->dtEnd()) : selectedEnd;
start = e->dtStart() > selectedStart ? e->dtStart() : selectedStart;
end = e->dtEnd() < selectedEnd ? e->dtEnd() : selectedEnd;
totalDuration += start.secsTo(end);
}
......
......@@ -280,10 +280,10 @@ QVariant TodoModel::data(const QModelIndex &index, int role) const
case PercentColumn:
return QVariant(todo->percentComplete());
case StartDateColumn:
return todo->hasStartDate() ? QLocale().toString(todo->dtStart().toLocalZone().date(), QLocale::ShortFormat)
return todo->hasStartDate() ? QLocale().toString(todo->dtStart().toLocalTime().date(), QLocale::ShortFormat)
: QVariant(QString());
case DueDateColumn:
return todo->hasDueDate() ? QLocale().toString(todo->dtDue().toLocalZone().date(), QLocale::ShortFormat)
return todo->hasDueDate() ? QLocale().toString(todo->dtDue().toLocalTime().date(), QLocale::ShortFormat)
: QVariant(QString());
case CategoriesColumn: {
QString categories = todo->categories().join(
......@@ -442,7 +442,7 @@ bool TodoModel::setData(const QModelIndex &index, const QVariant &value, int rol
if (role == Qt::CheckStateRole && index.column() == 0) {
const bool checked = static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked;
if (checked) {
todo->setCompleted(KDateTime::currentLocalDateTime()); // Because it calls Todo::recurTodo()
todo->setCompleted(QDateTime::currentDateTimeUtc()); // Because it calls Todo::recurTodo()
} else {
todo->setCompleted(false);
}
......@@ -462,13 +462,13 @@ bool TodoModel::setData(const QModelIndex &index, const QVariant &value, int rol
todo->setPercentComplete(value.toInt());
break;
case StartDateColumn: {
KDateTime tmp = todo->dtStart();
QDateTime tmp = todo->dtStart();
tmp.setDate(value.toDate());
todo->setDtStart(tmp);
}
break;
case DueDateColumn: {
KDateTime tmp = todo->dtDue();
QDateTime tmp = todo->dtDue();
tmp.setDate(value.toDate());
todo->setDtDue(tmp);
}
......
......@@ -882,7 +882,7 @@ void TodoView::copyTodoToDate(const QDate &date)
todo->setUid(KCalCore::CalFormat::createUniqueId());
KDateTime due = todo->dtDue();
QDateTime due = todo->dtDue();
due.setDate(date);
todo->setDtDue(due);
......@@ -968,7 +968,7 @@ void TodoView::setNewDate(const QDate &date)
if (calendar()->hasRight(todoItem, Akonadi::Collection::CanChangeItem)) {
KCalCore::Todo::Ptr oldTodo(todo->clone());
KDateTime dt(date);
QDateTime dt(date);
if (!todo->allDay()) {
dt.setTime(todo->dtDue().time());
......@@ -998,7 +998,7 @@ void TodoView::setNewPercentage(QAction *action)
int percentage = mPercentage.value(action);
if (percentage == 100) {
todo->setCompleted(KDateTime::currentLocalDateTime());
todo->setCompleted(QDateTime::currentDateTime());
todo->setPercentComplete(100);
} else {
todo->setPercentComplete(percentage);
......
......@@ -210,8 +210,8 @@ int TodoViewSortFilterProxyModel::compareStartDates(const QModelIndex &left,
// For sorting, no date is considered a very big date
return rightIsEmpty ? -1 : 1;
} else if (!leftIsEmpty) { // Both have start dates
const auto leftDateTime = leftTodo->dtStart().dateTime();
const auto rightDateTime = rightTodo->dtStart().dateTime();
const auto leftDateTime = leftTodo->dtStart();
const auto rightDateTime = rightTodo->dtStart();
if (leftDateTime == rightDateTime) {
return 0;
......@@ -257,8 +257,8 @@ int TodoViewSortFilterProxyModel::compareDueDates(const QModelIndex &left,
// For sorting, no date is considered a very big date
return rightIsEmpty ? -1 : 1;
} else if (!leftIsEmpty) { // Both have due dates
const auto leftDateTime = leftTodo->dtDue().dateTime();
const auto rightDateTime = rightTodo->dtDue().dateTime();
const auto leftDateTime = leftTodo->dtDue();
const auto rightDateTime = rightTodo->dtDue();
if (leftDateTime == rightDateTime) {
return 0;
......
......@@ -264,7 +264,7 @@ void WhatsNextView::appendEvent(const KCalCore::Incidence::Ptr &incidence, const
if (const KCalCore::Event::Ptr event = incidence.dynamicCast<KCalCore::Event>()) {
auto starttime = start.toLocalTime();
if (!starttime.isValid()) {
starttime = event->dtStart().dateTime().toLocalTime();
starttime = event->dtStart().toLocalTime();
}
auto endtime = end.toLocalTime();
if (!endtime.isValid()) {
......@@ -315,7 +315,7 @@ void WhatsNextView::appendTodo(const KCalCore::Incidence::Ptr &incidence)
if (todo->hasDueDate()) {
mText += i18nc("to-do due date", " (Due: %1)",
KCalUtils::IncidenceFormatter::dateTimeToString(
todo->dtDue().dateTime(), todo->allDay()));
todo->dtDue(), todo->allDay()));
}
mText += QLatin1String("</li>\n");
}
......
......@@ -5,5 +5,6 @@ target_link_libraries(createcolorgui_test
Qt5::Core
Qt5::Gui
KF5::EventViews
KF5::I18n
)
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