diff options
author | Minijackson <minijackson@riseup.net> | 2018-05-02 16:44:11 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-05-02 16:44:11 +0200 |
commit | 29695a1949c4f846f0d4ed21a400f3b864518ed1 (patch) | |
tree | 649ef0093dbd470fbb673ca525f53906fd79fd39 | |
parent | 4d9192f4906989a0144d08d1ddb091dfa6efd9ed (diff) | |
download | sink-29695a1949c4f846f0d4ed21a400f3b864518ed1.tar.gz sink-29695a1949c4f846f0d4ed21a400f3b864518ed1.zip |
Really add Todo entity type
-rw-r--r-- | common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 13 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 17 | ||||
-rw-r--r-- | common/domain/applicationdomaintype_p.h | 2 | ||||
-rw-r--r-- | common/domain/propertyregistry.cpp | 6 | ||||
-rw-r--r-- | common/domain/todo.fbs | 18 | ||||
-rw-r--r-- | common/domain/typeimplementations.cpp | 35 | ||||
-rw-r--r-- | common/domain/typeimplementations.h | 12 | ||||
-rw-r--r-- | common/propertymapper.cpp | 36 | ||||
-rw-r--r-- | common/propertymapper.h | 8 | ||||
-rw-r--r-- | common/todopreprocessor.cpp | 67 | ||||
-rw-r--r-- | common/todopreprocessor.h | 35 |
12 files changed, 251 insertions, 0 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 51145fd..5077bbb 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -71,6 +71,7 @@ set(command_SRCS | |||
71 | contactpreprocessor.cpp | 71 | contactpreprocessor.cpp |
72 | mailpreprocessor.cpp | 72 | mailpreprocessor.cpp |
73 | eventpreprocessor.cpp | 73 | eventpreprocessor.cpp |
74 | todopreprocessor.cpp | ||
74 | specialpurposepreprocessor.cpp | 75 | specialpurposepreprocessor.cpp |
75 | datastorequery.cpp | 76 | datastorequery.cpp |
76 | storage/entitystore.cpp | 77 | storage/entitystore.cpp |
@@ -105,6 +106,7 @@ generate_flatbuffers( | |||
105 | domain/contact | 106 | domain/contact |
106 | domain/addressbook | 107 | domain/addressbook |
107 | domain/event | 108 | domain/event |
109 | domain/todo | ||
108 | domain/calendar | 110 | domain/calendar |
109 | domain/mail | 111 | domain/mail |
110 | domain/folder | 112 | domain/folder |
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 78d46ee..b1469e1 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -132,6 +132,19 @@ SINK_REGISTER_PROPERTY(Event, EndTime); | |||
132 | SINK_REGISTER_PROPERTY(Event, Ical); | 132 | SINK_REGISTER_PROPERTY(Event, Ical); |
133 | SINK_REGISTER_PROPERTY(Event, Calendar); | 133 | SINK_REGISTER_PROPERTY(Event, Calendar); |
134 | 134 | ||
135 | SINK_REGISTER_ENTITY(Todo); | ||
136 | SINK_REGISTER_PROPERTY(Todo, Uid); | ||
137 | SINK_REGISTER_PROPERTY(Todo, Summary); | ||
138 | SINK_REGISTER_PROPERTY(Todo, Description); | ||
139 | SINK_REGISTER_PROPERTY(Todo, CompletedDate); | ||
140 | SINK_REGISTER_PROPERTY(Todo, DueDate); | ||
141 | SINK_REGISTER_PROPERTY(Todo, StartDate); | ||
142 | SINK_REGISTER_PROPERTY(Todo, Status); | ||
143 | SINK_REGISTER_PROPERTY(Todo, Priority); | ||
144 | SINK_REGISTER_PROPERTY(Todo, Categories); | ||
145 | SINK_REGISTER_PROPERTY(Todo, Ical); | ||
146 | SINK_REGISTER_PROPERTY(Todo, Calendar); | ||
147 | |||
135 | SINK_REGISTER_ENTITY(Calendar); | 148 | SINK_REGISTER_ENTITY(Calendar); |
136 | SINK_REGISTER_PROPERTY(Calendar, Name); | 149 | SINK_REGISTER_PROPERTY(Calendar, Name); |
137 | 150 | ||
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 39e66ab..93de8f5 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -407,6 +407,17 @@ struct SINK_EXPORT Event : public Entity { | |||
407 | 407 | ||
408 | struct SINK_EXPORT Todo : public Entity { | 408 | struct SINK_EXPORT Todo : public Entity { |
409 | SINK_ENTITY(Todo, todo); | 409 | SINK_ENTITY(Todo, todo); |
410 | SINK_EXTRACTED_PROPERTY(QString, Uid, uid); | ||
411 | SINK_EXTRACTED_PROPERTY(QString, Summary, summary); | ||
412 | SINK_EXTRACTED_PROPERTY(QString, Description, description); | ||
413 | SINK_EXTRACTED_PROPERTY(QDateTime, CompletedDate, completedDate); | ||
414 | SINK_EXTRACTED_PROPERTY(QDateTime, DueDate, dueDate); | ||
415 | SINK_EXTRACTED_PROPERTY(QDateTime, StartDate, startDate); | ||
416 | SINK_EXTRACTED_PROPERTY(QString, Status, status); | ||
417 | SINK_EXTRACTED_PROPERTY(int, Priority, priority); | ||
418 | SINK_EXTRACTED_PROPERTY(QStringList, Categories, categories); | ||
419 | SINK_PROPERTY(QByteArray, Ical, ical); | ||
420 | SINK_REFERENCE_PROPERTY(Calendar, Calendar, calendar); | ||
410 | }; | 421 | }; |
411 | 422 | ||
412 | struct SINK_EXPORT Folder : public Entity { | 423 | struct SINK_EXPORT Folder : public Entity { |
@@ -506,6 +517,11 @@ namespace Event { | |||
506 | static constexpr const char *calendar = "calendar"; | 517 | static constexpr const char *calendar = "calendar"; |
507 | static constexpr const char *storage = "event.storage"; | 518 | static constexpr const char *storage = "event.storage"; |
508 | }; | 519 | }; |
520 | namespace Todo { | ||
521 | static constexpr const char *todo = "todo"; | ||
522 | static constexpr const char *calendar = "calendar"; | ||
523 | static constexpr const char *storage = "todo.storage"; | ||
524 | }; | ||
509 | }; | 525 | }; |
510 | 526 | ||
511 | namespace SpecialPurpose { | 527 | namespace SpecialPurpose { |
@@ -558,6 +574,7 @@ class SINK_EXPORT TypeImplementation; | |||
558 | REGISTER_TYPE(Sink::ApplicationDomain::Contact) \ | 574 | REGISTER_TYPE(Sink::ApplicationDomain::Contact) \ |
559 | REGISTER_TYPE(Sink::ApplicationDomain::Addressbook) \ | 575 | REGISTER_TYPE(Sink::ApplicationDomain::Addressbook) \ |
560 | REGISTER_TYPE(Sink::ApplicationDomain::Event) \ | 576 | REGISTER_TYPE(Sink::ApplicationDomain::Event) \ |
577 | REGISTER_TYPE(Sink::ApplicationDomain::Todo) \ | ||
561 | REGISTER_TYPE(Sink::ApplicationDomain::Calendar) \ | 578 | REGISTER_TYPE(Sink::ApplicationDomain::Calendar) \ |
562 | REGISTER_TYPE(Sink::ApplicationDomain::Mail) \ | 579 | REGISTER_TYPE(Sink::ApplicationDomain::Mail) \ |
563 | REGISTER_TYPE(Sink::ApplicationDomain::Folder) \ | 580 | REGISTER_TYPE(Sink::ApplicationDomain::Folder) \ |
diff --git a/common/domain/applicationdomaintype_p.h b/common/domain/applicationdomaintype_p.h index 734ac3e..248f6f0 100644 --- a/common/domain/applicationdomaintype_p.h +++ b/common/domain/applicationdomaintype_p.h | |||
@@ -38,6 +38,8 @@ struct TypeHelper { | |||
38 | return Func<Sink::ApplicationDomain::Mail>{}(std::forward<Args...>(args...)); | 38 | return Func<Sink::ApplicationDomain::Mail>{}(std::forward<Args...>(args...)); |
39 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>()) { | 39 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>()) { |
40 | return Func<Sink::ApplicationDomain::Event>{}(std::forward<Args...>(args...)); | 40 | return Func<Sink::ApplicationDomain::Event>{}(std::forward<Args...>(args...)); |
41 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Todo>()) { | ||
42 | return Func<Sink::ApplicationDomain::Todo>{}(std::forward<Args...>(args...)); | ||
41 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Calendar>()) { | 43 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Calendar>()) { |
42 | return Func<Sink::ApplicationDomain::Calendar>{}(std::forward<Args...>(args...)); | 44 | return Func<Sink::ApplicationDomain::Calendar>{}(std::forward<Args...>(args...)); |
43 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Contact>()) { | 45 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Contact>()) { |
diff --git a/common/domain/propertyregistry.cpp b/common/domain/propertyregistry.cpp index d929d68..00bbb1d 100644 --- a/common/domain/propertyregistry.cpp +++ b/common/domain/propertyregistry.cpp | |||
@@ -75,6 +75,12 @@ QVariant parseString<QList<QByteArray>>(const QString &s) | |||
75 | } | 75 | } |
76 | 76 | ||
77 | template <> | 77 | template <> |
78 | QVariant parseString<QStringList>(const QString &s) | ||
79 | { | ||
80 | return s.split(','); | ||
81 | } | ||
82 | |||
83 | template <> | ||
78 | QVariant parseString<QDateTime>(const QString &s) | 84 | QVariant parseString<QDateTime>(const QString &s) |
79 | { | 85 | { |
80 | return QVariant::fromValue(QDateTime::fromString(s, Qt::ISODate)); | 86 | return QVariant::fromValue(QDateTime::fromString(s, Qt::ISODate)); |
diff --git a/common/domain/todo.fbs b/common/domain/todo.fbs new file mode 100644 index 0000000..b448cae --- /dev/null +++ b/common/domain/todo.fbs | |||
@@ -0,0 +1,18 @@ | |||
1 | namespace Sink.ApplicationDomain.Buffer; | ||
2 | |||
3 | table Todo { | ||
4 | uid:string; | ||
5 | summary:string; | ||
6 | description:string; | ||
7 | completedDate:string; | ||
8 | dueDate:string; | ||
9 | startDate:string; | ||
10 | status:string; | ||
11 | priority:int; | ||
12 | categories:[string]; | ||
13 | ical:string; | ||
14 | calendar:string; | ||
15 | } | ||
16 | |||
17 | root_type Todo; | ||
18 | file_identifier "AKFB"; | ||
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp index 615c8e8..b584138 100644 --- a/common/domain/typeimplementations.cpp +++ b/common/domain/typeimplementations.cpp | |||
@@ -67,6 +67,10 @@ typedef IndexConfig<Event, | |||
67 | ValueIndex<Event::Uid> | 67 | ValueIndex<Event::Uid> |
68 | > EventIndexConfig; | 68 | > EventIndexConfig; |
69 | 69 | ||
70 | typedef IndexConfig<Todo, | ||
71 | ValueIndex<Todo::Uid> | ||
72 | > TodoIndexConfig; | ||
73 | |||
70 | typedef IndexConfig<Calendar, | 74 | typedef IndexConfig<Calendar, |
71 | ValueIndex<Calendar::Name> | 75 | ValueIndex<Calendar::Name> |
72 | > CalendarIndexConfig; | 76 | > CalendarIndexConfig; |
@@ -218,6 +222,37 @@ void TypeImplementation<Event>::configure(IndexPropertyMapper &) | |||
218 | } | 222 | } |
219 | 223 | ||
220 | 224 | ||
225 | void TypeImplementation<Todo>::configure(TypeIndex &index) | ||
226 | { | ||
227 | TodoIndexConfig::configure(index); | ||
228 | } | ||
229 | |||
230 | QMap<QByteArray, int> TypeImplementation<Todo>::typeDatabases() | ||
231 | { | ||
232 | return merge(QMap<QByteArray, int>{{QByteArray{Todo::name} + ".main", 0}}, TodoIndexConfig::databases()); | ||
233 | } | ||
234 | |||
235 | void TypeImplementation<Todo>::configure(PropertyMapper &propertyMapper) | ||
236 | { | ||
237 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Uid, uid); | ||
238 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Summary, summary); | ||
239 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Description, description); | ||
240 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, CompletedDate, completedDate); | ||
241 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, DueDate, dueDate); | ||
242 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, StartDate, startDate); | ||
243 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Status, status); | ||
244 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Priority, priority); | ||
245 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Categories, categories); | ||
246 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Ical, ical); | ||
247 | SINK_REGISTER_SERIALIZER(propertyMapper, Todo, Calendar, calendar); | ||
248 | } | ||
249 | |||
250 | void TypeImplementation<Todo>::configure(IndexPropertyMapper &) | ||
251 | { | ||
252 | |||
253 | } | ||
254 | |||
255 | |||
221 | void TypeImplementation<Calendar>::configure(TypeIndex &index) | 256 | void TypeImplementation<Calendar>::configure(TypeIndex &index) |
222 | { | 257 | { |
223 | CalendarIndexConfig::configure(index); | 258 | CalendarIndexConfig::configure(index); |
diff --git a/common/domain/typeimplementations.h b/common/domain/typeimplementations.h index 672e83a..dea7426 100644 --- a/common/domain/typeimplementations.h +++ b/common/domain/typeimplementations.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "mail_generated.h" | 24 | #include "mail_generated.h" |
25 | #include "folder_generated.h" | 25 | #include "folder_generated.h" |
26 | #include "event_generated.h" | 26 | #include "event_generated.h" |
27 | #include "todo_generated.h" | ||
27 | #include "calendar_generated.h" | 28 | #include "calendar_generated.h" |
28 | #include "contact_generated.h" | 29 | #include "contact_generated.h" |
29 | #include "addressbook_generated.h" | 30 | #include "addressbook_generated.h" |
@@ -97,6 +98,17 @@ public: | |||
97 | }; | 98 | }; |
98 | 99 | ||
99 | template<> | 100 | template<> |
101 | class SINK_EXPORT TypeImplementation<Sink::ApplicationDomain::Todo> { | ||
102 | public: | ||
103 | typedef Sink::ApplicationDomain::Buffer::Todo Buffer; | ||
104 | typedef Sink::ApplicationDomain::Buffer::EventBuilder BufferBuilder; | ||
105 | static void configure(TypeIndex &); | ||
106 | static void configure(PropertyMapper &); | ||
107 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
108 | static QMap<QByteArray, int> typeDatabases(); | ||
109 | }; | ||
110 | |||
111 | template<> | ||
100 | class SINK_EXPORT TypeImplementation<Sink::ApplicationDomain::Calendar> { | 112 | class SINK_EXPORT TypeImplementation<Sink::ApplicationDomain::Calendar> { |
101 | public: | 113 | public: |
102 | typedef Sink::ApplicationDomain::Buffer::Calendar Buffer; | 114 | typedef Sink::ApplicationDomain::Buffer::Calendar Buffer; |
diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp index 7c313cc..f9f9c9b 100644 --- a/common/propertymapper.cpp +++ b/common/propertymapper.cpp | |||
@@ -82,6 +82,21 @@ flatbuffers::uoffset_t variantToProperty<QByteArrayList>(const QVariant &propert | |||
82 | } | 82 | } |
83 | 83 | ||
84 | template <> | 84 | template <> |
85 | flatbuffers::uoffset_t variantToProperty<QStringList>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
86 | { | ||
87 | if (property.isValid()) { | ||
88 | const auto list = property.value<QStringList>(); | ||
89 | std::vector<flatbuffers::Offset<flatbuffers::String>> vector; | ||
90 | for (const auto &value : list) { | ||
91 | auto offset = fbb.CreateString(value.toStdString()); | ||
92 | vector.push_back(offset); | ||
93 | } | ||
94 | return fbb.CreateVector(vector).o; | ||
95 | } | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | template <> | ||
85 | flatbuffers::uoffset_t variantToProperty<Sink::ApplicationDomain::Mail::Contact>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | 100 | flatbuffers::uoffset_t variantToProperty<Sink::ApplicationDomain::Mail::Contact>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) |
86 | { | 101 | { |
87 | if (property.isValid()) { | 102 | if (property.isValid()) { |
@@ -187,6 +202,21 @@ QVariant propertyToVariant<QByteArrayList>(const flatbuffers::Vector<flatbuffers | |||
187 | } | 202 | } |
188 | 203 | ||
189 | template <> | 204 | template <> |
205 | QVariant propertyToVariant<QStringList>(const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *property) | ||
206 | { | ||
207 | if (property) { | ||
208 | QStringList list; | ||
209 | for (auto it = property->begin(); it != property->end();) { | ||
210 | // We have to copy the memory, otherwise it would become eventually invalid | ||
211 | list << QString::fromStdString((*it)->str()); | ||
212 | it.operator++(); | ||
213 | } | ||
214 | return QVariant::fromValue(list); | ||
215 | } | ||
216 | return QVariant(); | ||
217 | } | ||
218 | |||
219 | template <> | ||
190 | QVariant propertyToVariant<Sink::ApplicationDomain::Mail::Contact>(const Sink::ApplicationDomain::Buffer::MailContact *property) | 220 | QVariant propertyToVariant<Sink::ApplicationDomain::Mail::Contact>(const Sink::ApplicationDomain::Buffer::MailContact *property) |
191 | { | 221 | { |
192 | if (property) { | 222 | if (property) { |
@@ -232,6 +262,12 @@ QVariant propertyToVariant<bool>(uint8_t property) | |||
232 | } | 262 | } |
233 | 263 | ||
234 | template <> | 264 | template <> |
265 | QVariant propertyToVariant<int>(uint8_t property) | ||
266 | { | ||
267 | return static_cast<int>(property); | ||
268 | } | ||
269 | |||
270 | template <> | ||
235 | QVariant propertyToVariant<QDateTime>(const flatbuffers::String *property) | 271 | QVariant propertyToVariant<QDateTime>(const flatbuffers::String *property) |
236 | { | 272 | { |
237 | if (property) { | 273 | if (property) { |
diff --git a/common/propertymapper.h b/common/propertymapper.h index fd24278..49224fa 100644 --- a/common/propertymapper.h +++ b/common/propertymapper.h | |||
@@ -131,6 +131,14 @@ private: | |||
131 | } | 131 | } |
132 | 132 | ||
133 | template <typename T, typename BufferBuilder> | 133 | template <typename T, typename BufferBuilder> |
134 | void addWriteMapping(void (BufferBuilder::*f)(int)) | ||
135 | { | ||
136 | addWriteMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(void *builder)> { | ||
137 | return [value, f](void *builder) { (static_cast<BufferBuilder*>(builder)->*f)(value.value<typename T::Type>()); }; | ||
138 | }); | ||
139 | } | ||
140 | |||
141 | template <typename T, typename BufferBuilder> | ||
134 | void addWriteMapping(void (BufferBuilder::*f)(bool)) | 142 | void addWriteMapping(void (BufferBuilder::*f)(bool)) |
135 | { | 143 | { |
136 | addWriteMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(void *builder)> { | 144 | addWriteMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(void *builder)> { |
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 | } | ||
diff --git a/common/todopreprocessor.h b/common/todopreprocessor.h new file mode 100644 index 0000000..ccb9f1a --- /dev/null +++ b/common/todopreprocessor.h | |||
@@ -0,0 +1,35 @@ | |||
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 "pipeline.h" | ||
22 | #include "sink_export.h" | ||
23 | |||
24 | class SINK_EXPORT TodoPropertyExtractor : public Sink::EntityPreprocessor<Sink::ApplicationDomain::Todo> | ||
25 | { | ||
26 | using Todo = Sink::ApplicationDomain::Todo; | ||
27 | |||
28 | public: | ||
29 | virtual ~TodoPropertyExtractor() {} | ||
30 | virtual void newEntity(Todo &todo) Q_DECL_OVERRIDE; | ||
31 | virtual void modifiedEntity(const Todo &oldTodo, Todo &newTodo) Q_DECL_OVERRIDE; | ||
32 | |||
33 | private: | ||
34 | static void updatedIndexedProperties(Todo &todo, const QByteArray &rawIcal); | ||
35 | }; | ||