Commit 1444b080 authored by Volker Krause's avatar Volker Krause

Port away from KDateTime completely

parent ecc78a18
......@@ -66,6 +66,12 @@ target_link_libraries(korgac
KF5::Codecs
KF5::DBusAddons
Phonon::phonon4qt5
KF5::Notifications
KF5::Completion
KF5::IconThemes
KF5::Service
KF5::KIOCore
KF5::WindowSystem
)
install(TARGETS
......
......@@ -50,7 +50,6 @@
#include <QUrl>
#include <KComboBox>
#include <KDateTime>
#include <QHBoxLayout>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -864,7 +863,7 @@ QDateTime AlarmDialog::triggerDateForIncidence(const Incidence::Ptr &incidence,
}
if (!result.isValid()) {
result = incidence->dateTime(Incidence::RoleAlarm).toLocalZone().dateTime();
result = incidence->dateTime(Incidence::RoleAlarm).toLocalTime();
}
if (result.isValid()) {
......
......@@ -42,6 +42,7 @@
#include <KCheckableProxyModel>
#include <KConfig>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QApplication>
#include "koalarmclient_debug.h"
......
......@@ -32,4 +32,7 @@ target_link_libraries(testalarmdlg
KF5::IdentityManagement
KF5::MailTransport
Phonon::phonon4qt5
KF5::Notifications
KF5::IconThemes
KF5::WindowSystem
)
......@@ -53,7 +53,7 @@ int main(int argc, char **argv)
Event *e1 = new Event;
e1->setSummary(QStringLiteral("This is a summary."));
KDateTime now = KDateTime::currentLocalDateTime();
QDateTime now = QDateTime::currentDateTime();
e1->setDtStart(now);
e1->setDtEnd(now.addDays(1));
Alarm::Ptr a = e1->newAlarm();
......
......@@ -51,6 +51,7 @@ target_link_libraries(korganizer
korganizer_core
KF5::PimCommonAkonadi
KF5::Crash
KF5::WindowSystem
)
install(TARGETS
......@@ -83,6 +84,7 @@ target_link_libraries(kcm_korganizer
KF5::MailTransport
KF5::PimCommon
KF5::AkonadiWidgets
KF5::WindowSystem
)
install(TARGETS
......@@ -255,6 +257,10 @@ target_link_libraries(korganizerprivate
KF5::NewStuff
KF5::Ldap
KF5::AkonadiWidgets
KF5::IconThemes
KF5::WindowSystem
KF5::Notifications
KF5::ItemViews
)
target_include_directories(korganizerprivate PUBLIC
......
......@@ -90,10 +90,10 @@ void KoEventPopupMenuTest::createEventFromTodo()
item.setMimeType(KCalCore::Todo::todoMimeType());
item.setPayload<KCalCore::Todo::Ptr>(todo);
KDateTime start, end;
QDateTime start, end;
QString summary(QStringLiteral("a test"));
start.setTime_t(1402593346);
end.setTime_t(1403593346);
start = QDateTime::fromSecsSinceEpoch(1402593346);
end = QDateTime::fromSecsSinceEpoch(1403593346);
todo->setDtStart(start);
todo->setDtDue(end);
todo->setSummary(summary);
......@@ -124,10 +124,10 @@ void KoEventPopupMenuTest::createTodoFromEvent()
item.setMimeType(KCalCore::Event::eventMimeType());
item.setPayload<KCalCore::Event::Ptr>(event);
KDateTime start, end;
QDateTime start, end;
QString summary(QStringLiteral("a test"));
start.setTime_t(1402593346);
end.setTime_t(1403593346);
start = QDateTime::fromSecsSinceEpoch(1402593346);
end = QDateTime::fromSecsSinceEpoch(1403593346);
event->setDtStart(start);
event->setDtEnd(end);
event->setSummary(summary);
......@@ -158,11 +158,11 @@ void KoEventPopupMenuTest::createNoteFromEvent()
item.setMimeType(KCalCore::Event::eventMimeType());
item.setPayload<KCalCore::Event::Ptr>(event);
KDateTime start, end;
QDateTime start, end;
QString summary(QStringLiteral("A test"));
QString description(QStringLiteral("A long description"));
start.setTime_t(1402593346);
end.setTime_t(1403593346);
start = QDateTime::fromSecsSinceEpoch(1402593346);
end = QDateTime::fromSecsSinceEpoch(1403593346);
event->setDtStart(start);
event->setDtEnd(end);
event->setSummary(summary);
......@@ -196,11 +196,11 @@ void KoEventPopupMenuTest::createNoteFromTodo()
item.setMimeType(KCalCore::Todo::todoMimeType());
item.setPayload<KCalCore::Todo::Ptr>(todo);
KDateTime start, end;
QDateTime start, end;
QString summary(QStringLiteral("a test"));
QString description(QStringLiteral("A long description"));
start.setTime_t(1402593346);
end.setTime_t(1403593346);
start = QDateTime::fromSecsSinceEpoch(1402593346);
end = QDateTime::fromSecsSinceEpoch(1403593346);
todo->setDtStart(start);
todo->setDtDue(end);
todo->setSummary(summary);
......
......@@ -85,7 +85,6 @@
#include <KCalCore/FileStorage>
#include <KCalCore/ICalFormat>
#include <KCalCore/VCalFormat>
#include <KCalCore/Utils>
#include <KCalUtils/ICalDrag>
#include <KCalUtils/Stringify>
......@@ -657,7 +656,7 @@ void CalendarView::slotModifyFinished(int changeId,
if (journals.isEmpty()) {
KCalCore::Journal::Ptr journal(new KCalCore::Journal);
journal->setDtStart(KDateTime::currentLocalDateTime());
journal->setDtStart(QDateTime::currentDateTime());
QString dateStr = QLocale::system().toString(QDate::currentDate(), QLocale::LongFormat);
journal->setSummary(i18n("Journal of %1", dateStr));
......@@ -881,8 +880,8 @@ void CalendarView::edit_paste()
if (agendaView && endDT.isValid() && useEndTime) {
if ((pastedEvent->allDay() && agendaView->selectedIsAllDay()) ||
(!pastedEvent->allDay() && !agendaView->selectedIsAllDay())) {
KDateTime kdt(endDT, KDateTime::LocalZone);
pastedEvent->setDtEnd(kdt.toTimeSpec(pastedEvent->dtEnd().timeSpec()));
QDateTime kdt = endDT.toLocalTime();
pastedEvent->setDtEnd(kdt.toTimeZone(pastedEvent->dtEnd().timeZone()));
}
}
......@@ -1391,7 +1390,7 @@ void CalendarView::toggleTodoCompleted(const Akonadi::Item &todoItem)
if (todo->isCompleted()) {
todo->setPercentComplete(0);
} else {
todo->setCompleted(KDateTime::currentLocalDateTime());
todo->setCompleted(QDateTime::currentDateTime());
}
mChanger->startAtomicOperation(i18n("Toggle To-do Completed"));
......@@ -1614,7 +1613,7 @@ void CalendarView::dissociateOccurrence(const Akonadi::Item &item, const QDate &
} else {
startMultiModify(i18n("Dissociate occurrence"));
}
QDateTime occurrenceDate = KCalCore::k2q(incidence->dtStart());
QDateTime occurrenceDate = incidence->dtStart();
occurrenceDate.setDate(date);
qCDebug(KORGANIZER_LOG) << "create exception: " << occurrenceDate;
KCalCore::Incidence::Ptr newInc(KCalCore::Calendar::createException(
......@@ -2231,7 +2230,7 @@ void CalendarView::showIncidenceContext(const Akonadi::Item &item)
viewManager()->showAgendaView();
}
// just select the appropriate date
mDateNavigator->selectWeek(incidence->dtStart().toLocalZone().date());
mDateNavigator->selectWeek(incidence->dtStart().toLocalTime().date());
return;
} else if (CalendarSupport::hasJournal(item)) {
if (!viewManager()->currentView()->inherits("KOJournalView")) {
......@@ -2537,8 +2536,8 @@ void CalendarView::addIncidenceOn(const Akonadi::Item &itemadd, const QDate &dt)
if (const KCalCore::Event::Ptr event = incidence.dynamicCast<KCalCore::Event>()) {
// Adjust date
KDateTime start = event->dtStart();
KDateTime end = event->dtEnd();
QDateTime start = event->dtStart();
QDateTime end = event->dtEnd();
int duration = start.daysTo(end);
start.setDate(dt);
......@@ -2548,7 +2547,7 @@ void CalendarView::addIncidenceOn(const Akonadi::Item &itemadd, const QDate &dt)
event->setDtEnd(end);
} else if (const KCalCore::Todo::Ptr todo = incidence.dynamicCast<KCalCore::Todo>()) {
KDateTime due = todo->dtDue();
QDateTime due = todo->dtDue();
due.setDate(dt);
todo->setDtDue(due);
......@@ -2577,8 +2576,8 @@ void CalendarView::moveIncidenceTo(const Akonadi::Item &itemmove, const QDate &d
if (const KCalCore::Event::Ptr event = incidence.dynamicCast<KCalCore::Event>()) {
// Adjust date
KDateTime start = event->dtStart();
KDateTime end = event->dtEnd();
QDateTime start = event->dtStart();
QDateTime end = event->dtEnd();
int duration = start.daysTo(end);
start.setDate(dt);
......@@ -2588,7 +2587,7 @@ void CalendarView::moveIncidenceTo(const Akonadi::Item &itemmove, const QDate &d
event->setDtEnd(end);
} if (const KCalCore::Todo::Ptr todo = incidence.dynamicCast<KCalCore::Todo>()) {
KDateTime due = todo->dtDue();
QDateTime due = todo->dtDue();
due.setDate(dt);
todo->setDtDue(due);
......
......@@ -177,14 +177,14 @@ void SearchDialog::search(const QRegExp &re)
Q_ASSERT(todo);
if ((!todo->hasStartDate() && !todo->hasDueDate()) || // undated
(todo->hasStartDate() &&
(todo->dtStart().toLocalZone().date() >= startDt) &&
(todo->dtStart().toLocalZone().date() <= endDt)) || //start dt in range
(todo->dtStart().toLocalTime().date() >= startDt) &&
(todo->dtStart().toLocalTime().date() <= endDt)) || //start dt in range
(todo->hasDueDate() &&
(todo->dtDue().toLocalZone().date() >= startDt) &&
(todo->dtDue().toLocalZone().date() <= endDt)) || //due dt in range
(todo->dtDue().toLocalTime().date() >= startDt) &&
(todo->dtDue().toLocalTime().date() <= endDt)) || //due dt in range
(todo->hasCompletedDate() &&
(todo->completed().toLocalZone().date() >= startDt) &&
(todo->completed().toLocalZone().date() <= endDt))) { //completed dt in range
(todo->completed().toLocalTime().date() >= startDt) &&
(todo->completed().toLocalTime().date() <= endDt))) { //completed dt in range
todos.append(todo);
}
}
......
......@@ -12,6 +12,8 @@ target_link_libraries(korganizer_interfaces
KF5::CalendarSupport
KF5::EventViews
KF5::AkonadiCore
Qt5::PrintSupport
KF5::Parts
)
set_target_properties(korganizer_interfaces PROPERTIES
......
......@@ -26,6 +26,8 @@
#include <CalendarSupport/KCalPrefs>
#include <KLocalizedString>
QColor KOCoreHelper::categoryColor(const QStringList &categories)
{
if (categories.isEmpty()) {
......
......@@ -35,8 +35,6 @@
#include <AkonadiCore/ItemFetchJob>
#include <AkonadiCore/ItemFetchScope>
#include <KCalCore/Utils>
#include <QUrl>
#include <QIcon>
#include <QMenu>
......@@ -278,7 +276,7 @@ void KODayMatrix::updateJournals()
for (const KCalCore::Incidence::Ptr &inc : incidences) {
Q_ASSERT(inc);
QDate d = inc->dtStart().toLocalZone().date();
QDate d = inc->dtStart().toLocalTime().date();
if (inc->type() == KCalCore::Incidence::TypeJournal &&
d >= mDays[0] &&
d <= mDays[NUMDAYS - 1] &&
......@@ -332,7 +330,7 @@ void KODayMatrix::updateTodos()
}
} else {
d = t->dtDue().toLocalZone().date();
d = t->dtDue().toLocalTime().date();
if (d >= mDays[0] && d <= mDays[NUMDAYS - 1] && !mEvents.contains(d)) {
mEvents.append(d);
}
......@@ -359,13 +357,13 @@ void KODayMatrix::updateEvents()
Q_ASSERT(event);
const ushort recurType = event->recurrenceType();
const KDateTime dtStart = event->dtStart().toLocalZone();
const QDateTime dtStart = event->dtStart().toLocalTime();
// timed incidences occur in
// [dtStart(), dtEnd()[. All-day incidences occur in [dtStart(), dtEnd()]
// so we subtract 1 second in the timed case
const int secsToAdd = event->allDay() ? 0 : -1;
const KDateTime dtEnd = event->dtEnd().toLocalZone().addSecs(secsToAdd);
const QDateTime dtEnd = event->dtEnd().toLocalTime().addSecs(secsToAdd);
if (!(recurType == KCalCore::Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) &&
!(recurType == KCalCore::Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
......@@ -381,7 +379,7 @@ void KODayMatrix::updateEvents()
QDateTime(mDays[NUMDAYS - 1], {}, Qt::LocalTime));
} else {
if (dtStart.date() >= mDays[0]) {
timeDateList.append(KCalCore::k2q(dtStart));
timeDateList.append(dtStart);
} else {
// The event starts in another month (not visible))
timeDateList.append(QDateTime(mDays[0], {}, Qt::LocalTime));
......
......@@ -204,12 +204,12 @@ bool KOEventView::usesCompletedTodoPixmap(const Akonadi::Item &aitem, const QDat
if (todo->allDay()) {
time = QTime(0, 0);
} else {
time = todo->dtDue().toLocalZone().time();
time = todo->dtDue().toLocalTime().time();
}
QDateTime itemDateTime(date, time, Qt::LocalTime);
return itemDateTime < todo->dtDue(false).toLocalZone().dateTime();
return itemDateTime < todo->dtDue(false).toLocalTime();
} else {
return false;
......
......@@ -28,6 +28,7 @@
#include <EventViews/Helper>
#include <CalendarSupport/KCalPrefs>
#include <KLocalizedString>
#include <KMessageBox>
QColor KOHelper::getTextColor(const QColor &c)
......
......@@ -8,7 +8,7 @@ qt5_add_dbus_interfaces(kontact_korganizerplugin_PART_SRCS ${korganizer_SOURCE_D
add_library(kontact_korganizerplugin MODULE ${kontact_korganizerplugin_PART_SRCS})
target_link_libraries(kontact_korganizerplugin KF5::AkonadiCalendar KF5::CalendarUtils KF5::Contacts KF5::CalendarCore KF5::Libkdepim KF5::KontactInterface korganizerprivate KF5::CalendarSupport KF5::AkonadiCalendar)
target_link_libraries(kontact_korganizerplugin KF5::AkonadiCalendar KF5::CalendarUtils KF5::Contacts KF5::CalendarCore KF5::Libkdepim KF5::KontactInterface korganizerprivate KF5::CalendarSupport KF5::AkonadiCalendar KF5::WindowSystem KF5::I18n KF5::IconThemes)
########### next target ###############
......@@ -18,7 +18,7 @@ qt5_add_dbus_interfaces(kontact_todoplugin_PART_SRCS ${korganizer_SOURCE_DIR}/sr
add_library(kontact_todoplugin MODULE ${kontact_todoplugin_PART_SRCS})
target_link_libraries(kontact_todoplugin KF5::AkonadiCalendar KF5::Contacts KF5::Libkdepim KF5::KontactInterface KF5::CalendarCore KF5::CalendarUtils KF5::CalendarSupport KF5::AkonadiCalendar)
target_link_libraries(kontact_todoplugin KF5::AkonadiCalendar KF5::Contacts KF5::Libkdepim KF5::KontactInterface KF5::CalendarCore KF5::CalendarUtils KF5::CalendarSupport KF5::AkonadiCalendar KF5::IconThemes KF5::Notifications KF5::WindowSystem)
########### next target ###############
......
......@@ -9,4 +9,5 @@ target_link_libraries(
KF5::CalendarCore
KF5::CalendarUtils
Qt5::Test
KF5::I18n
)
......@@ -24,7 +24,6 @@
#include <KCalCore/Event>
#include <KCalCore/MemoryCalendar>
#include <KLocale>
#include <QTimeZone>
QTEST_GUILESS_MAIN(SummaryEventTester)
......@@ -37,15 +36,16 @@ void SummaryEventTester::test_Multiday()
KCalCore::MemoryCalendar *cal = new KCalCore::MemoryCalendar(QTimeZone::systemTimeZone());
KCalCore::Event::Ptr event(new KCalCore::Event());
event->setDtStart(KDateTime(today.addDays(-1)));
event->setDtEnd(KDateTime(today.addDays(5)));
event->setDtStart(QDateTime(today.addDays(-1)));
event->setDtEnd(QDateTime(today.addDays(5)));
event->setAllDay(true);
QString multiDayAllDayStartingYesterday = QStringLiteral("Multiday, allday, in progress (day 2/6)");
event->setSummary(multiDayAllDayStartingYesterday);
QVERIFY(cal->addEvent(event));
event = KCalCore::Event::Ptr(new KCalCore::Event());
event->setDtStart(KDateTime(today.addDays(-1), QTime(12, 00)));
event->setDtEnd(KDateTime(today.addDays(5), QTime(12, 00)));
event->setDtStart(QDateTime(today.addDays(-1), QTime(12, 00)));
event->setDtEnd(QDateTime(today.addDays(5), QTime(12, 00)));
event->setSummary(multidayWithTimeInProgress);
QVERIFY(cal->addEvent(event));
for (int i = 0; i < 5; ++i) {
......@@ -66,8 +66,8 @@ void SummaryEventTester::test_Multiday()
// Test date a multiday event in the future has to correct DaysTo set
QString multiDayWithTimeFuture = QStringLiteral("Multiday, with time, in the future");
event = KCalCore::Event::Ptr(new KCalCore::Event());
event->setDtStart(KDateTime(today.addDays(100), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setDtEnd(KDateTime(today.addDays(106), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setDtStart(QDateTime(today.addDays(100), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setDtEnd(QDateTime(today.addDays(106), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setSummary(multiDayWithTimeFuture);
QVERIFY(cal->addEvent(event));
for (int i = 100; i <= 106; ++i) {
......@@ -87,27 +87,29 @@ void SummaryEventTester::test_Multiday()
QString multiDayAllDayInFuture = QStringLiteral("Multiday, allday, in future");
int multiDayFuture = 30;
event = KCalCore::Event::Ptr(new KCalCore::Event());
event->setDtStart(KDateTime(today.addDays(multiDayFuture)));
event->setDtEnd(KDateTime(today.addDays(multiDayFuture + 5)));
event->setDtStart(QDateTime(today.addDays(multiDayFuture)));
event->setAllDay(true);
event->setDtEnd(QDateTime(today.addDays(multiDayFuture + 5)));
event->setSummary(multiDayAllDayInFuture);
QVERIFY(cal->addEvent(event));
event = KCalCore::Event::Ptr(new KCalCore::Event());
event->setDtStart(KDateTime(today.addDays(2), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setDtEnd(KDateTime(today.addDays(5), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setDtStart(QDateTime(today.addDays(2), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setDtEnd(QDateTime(today.addDays(5), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setSummary(QStringLiteral("Multiday, time specified, in future"));
QVERIFY(cal->addEvent(event));
QString multiDayAllDayStartingToday = QStringLiteral("Multiday, allday, starting today");
event = KCalCore::Event::Ptr(new KCalCore::Event());
event->setDtStart(KDateTime(today));
event->setDtEnd(KDateTime(today.addDays(5)));
event->setDtStart(QDateTime(today));
event->setDtEnd(QDateTime(today.addDays(5)));
event->setAllDay(true);
event->setSummary(multiDayAllDayStartingToday);
QVERIFY(cal->addEvent(event));
event = KCalCore::Event::Ptr(new KCalCore::Event());
event->setDtStart(KDateTime(today.addDays(-10), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setDtEnd(KDateTime(today.addDays(-5), QTime::fromString(QStringLiteral("10:00"), QStringLiteral("hh:mm"))));
event->setDtStart(QDateTime(today.addDays(-10), QTime::fromString(QStringLiteral("12:00"), QStringLiteral("hh:mm"))));
event->setDtEnd(QDateTime(today.addDays(-5), QTime::fromString(QStringLiteral("10:00"), QStringLiteral("hh:mm"))));
event->setSummary(QStringLiteral("Some event in the past"));
QVERIFY(cal->addEvent(event));
......@@ -183,8 +185,9 @@ void SummaryEventTester::test_eventsForRange()
KCalCore::MemoryCalendar *cal = new KCalCore::MemoryCalendar(QTimeZone::systemTimeZone());
KCalCore::Event::Ptr event(new KCalCore::Event());
event->setDtStart(KDateTime(today.addDays(start)));
event->setDtEnd(KDateTime(today.addDays(end)));
event->setDtStart(QDateTime(today.addDays(start)));
event->setDtEnd(QDateTime(today.addDays(end)));
event->setAllDay(true);
QVERIFY(cal->addEvent(event));
SummaryEventInfo::List events = SummaryEventInfo::eventsForRange(today, today.addDays(7), cal);
......
......@@ -28,7 +28,6 @@
#include <KCalCore/Calendar>
#include <KCalCore/Event>
#include <KCalCore/Utils>
using namespace KCalCore;
#include <KCalUtils/IncidenceFormatter>
......@@ -43,31 +42,19 @@ using namespace KCalUtils;
bool SummaryEventInfo::mShowBirthdays = true;
bool SummaryEventInfo::mShowAnniversaries = true;
typedef QHash<QString, KDateTime> DateTimeByUidHash;
typedef QHash<QString, QDateTime> DateTimeByUidHash;
Q_GLOBAL_STATIC(DateTimeByUidHash, sDateTimeByUid)
static bool eventLessThan(const KCalCore::Event::Ptr &event1, const KCalCore::Event::Ptr &event2)
{
KDateTime kdt1 = sDateTimeByUid()->value(event1->instanceIdentifier());
KDateTime kdt2 = sDateTimeByUid()->value(event2->instanceIdentifier());
if (kdt1.date() < kdt2.date()) { // Compare dates first since comparing all day with non-all-day doesn't work
QDateTime kdt1 = sDateTimeByUid()->value(event1->instanceIdentifier());
QDateTime kdt2 = sDateTimeByUid()->value(event2->instanceIdentifier());
if (kdt1 > kdt2) {
return true;
} else if (kdt1.date() > kdt2.date()) {
} else if (kdt1 < kdt2) {
return false;
} else {
if (kdt1.isDateOnly() && !kdt2.isDateOnly()) {
return false;
} else if (!kdt1.isDateOnly() && kdt2.isDateOnly()) {
return true;
} else {
if (kdt1 > kdt2) {
return true;
} else if (kdt1 < kdt2) {
return false;
} else {
return event1->summary() > event2->summary();
}
}
return event1->summary() > event2->summary();
}
}
......@@ -147,22 +134,22 @@ SummaryEventInfo::List SummaryEventInfo::eventsForRange(const QDate &start, cons
continue;
}
const auto eventStart = event->dtStart().toLocalZone().dateTime();
const auto eventEnd = event->dtEnd().toLocalZone().dateTime();
const auto eventStart = event->dtStart().toLocalTime();
const auto eventEnd = event->dtEnd().toLocalTime();
if (event->recurs()) {
const auto occurrences = event->recurrence()->timesInInterval(QDateTime(start, {}), QDateTime(end, {}));
if (!occurrences.isEmpty()) {
events << event;
sDateTimeByUid()->insert(event->instanceIdentifier(), KCalCore::q2k(occurrences.first()));
sDateTimeByUid()->insert(event->instanceIdentifier(), occurrences.first());
}
} else {
if ((end >= eventStart.date() && start <= eventEnd.date()) ||
(start >= eventStart.date() && end <= eventEnd.date())) {
events << event;
if (eventStart.date() < start) {
sDateTimeByUid()->insert(event->instanceIdentifier(), KDateTime(start));
sDateTimeByUid()->insert(event->instanceIdentifier(), QDateTime(start));
} else {
sDateTimeByUid()->insert(event->instanceIdentifier(), KDateTime(eventStart));
sDateTimeByUid()->insert(event->instanceIdentifier(), eventStart);
}
}
}
......@@ -179,8 +166,8 @@ SummaryEventInfo::List SummaryEventInfo::eventsForRange(const QDate &start, cons
// Count number of days remaining in multiday event
int span = 1;
int dayof = 1;
const auto eventStart = ev->dtStart().toLocalZone().dateTime();
const auto eventEnd = ev->dtEnd().toLocalZone().dateTime();
const auto eventStart = ev->dtStart().toLocalTime();
const auto eventEnd = ev->dtEnd().toLocalTime();
const QDate occurrenceStartDate = sDateTimeByUid()->value(ev->instanceIdentifier()).date();
QDate startOfMultiday = eventStart.date();
......@@ -225,9 +212,9 @@ SummaryEventInfo::List SummaryEventInfo::eventsForRange(const QDate &start, cons
// Print the date span for multiday, floating events, for the
// first day of the event only.
if (ev->isMultiDay() && ev->allDay() && firstDayOfMultiday && span > 1) {
str = IncidenceFormatter::dateToString(ev->dtStart().toLocalZone().date(), false) +
str = IncidenceFormatter::dateToString(ev->dtStart().toLocalTime().date(), false) +
QLatin1String(" -\n ") +
IncidenceFormatter::dateToString(ev->dtEnd().toLocalZone().date(), false);
IncidenceFormatter::dateToString(ev->dtEnd().toLocalTime().date(), false);
}
summaryEvent->dateSpan = str;
......@@ -240,7 +227,7 @@ SummaryEventInfo::List SummaryEventInfo::eventsForRange(const QDate &start, cons
if (!ev->allDay()) {
int secs;
if (!ev->recurs()) {
secs = currentDateTime.secsTo(ev->dtStart().dateTime());
secs = currentDateTime.secsTo(ev->dtStart());
} else {
QDateTime kdt(start, QTime(0, 0, 0), Qt::LocalTime);
kdt = kdt.addSecs(-1);
......
......@@ -219,7 +219,7 @@ void TodoSummaryWidget::updateView()
}
}
if (str.isEmpty()) {
str = locale.toString(todo->dtDue().dateTime(), QLocale::ShortFormat);
str = locale.toString(todo->dtDue(), QLocale::ShortFormat);
}
}
}
......@@ -333,7 +333,7 @@ void TodoSummaryWidget::completeTodo(Akonadi::Item::Id id)
KCalCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
if (!todo->isReadOnly()) {
KCalCore::Todo::Ptr oldTodo(todo->clone());
todo->setCompleted(KDateTime::currentLocalDateTime());
todo->setCompleted(QDateTime::currentDateTime());
mChanger->modifyIncidence(todoItem, oldTodo);
updateView();
}
......
......@@ -18,6 +18,7 @@ target_link_libraries(kontact_specialdatesplugin
KF5::AkonadiCore
KF5::AkonadiContact
KF5::CalendarSupport
KF5::IconThemes
)
########### next target ###############
......
......@@ -103,7 +103,7 @@ void KOrganizerPart::slotChangeInfo(const Akonadi::Item &item, const QDate &date
const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence(item);
if (incidence) {
Q_EMIT textChanged(incidence->summary() + QLatin1String(" / ") +
KCalUtils::IncidenceFormatter::timeToString(incidence->dtStart().toLocalZone().time()));
KCalUtils::IncidenceFormatter::timeToString(incidence->dtStart().toLocalTime().time()));
} else {
Q_EMIT textChanged(QString());
}
......
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