summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Krause <[email protected]>2017-09-13 11:02:09 +0200
committerVolker Krause <[email protected]>2017-09-13 11:02:09 +0200
commitad2c7a7ece7902c40ff17a49bd452d5db74ddedf (patch)
tree59e8bef7c9b783b018558913b1b693703972f1fe
parentd07b3bb2e304252545d76bb547adfb111a9b4d2b (diff)
Free IncidenceEditor from KDateTime
-rw-r--r--autotests/CMakeLists.txt6
-rw-r--r--autotests/ktimezonecomboboxtest.cpp2
-rw-r--r--autotests/testfreebusyganttproxymodel.cpp8
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/incidencedatetime.cpp84
-rw-r--r--src/incidencedatetime.h6
-rw-r--r--src/incidencedefaults.cpp20
-rw-r--r--src/incidenceeditor.kcfg1
-rw-r--r--src/incidencerecurrence.cpp8
9 files changed, 72 insertions, 69 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 0fb5468..074217b 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -25,7 +25,7 @@ endmacro()
macro(IE_EXECUTABLE_TESTS)
foreach(_testname ${ARGN})
add_executable(${_testname} NOGUI TEST ${_testname}.cpp modeltest.cpp)
- target_link_libraries(${_testname} KF5::CalendarCore Qt5::Test KF5::IncidenceEditor)
+ target_link_libraries(${_testname} KF5::CalendarCore Qt5::Test KF5::IncidenceEditor Qt5::Widgets)
endforeach()
endmacro()
@@ -45,6 +45,7 @@ target_link_libraries(ktimezonecomboboxtest
KF5::CalendarCore
Qt5::Test
KF5::IncidenceEditor
+ KF5::Completion
)
add_executable(testindividualmaildialog testindividualmaildialog.cpp ../src/individualmaildialog.cpp)
@@ -54,4 +55,7 @@ ecm_mark_as_test(testindividualmaildialog)
target_link_libraries(testindividualmaildialog
KF5::CalendarCore
Qt5::Test
+ Qt5::Widgets
+ KF5::WidgetsAddons
+ KF5::I18n
)
diff --git a/autotests/ktimezonecomboboxtest.cpp b/autotests/ktimezonecomboboxtest.cpp
index 8ddb70f..82ecbd3 100644
--- a/autotests/ktimezonecomboboxtest.cpp
+++ b/autotests/ktimezonecomboboxtest.cpp
@@ -22,8 +22,6 @@
#include "qtest.h"
-#include <KTimeZone>
-
QTEST_MAIN(KTimeZoneComboBoxTest)
void KTimeZoneComboBoxTest::test_timeSpec()
diff --git a/autotests/testfreebusyganttproxymodel.cpp b/autotests/testfreebusyganttproxymodel.cpp
index 63d3b30..180ce42 100644
--- a/autotests/testfreebusyganttproxymodel.cpp
+++ b/autotests/testfreebusyganttproxymodel.cpp
@@ -56,8 +56,8 @@ void FreeBusyGanttProxyModelTest::testModelValidity()
KCalCore::Attendee::Ptr a1(new KCalCore::Attendee(QStringLiteral("fred"), QStringLiteral("[email protected]")));
KCalCore::FreeBusy::Ptr fb1(new KCalCore::FreeBusy());
- fb1->addPeriod(KDateTime(dt1), KCalCore::Duration(60 * 60));
- fb1->addPeriod(KDateTime(dt2), KCalCore::Duration(60 * 60));
+ fb1->addPeriod(dt1, KCalCore::Duration(60 * 60));
+ fb1->addPeriod(dt2, KCalCore::Duration(60 * 60));
CalendarSupport::FreeBusyItem::Ptr item1(new CalendarSupport::FreeBusyItem(a1, nullptr));
item1->setFreeBusy(fb1);
@@ -67,8 +67,8 @@ void FreeBusyGanttProxyModelTest::testModelValidity()
KCalCore::Attendee::Ptr a2(new KCalCore::Attendee(QStringLiteral("joe"), QStringLiteral("[email protected]")));
KCalCore::FreeBusy::Ptr fb2(new KCalCore::FreeBusy());
- fb2->addPeriod(KDateTime(dt3), KCalCore::Duration(60 * 60));
- fb2->addPeriod(KDateTime(dt4), KCalCore::Duration(60 * 60));
+ fb2->addPeriod(dt3, KCalCore::Duration(60 * 60));
+ fb2->addPeriod(dt4, KCalCore::Duration(60 * 60));
CalendarSupport::FreeBusyItem::Ptr item2(new CalendarSupport::FreeBusyItem(a2, nullptr));
item2->setFreeBusy(fb2);
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 845cd98..e908be9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -113,6 +113,12 @@ PRIVATE
KF5::Codecs
KF5::Ldap
KF5::AkonadiWidgets
+ KF5::IconThemes
+ KF5::Completion
+ KF5::KIOWidgets
+ KF5::TextWidgets
+ KF5::WidgetsAddons
+ KF5::XmlGui
)
target_include_directories(KF5IncidenceEditor INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/IncidenceEditor/;${KDE_INSTALL_INCLUDEDIR_KF5}/incidenceeditor>")
target_include_directories(KF5IncidenceEditor PUBLIC "$<BUILD_INTERFACE:${incidenceeditor_SOURCE_DIR}/src;${incidenceeditor_BINARY_DIR}/src;>")
diff --git a/src/incidencedatetime.cpp b/src/incidencedatetime.cpp
index 6b1c617..b059a70 100644
--- a/src/incidencedatetime.cpp
+++ b/src/incidencedatetime.cpp
@@ -24,7 +24,6 @@
#include <CalendarSupport/KCalPrefs>
-#include <KCalCore/Utils>
#include <KCalUtils/IncidenceFormatter>
#include <QTimeZone>
@@ -55,8 +54,8 @@ static bool incidenceHasDefaultTimes(const KCalCore::Incidence::Ptr &incidence)
return true; // no duration to compare with
}
- const KDateTime start = incidence->dtStart();
- const KDateTime end = incidence->dateTime(KCalCore::Incidence::RoleEnd);
+ const QDateTime start = incidence->dtStart();
+ const QDateTime end = incidence->dateTime(KCalCore::Incidence::RoleEnd);
if (!end.isValid() || !start.isValid()) {
return false;
}
@@ -264,7 +263,7 @@ void IncidenceDateTime::updateStartTime(const QTime &newTime)
return;
}
- KDateTime endDateTime = KCalCore::q2k(currentEndDateTime());
+ QDateTime endDateTime = currentEndDateTime();
const int secsep = mCurrentStartDateTime.secsTo(endDateTime);
mCurrentStartDateTime.setTime(newTime);
if (mUi->mEndCheck->isChecked()) {
@@ -288,7 +287,7 @@ void IncidenceDateTime::updateStartDate(const QDate &newDate)
const bool dateChanged = mCurrentStartDateTime.date().day() != newDate.day()
|| mCurrentStartDateTime.date().month() != newDate.month();
- KDateTime endDateTime = KCalCore::q2k(currentEndDateTime());
+ QDateTime endDateTime = currentEndDateTime();
int daysep = mCurrentStartDateTime.daysTo(endDateTime);
mCurrentStartDateTime.setDate(newDate);
if (mUi->mEndCheck->isChecked()) {
@@ -310,11 +309,11 @@ void IncidenceDateTime::updateStartSpec()
const QDate prevDate = mCurrentStartDateTime.date();
if (mUi->mEndCheck->isChecked()
- && currentEndDateTime().timeZone() == KCalCore::specToZone(mCurrentStartDateTime.timeSpec())) {
+ && currentEndDateTime().timeZone() == mCurrentStartDateTime.timeZone()) {
mUi->mTimeZoneComboEnd->selectTimeZone(mUi->mTimeZoneComboStart->selectedTimeZone());
}
- mCurrentStartDateTime.setTimeSpec(KCalCore::zoneToSpec(mUi->mTimeZoneComboStart->selectedTimeZone()));
+ mCurrentStartDateTime.setTimeZone(mUi->mTimeZoneComboStart->selectedTimeZone());
const bool dateChanged = mCurrentStartDateTime.date().day() != prevDate.day()
|| mCurrentStartDateTime.date().month() != prevDate.month();
@@ -453,7 +452,7 @@ bool IncidenceDateTime::isDirty(const KCalCore::Todo::Ptr &todo) const
}
if (mUi->mStartCheck->isChecked()) {
- // Use mActiveStartTime. This is the KDateTime::Spec selected on load coming from
+ // Use mActiveStartTime. This is the QTimeZone selected on load coming from
// the combobox. We use this one as it can slightly differ (e.g. missing
// country code in the incidence time spec) from the incidence.
if (currentStartDateTime() != mInitialStartDT) {
@@ -591,8 +590,8 @@ void IncidenceDateTime::load(const KCalCore::Event::Ptr &event, bool isTemplate,
setTimes(event->dtStart(), event->dtEnd());
}
} else {
- KDateTime startDT = event->dtStart();
- KDateTime endDT = event->dtEnd();
+ QDateTime startDT = event->dtStart();
+ QDateTime endDT = event->dtEnd();
setDateTimes(startDT, endDT);
}
@@ -638,16 +637,16 @@ void IncidenceDateTime::load(const KCalCore::Journal::Ptr &journal, bool isTempl
if (isTemplate) {
if (templateOverridesTimes) {
// We only use the template times if the user didn't override them.
- setTimes(journal->dtStart(), KDateTime());
+ setTimes(journal->dtStart(), QDateTime());
}
} else {
- KDateTime startDT = journal->dtStart();
+ QDateTime startDT = journal->dtStart();
// Convert UTC to local timezone, if needed (i.e. for kolab #204059)
- if (startDT.isUtc()) {
- startDT = startDT.toLocalZone();
+ if (startDT.timeZone() == QTimeZone::utc()) {
+ startDT = startDT.toLocalTime();
}
- setDateTimes(startDT, KDateTime());
+ setDateTimes(startDT, QDateTime());
}
}
@@ -706,7 +705,7 @@ void IncidenceDateTime::load(const KCalCore::Todo::Ptr &todo, bool isTemplate,
this,
&IncidenceDateTime::checkDirtyStatus);
- const KDateTime rightNow = KDateTime(QDate::currentDate(), QTime::currentTime()).toLocalZone();
+ const QDateTime rightNow = QDateTime::currentDateTime();
if (isTemplate) {
if (templateOverridesTimes) {
@@ -714,8 +713,8 @@ void IncidenceDateTime::load(const KCalCore::Todo::Ptr &todo, bool isTemplate,
setTimes(todo->dtStart(), todo->dateTime(KCalCore::Incidence::RoleEnd));
}
} else {
- const KDateTime endDT = todo->hasDueDate() ? todo->dtDue(true /** first */) : rightNow;
- const KDateTime startDT
+ const QDateTime endDT = todo->hasDueDate() ? todo->dtDue(true /** first */) : rightNow;
+ const QDateTime startDT
= todo->hasStartDate() ? todo->dtStart(true /** first */) : rightNow;
setDateTimes(startDT, endDT);
}
@@ -727,20 +726,19 @@ void IncidenceDateTime::save(const KCalCore::Event::Ptr &event)
event->setAllDay(true);
// TODO: need to change this.
- KDateTime eventDTStart = KCalCore::q2k(currentStartDateTime());
- eventDTStart.setDateOnly(true);
+ QDateTime eventDTStart = currentStartDateTime();
+ event->setAllDay(true);
event->setDtStart(eventDTStart);
- KDateTime eventDTEnd = KCalCore::q2k(currentEndDateTime());
- eventDTEnd.setDateOnly(true);
+ QDateTime eventDTEnd = currentEndDateTime();
event->setDtEnd(eventDTEnd);
} else { // Timed Event
event->setAllDay(false);
// set date/time end
- event->setDtStart(KCalCore::q2k(currentStartDateTime()));
- event->setDtEnd(KCalCore::q2k(currentEndDateTime()));
+ event->setDtStart(currentStartDateTime());
+ event->setDtEnd(currentEndDateTime());
}
// Free == Event::Transparent
@@ -753,24 +751,24 @@ void IncidenceDateTime::save(const KCalCore::Event::Ptr &event)
void IncidenceDateTime::save(const KCalCore::Todo::Ptr &todo)
{
if (mUi->mStartCheck->isChecked()) {
- todo->setDtStart(KCalCore::q2k(currentStartDateTime()));
+ todo->setDtStart(currentStartDateTime());
// Set allday must be executed after setDtStart
todo->setAllDay(mUi->mWholeDayCheck->isChecked());
if (currentStartDateTime() != mInitialStartDT) {
// We don't offer any way to edit the current completed occurrence.
// So, if the start date changes, reset the dtRecurrence
- todo->setDtRecurrence(KCalCore::q2k(currentStartDateTime()));
+ todo->setDtRecurrence(currentStartDateTime());
}
} else {
- todo->setDtStart(KDateTime());
+ todo->setDtStart(QDateTime());
}
if (mUi->mEndCheck->isChecked()) {
- todo->setDtDue(KCalCore::q2k(currentEndDateTime()), true /** first */);
+ todo->setDtDue(currentEndDateTime(), true /** first */);
// Set allday must be executed after setDtDue
todo->setAllDay(mUi->mWholeDayCheck->isChecked());
} else {
- todo->setDtDue(KDateTime());
+ todo->setDtDue(QDateTime());
}
}
@@ -779,40 +777,40 @@ void IncidenceDateTime::save(const KCalCore::Journal::Ptr &journal)
journal->setAllDay(mUi->mWholeDayCheck->isChecked());
if (mUi->mWholeDayCheck->isChecked()) { // All day journal
- KDateTime journalDTStart = KCalCore::q2k(currentStartDateTime());
- journalDTStart.setDateOnly(true);
+ QDateTime journalDTStart = currentStartDateTime();
+ journal->setAllDay(true);
journal->setDtStart(journalDTStart);
} else { // Timed Journal
// set date/time end
- journal->setDtStart(KCalCore::q2k(currentStartDateTime()));
+ journal->setDtStart(currentStartDateTime());
}
}
-void IncidenceDateTime::setDateTimes(const KDateTime &start, const KDateTime &end)
+void IncidenceDateTime::setDateTimes(const QDateTime &start, const QDateTime &end)
{
if (start.isValid()) {
mUi->mStartDateEdit->setDate(start.date());
mUi->mStartTimeEdit->setTime(start.time());
- mUi->mTimeZoneComboStart->selectTimeZone(KCalCore::specToZone(start.timeSpec()));
+ mUi->mTimeZoneComboStart->selectTimeZone(start.timeZone());
} else {
- KDateTime dt(QDate::currentDate(), QTime::currentTime());
+ QDateTime dt = QDateTime::currentDateTime();
mUi->mStartDateEdit->setDate(dt.date());
mUi->mStartTimeEdit->setTime(dt.time());
- mUi->mTimeZoneComboStart->selectTimeZone(KCalCore::specToZone(dt.timeSpec()));
+ mUi->mTimeZoneComboStart->selectTimeZone(dt.timeZone());
}
if (end.isValid()) {
mUi->mEndDateEdit->setDate(end.date());
mUi->mEndTimeEdit->setTime(end.time());
- mUi->mTimeZoneComboEnd->selectTimeZone(KCalCore::specToZone(end.timeSpec()));
+ mUi->mTimeZoneComboEnd->selectTimeZone(end.timeZone());
} else {
- KDateTime dt(QDate::currentDate(), QTime::currentTime().addSecs(60 * 60));
+ QDateTime dt(QDate::currentDate(), QTime::currentTime().addSecs(60 * 60));
mUi->mEndDateEdit->setDate(dt.date());
mUi->mEndTimeEdit->setTime(dt.time());
- mUi->mTimeZoneComboEnd->selectTimeZone(KCalCore::specToZone(dt.timeSpec()));
+ mUi->mTimeZoneComboEnd->selectTimeZone(dt.timeZone());
}
- mCurrentStartDateTime = KCalCore::q2k(currentStartDateTime());
+ mCurrentStartDateTime = currentStartDateTime();
Q_EMIT startDateChanged(start.date());
Q_EMIT startTimeChanged(start.time());
Q_EMIT endDateChanged(end.date());
@@ -864,7 +862,7 @@ void IncidenceDateTime::updateEndToolTips()
}
}
-void IncidenceDateTime::setTimes(const KDateTime &start, const KDateTime &end)
+void IncidenceDateTime::setTimes(const QDateTime &start, const QDateTime &end)
{
// like setDateTimes(), but it set only the start/end time, not the date
// it is used while applying a template to an event.
@@ -874,8 +872,8 @@ void IncidenceDateTime::setTimes(const KDateTime &start, const KDateTime &end)
mUi->mEndTimeEdit->setTime(end.time());
- mUi->mTimeZoneComboStart->selectTimeZone(KCalCore::specToZone(start.timeSpec()));
- mUi->mTimeZoneComboEnd->selectTimeZone(KCalCore::specToZone(end.timeSpec()));
+ mUi->mTimeZoneComboStart->selectTimeZone(start.timeZone());
+ mUi->mTimeZoneComboEnd->selectTimeZone(end.timeZone());
// emitDateTimeStr();
}
diff --git a/src/incidencedatetime.h b/src/incidencedatetime.h
index 672cb95..784f77e 100644
--- a/src/incidencedatetime.h
+++ b/src/incidencedatetime.h
@@ -119,8 +119,8 @@ private:
void save(const KCalCore::Event::Ptr &event);
void save(const KCalCore::Todo::Ptr &todo);
void save(const KCalCore::Journal::Ptr &journal);
- void setDateTimes(const KDateTime &start, const KDateTime &end);
- void setTimes(const KDateTime &start, const KDateTime &end);
+ void setDateTimes(const QDateTime &start, const QDateTime &end);
+ void setTimes(const QDateTime &start, const QDateTime &end);
void setTimeZoneLabelEnabled(bool enable);
bool timeZonesAreLocal(const QDateTime &start, const QDateTime &end);
@@ -140,7 +140,7 @@ private:
* We need to store the current start date/time to be able to update the end
* time appropriate when the start time changes.
*/
- KDateTime mCurrentStartDateTime;
+ QDateTime mCurrentStartDateTime;
/// Remembers state when switching between takes whole day and timed event/to-do.
bool mTimezoneCombosWereVisibile;
diff --git a/src/incidencedefaults.cpp b/src/incidencedefaults.cpp
index 1fcb063..f8f8430 100644
--- a/src/incidencedefaults.cpp
+++ b/src/incidencedefaults.cpp
@@ -157,8 +157,8 @@ void IncidenceDefaultsPrivate::eventDefaults(const KCalCore::Event::Ptr &event)
const QDateTime endDT = mEndDt.isValid() ? mEndDt : startDT.addSecs(defaultDuration);
- event->setDtStart(KDateTime(startDT));
- event->setDtEnd(KDateTime(endDT));
+ event->setDtStart(startDT);
+ event->setDtEnd(endDT);
event->setTransparency(KCalCore::Event::Opaque);
if (KCalPrefs::instance()->defaultEventReminders()) {
@@ -169,7 +169,7 @@ void IncidenceDefaultsPrivate::eventDefaults(const KCalCore::Event::Ptr &event)
void IncidenceDefaultsPrivate::journalDefaults(const KCalCore::Journal::Ptr &journal) const
{
const QDateTime startDT = mStartDt.isValid() ? mStartDt : QDateTime::currentDateTime();
- journal->setDtStart(KDateTime(startDT));
+ journal->setDtStart(startDT);
journal->setAllDay(true);
}
@@ -181,28 +181,28 @@ void IncidenceDefaultsPrivate::todoDefaults(const KCalCore::Todo::Ptr &todo) con
}
if (mEndDt.isValid()) {
- todo->setDtDue(KDateTime(mEndDt), true /** first */);
+ todo->setDtDue(mEndDt, true /** first */);
} else if (relatedTodo && relatedTodo->hasDueDate()) {
todo->setDtDue(relatedTodo->dtDue(true), true /** first */);
todo->setAllDay(relatedTodo->allDay());
} else if (relatedTodo) {
- todo->setDtDue(KDateTime());
+ todo->setDtDue(QDateTime());
} else {
- todo->setDtDue(KDateTime(QDateTime::currentDateTime().addDays(1)), true /** first */);
+ todo->setDtDue(QDateTime::currentDateTime().addDays(1), true /** first */);
}
if (mStartDt.isValid()) {
- todo->setDtStart(KDateTime(mStartDt));
+ todo->setDtStart(mStartDt);
} else if (relatedTodo && !relatedTodo->hasStartDate()) {
- todo->setDtStart(KDateTime());
+ todo->setDtStart(QDateTime());
} else if (relatedTodo && relatedTodo->hasStartDate() &&
relatedTodo->dtStart() <= todo->dtDue()) {
todo->setDtStart(relatedTodo->dtStart());
todo->setAllDay(relatedTodo->allDay());
} else if (!mEndDt.isValid() || (QDateTime::currentDateTime() < mEndDt)) {
- todo->setDtStart(KDateTime(QDateTime::currentDateTime()));
+ todo->setDtStart(QDateTime::currentDateTime());
} else {
- todo->setDtStart(KDateTime(mEndDt.addDays(-1)));
+ todo->setDtStart(mEndDt.addDays(-1));
}
todo->setCompleted(false);
diff --git a/src/incidenceeditor.kcfg b/src/incidenceeditor.kcfg
index c71bfcd..44b3219 100644
--- a/src/incidenceeditor.kcfg
+++ b/src/incidenceeditor.kcfg
@@ -5,7 +5,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
- <include>klocale.h</include>
<kcfgfile name="incidenceeditorrc"/>
<group name="AttachmentHandling">
diff --git a/src/incidencerecurrence.cpp b/src/incidencerecurrence.cpp
index 7308a87..73ff4de 100644
--- a/src/incidencerecurrence.cpp
+++ b/src/incidencerecurrence.cpp
@@ -26,8 +26,6 @@
#include <KLocalizedString>
#include <QLocale>
-#include <KCalCore/Utils>
-
using namespace IncidenceEditorNG;
enum {
@@ -432,12 +430,12 @@ bool IncidenceRecurrence::isValid() const
// Check if the incidence will occur at least once
if (incidence->recurs()) {
// dtStart for events, dtDue for to-dos
- const KDateTime referenceDate
+ const QDateTime referenceDate
= incidence->dateTime(KCalCore::Incidence::RoleRecurrenceStart);
if (referenceDate.isValid()) {
- if (!(incidence->recurrence()->recursOn(referenceDate.date(), KCalCore::specToZone(referenceDate.timeSpec()))
- || incidence->recurrence()->getNextDateTime(KCalCore::k2q(referenceDate)).isValid())) {
+ if (!(incidence->recurrence()->recursOn(referenceDate.date(), referenceDate.timeZone())
+ || incidence->recurrence()->getNextDateTime(referenceDate).isValid())) {
mLastErrorString = i18n("A recurring event or to-do must occur at least once. "
"Adjust the recurring parameters.");
qCDebug(INCIDENCEEDITOR_LOG) << mLastErrorString;