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/propertymapper.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/propertymapper.cpp')
-rw-r--r-- | common/propertymapper.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
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) { |