diff options
Diffstat (limited to 'common/domain/event.cpp')
-rw-r--r-- | common/domain/event.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/common/domain/event.cpp b/common/domain/event.cpp index 86100b7..ea0931c 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp | |||
@@ -20,15 +20,19 @@ | |||
20 | 20 | ||
21 | #include <QVector> | 21 | #include <QVector> |
22 | #include <QByteArray> | 22 | #include <QByteArray> |
23 | #include <QString> | ||
23 | 24 | ||
24 | #include "../resultset.h" | 25 | #include "../resultset.h" |
25 | #include "../index.h" | 26 | #include "../index.h" |
26 | #include "../storage.h" | 27 | #include "../storage.h" |
27 | #include "../log.h" | 28 | #include "../log.h" |
29 | #include "../propertymapper.h" | ||
30 | |||
31 | #include "event_generated.h" | ||
28 | 32 | ||
29 | using namespace Akonadi2::ApplicationDomain; | 33 | using namespace Akonadi2::ApplicationDomain; |
30 | 34 | ||
31 | ResultSet EventImplementation::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier) | 35 | ResultSet TypeImplementation<Event>::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier) |
32 | { | 36 | { |
33 | QVector<QByteArray> keys; | 37 | QVector<QByteArray> keys; |
34 | if (query.propertyFilter.contains("uid")) { | 38 | if (query.propertyFilter.contains("uid")) { |
@@ -43,7 +47,7 @@ ResultSet EventImplementation::queryIndexes(const Akonadi2::Query &query, const | |||
43 | return ResultSet(keys); | 47 | return ResultSet(keys); |
44 | } | 48 | } |
45 | 49 | ||
46 | void EventImplementation::index(const Event &type) | 50 | void TypeImplementation<Event>::index(const Event &type) |
47 | { | 51 | { |
48 | Index uidIndex(Akonadi2::Store::storageLocation(), type.resourceInstanceIdentifier() + "index.uid", Akonadi2::Storage::ReadWrite); | 52 | Index uidIndex(Akonadi2::Store::storageLocation(), type.resourceInstanceIdentifier() + "index.uid", Akonadi2::Storage::ReadWrite); |
49 | const auto uid = type.getProperty("uid"); | 53 | const auto uid = type.getProperty("uid"); |
@@ -51,3 +55,29 @@ void EventImplementation::index(const Event &type) | |||
51 | uidIndex.add(uid.toByteArray(), type.identifier()); | 55 | uidIndex.add(uid.toByteArray(), type.identifier()); |
52 | } | 56 | } |
53 | } | 57 | } |
58 | |||
59 | QSharedPointer<ReadPropertyMapper<Buffer::Event> > TypeImplementation<Event>::initializeReadPropertyMapper() | ||
60 | { | ||
61 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer::Event> >::create(); | ||
62 | propertyMapper->addMapping("summary", [](Buffer::Event const *buffer) -> QVariant { | ||
63 | return propertyToVariant<QString>(buffer->summary()); | ||
64 | }); | ||
65 | propertyMapper->addMapping("uid", [](Buffer::Event const *buffer) -> QVariant { | ||
66 | return propertyToVariant<QString>(buffer->uid()); | ||
67 | }); | ||
68 | return propertyMapper; | ||
69 | } | ||
70 | |||
71 | QSharedPointer<WritePropertyMapper<Buffer::EventBuilder> > TypeImplementation<Event>::initializeWritePropertyMapper() | ||
72 | { | ||
73 | auto propertyMapper = QSharedPointer<WritePropertyMapper<Buffer::EventBuilder> >::create(); | ||
74 | propertyMapper->addMapping("summary", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Buffer::EventBuilder &)> { | ||
75 | auto offset = variantToProperty<QString>(value, fbb); | ||
76 | return [offset](Buffer::EventBuilder &builder) { builder.add_summary(offset); }; | ||
77 | }); | ||
78 | propertyMapper->addMapping("uid", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Buffer::EventBuilder &)> { | ||
79 | auto offset = variantToProperty<QString>(value, fbb); | ||
80 | return [offset](Buffer::EventBuilder &builder) { builder.add_uid(offset); }; | ||
81 | }); | ||
82 | return propertyMapper; | ||
83 | } | ||