Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi/akonadiserializer.cpp
Show All 24 Lines | |||||
25 | 25 | | |||
26 | #include "akonadiserializer.h" | 26 | #include "akonadiserializer.h" | ||
27 | 27 | | |||
28 | #include <AkonadiCore/Collection> | 28 | #include <AkonadiCore/Collection> | ||
29 | #include <AkonadiCore/EntityDisplayAttribute> | 29 | #include <AkonadiCore/EntityDisplayAttribute> | ||
30 | #include <AkonadiCore/Item> | 30 | #include <AkonadiCore/Item> | ||
31 | #include <Akonadi/Notes/NoteUtils> | 31 | #include <Akonadi/Notes/NoteUtils> | ||
32 | #include <KCalCore/Todo> | 32 | #include <KCalCore/Todo> | ||
33 | #include <kcalcore_version.h> | ||||
33 | #include <KMime/Message> | 34 | #include <KMime/Message> | ||
34 | #include <QMimeDatabase> | 35 | #include <QMimeDatabase> | ||
36 | #if KCALCORE_VERSION < QT_VERSION_CHECK(5, 6, 80) | ||||
35 | #include <KDateTime> | 37 | #include <KDateTime> | ||
38 | #endif | ||||
36 | 39 | | |||
37 | #include <numeric> | 40 | #include <numeric> | ||
38 | 41 | | |||
39 | #include "utils/mem_fn.h" | 42 | #include "utils/mem_fn.h" | ||
40 | 43 | | |||
41 | #include "akonadi/akonadiapplicationselectedattribute.h" | 44 | #include "akonadi/akonadiapplicationselectedattribute.h" | ||
42 | #include "akonadi/akonaditimestampattribute.h" | 45 | #include "akonadi/akonaditimestampattribute.h" | ||
43 | 46 | | |||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 191 | { | |||
189 | if (!isTaskItem(item)) | 192 | if (!isTaskItem(item)) | ||
190 | return; | 193 | return; | ||
191 | 194 | | |||
192 | auto todo = item.payload<KCalCore::Todo::Ptr>(); | 195 | auto todo = item.payload<KCalCore::Todo::Ptr>(); | ||
193 | 196 | | |||
194 | task->setTitle(todo->summary()); | 197 | task->setTitle(todo->summary()); | ||
195 | task->setText(todo->description()); | 198 | task->setText(todo->description()); | ||
196 | task->setDone(todo->isCompleted()); | 199 | task->setDone(todo->isCompleted()); | ||
200 | #if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 6, 80) | ||||
201 | task->setDoneDate(todo->completed().toUTC()); | ||||
202 | task->setStartDate(todo->dtStart().toUTC()); | ||||
203 | task->setDueDate(todo->dtDue().toUTC()); | ||||
204 | #else | ||||
197 | task->setDoneDate(todo->completed().dateTime().toUTC()); | 205 | task->setDoneDate(todo->completed().dateTime().toUTC()); | ||
198 | task->setStartDate(todo->dtStart().dateTime().toUTC()); | 206 | task->setStartDate(todo->dtStart().dateTime().toUTC()); | ||
199 | task->setDueDate(todo->dtDue().dateTime().toUTC()); | 207 | task->setDueDate(todo->dtDue().dateTime().toUTC()); | ||
208 | #endif | ||||
200 | task->setProperty("itemId", item.id()); | 209 | task->setProperty("itemId", item.id()); | ||
201 | task->setProperty("parentCollectionId", item.parentCollection().id()); | 210 | task->setProperty("parentCollectionId", item.parentCollection().id()); | ||
202 | task->setProperty("todoUid", todo->uid()); | 211 | task->setProperty("todoUid", todo->uid()); | ||
203 | task->setProperty("relatedUid", todo->relatedTo()); | 212 | task->setProperty("relatedUid", todo->relatedTo()); | ||
204 | task->setRunning(todo->customProperty("Zanshin", "Running") == QLatin1String("1")); | 213 | task->setRunning(todo->customProperty("Zanshin", "Running") == QLatin1String("1")); | ||
205 | 214 | | |||
206 | switch (todo->recurrence()->recurrenceType()) { | 215 | switch (todo->recurrence()->recurrenceType()) { | ||
207 | case KCalCore::Recurrence::rDaily: | 216 | case KCalCore::Recurrence::rDaily: | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 262 | { | |||
256 | 265 | | |||
257 | auto todo = item.payload<KCalCore::Todo::Ptr>(); | 266 | auto todo = item.payload<KCalCore::Todo::Ptr>(); | ||
258 | if (todo->relatedTo() == task->property("todoUid")) | 267 | if (todo->relatedTo() == task->property("todoUid")) | ||
259 | return true; | 268 | return true; | ||
260 | 269 | | |||
261 | return false; | 270 | return false; | ||
262 | } | 271 | } | ||
263 | 272 | | |||
273 | #if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 6, 80) | ||||
274 | #define KDateTime QDateTime | ||||
275 | #endif | ||||
276 | | ||||
277 | | ||||
264 | Akonadi::Item Serializer::createItemFromTask(Domain::Task::Ptr task) | 278 | Akonadi::Item Serializer::createItemFromTask(Domain::Task::Ptr task) | ||
265 | { | 279 | { | ||
266 | auto todo = KCalCore::Todo::Ptr::create(); | 280 | auto todo = KCalCore::Todo::Ptr::create(); | ||
267 | 281 | | |||
268 | todo->setSummary(task->title()); | 282 | todo->setSummary(task->title()); | ||
269 | todo->setDescription(task->text()); | 283 | todo->setDescription(task->text()); | ||
270 | 284 | | |||
285 | #if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 6, 80) | ||||
286 | QDateTime start = task->startDate(); | ||||
287 | start.setTimeSpec(Qt::UTC); | ||||
288 | todo->setDtStart(start); | ||||
289 | QDateTime due = task->dueDate(); | ||||
290 | due.setTimeSpec(Qt::UTC); | ||||
291 | todo->setDtDue(due); | ||||
292 | todo->setAllDay(true); | ||||
293 | #else | ||||
271 | todo->setDtStart(KDateTime(task->startDate(), KDateTime::UTC)); | 294 | todo->setDtStart(KDateTime(task->startDate(), KDateTime::UTC)); | ||
272 | todo->setDtDue(KDateTime(task->dueDate(), KDateTime::UTC)); | 295 | todo->setDtDue(KDateTime(task->dueDate(), KDateTime::UTC)); | ||
296 | #endif | ||||
273 | 297 | | |||
274 | if (task->property("todoUid").isValid()) { | 298 | if (task->property("todoUid").isValid()) { | ||
275 | todo->setUid(task->property("todoUid").toString()); | 299 | todo->setUid(task->property("todoUid").toString()); | ||
276 | } | 300 | } | ||
277 | 301 | | |||
278 | if (task->property("relatedUid").isValid()) { | 302 | if (task->property("relatedUid").isValid()) { | ||
279 | todo->setRelatedTo(task->property("relatedUid").toString()); | 303 | todo->setRelatedTo(task->property("relatedUid").toString()); | ||
280 | } | 304 | } | ||
▲ Show 20 Lines • Show All 404 Lines • Show Last 20 Lines |