diff options
author | Rémi Nicole <nicole@kolabsystems.com> | 2018-05-06 17:42:37 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-06 17:52:51 +0200 |
commit | 90a8d33f7c17c802730fd9b978db0e32d28a7dff (patch) | |
tree | d270feeb64815da8de3ffb544b14af362424c279 /common/todopreprocessor.cpp | |
parent | 3d998856895f0e82a4d0eadd398dafbe1d027e34 (diff) | |
download | sink-90a8d33f7c17c802730fd9b978db0e32d28a7dff.tar.gz sink-90a8d33f7c17c802730fd9b978db0e32d28a7dff.zip |
Implement Todo entity type
Summary:
Some notes:
- Needed to specialize some flatbuffers related functions for serializing QStringList and int
- Removed useless qWarnings in caldav test
- Rename EventSynchronizer -> CalDAVSynchronizer since it also synchronizes Calendars and Todos (and more to come!)
Reviewers: cmollekopf
Tags: #sink
Differential Revision: https://phabricator.kde.org/D12695
Diffstat (limited to 'common/todopreprocessor.cpp')
-rw-r--r-- | common/todopreprocessor.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/common/todopreprocessor.cpp b/common/todopreprocessor.cpp new file mode 100644 index 0000000..fe99953 --- /dev/null +++ b/common/todopreprocessor.cpp | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * Copyright (C) 2018 Rémi Nicole <minijackson@riseup.net> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the | ||
17 | * Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include "todopreprocessor.h" | ||
22 | |||
23 | #include <KCalCore/ICalFormat> | ||
24 | |||
25 | void TodoPropertyExtractor::updatedIndexedProperties(Todo &todo, const QByteArray &rawIcal) | ||
26 | { | ||
27 | auto incidence = KCalCore::ICalFormat().readIncidence(rawIcal); | ||
28 | |||
29 | if(!incidence) { | ||
30 | SinkWarning() << "Invalid ICal to process, ignoring..."; | ||
31 | return; | ||
32 | } | ||
33 | |||
34 | if(incidence->type() != KCalCore::IncidenceBase::IncidenceType::TypeTodo) { | ||
35 | SinkWarning() << "ICal to process is not of type `Todo`, ignoring..."; | ||
36 | return; | ||
37 | } | ||
38 | |||
39 | auto icalTodo = dynamic_cast<const KCalCore::Todo *>(incidence.data()); | ||
40 | // Should be guaranteed by the incidence->type() condition above. | ||
41 | Q_ASSERT(icalTodo); | ||
42 | |||
43 | SinkTrace() << "Extracting properties for todo:" << icalTodo->summary(); | ||
44 | |||
45 | todo.setExtractedUid(icalTodo->uid()); | ||
46 | todo.setExtractedSummary(icalTodo->summary()); | ||
47 | todo.setExtractedDescription(icalTodo->description()); | ||
48 | |||
49 | // Sets invalid QDateTime if not defined | ||
50 | todo.setExtractedCompletedDate(icalTodo->completed()); | ||
51 | todo.setExtractedDueDate(icalTodo->dtDue()); | ||
52 | todo.setExtractedStartDate(icalTodo->dtStart()); | ||
53 | |||
54 | todo.setExtractedStatus(icalTodo->customStatus()); | ||
55 | todo.setExtractedPriority(icalTodo->priority()); | ||
56 | todo.setExtractedCategories(icalTodo->categories()); | ||
57 | } | ||
58 | |||
59 | void TodoPropertyExtractor::newEntity(Todo &todo) | ||
60 | { | ||
61 | updatedIndexedProperties(todo, todo.getIcal()); | ||
62 | } | ||
63 | |||
64 | void TodoPropertyExtractor::modifiedEntity(const Todo &oldTodo, Todo &newTodo) | ||
65 | { | ||
66 | updatedIndexedProperties(newTodo, newTodo.getIcal()); | ||
67 | } | ||