Changeset View
Changeset View
Standalone View
Standalone View
tests/testlib/gentodo.cpp
Show All 19 Lines | 1 | /* This file is part of Zanshin | |||
---|---|---|---|---|---|
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
21 | USA. | 21 | USA. | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #include "gentodo.h" | 24 | #include "gentodo.h" | ||
25 | 25 | | |||
26 | #include <KCalCore/Todo> | 26 | #include <KCalCore/Todo> | ||
27 | #include <QDate> | 27 | #include <QDate> | ||
28 | #include <kcalcore_version.h> | ||||
29 | #if KCALCORE_VERSION < QT_VERSION_CHECK(5, 6, 80) | ||||
28 | #include <KDateTime> | 30 | #include <KDateTime> | ||
31 | #endif | ||||
29 | 32 | | |||
30 | using namespace Testlib; | 33 | using namespace Testlib; | ||
31 | 34 | | |||
32 | GenTodo::GenTodo(const Akonadi::Item &item) | 35 | GenTodo::GenTodo(const Akonadi::Item &item) | ||
33 | : m_item(item) | 36 | : m_item(item) | ||
34 | { | 37 | { | ||
35 | m_item.setMimeType(KCalCore::Todo::todoMimeType()); | 38 | m_item.setMimeType(KCalCore::Todo::todoMimeType()); | ||
36 | if (!m_item.hasPayload<KCalCore::Todo::Ptr>()) | 39 | if (!m_item.hasPayload<KCalCore::Todo::Ptr>()) | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | |||||
101 | } | 104 | } | ||
102 | 105 | | |||
103 | GenTodo &GenTodo::done(bool value) | 106 | GenTodo &GenTodo::done(bool value) | ||
104 | { | 107 | { | ||
105 | m_item.payload<KCalCore::Todo::Ptr>()->setCompleted(value); | 108 | m_item.payload<KCalCore::Todo::Ptr>()->setCompleted(value); | ||
106 | return *this; | 109 | return *this; | ||
107 | } | 110 | } | ||
108 | 111 | | |||
112 | #if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 6, 80) | ||||
113 | | ||||
114 | template <typename T> | ||||
115 | static QDateTime KDateTime(const T& input) { | ||||
116 | QDateTime dt(input); | ||||
117 | dt.setTimeSpec(Qt::UTC); | ||||
118 | return dt; | ||||
119 | } | ||||
120 | | ||||
121 | #endif | ||||
122 | | ||||
109 | GenTodo &GenTodo::withDoneDate(const QString &date) | 123 | GenTodo &GenTodo::withDoneDate(const QString &date) | ||
110 | { | 124 | { | ||
111 | m_item.payload<KCalCore::Todo::Ptr>()->setCompleted(KDateTime(QDate::fromString(date, Qt::ISODate))); | 125 | m_item.payload<KCalCore::Todo::Ptr>()->setCompleted(KDateTime(QDate::fromString(date, Qt::ISODate))); | ||
112 | return *this; | 126 | return *this; | ||
113 | } | 127 | } | ||
114 | 128 | | |||
115 | GenTodo &GenTodo::withDoneDate(const QDateTime &date) | 129 | GenTodo &GenTodo::withDoneDate(const QDateTime &date) | ||
116 | { | 130 | { | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |