diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-31 18:45:59 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-31 18:45:59 +0100 |
commit | 1d245e28c9b1b18a45097a72bc4ff166c59c37ba (patch) | |
tree | 46853e4df7d5b60435088b8503966567639b51b6 /common/propertymapper.cpp | |
parent | eed2f992300a82debdeda3ece5acf5c05954bbf7 (diff) | |
download | sink-1d245e28c9b1b18a45097a72bc4ff166c59c37ba.tar.gz sink-1d245e28c9b1b18a45097a72bc4ff166c59c37ba.zip |
Mail::Contact mapping
Diffstat (limited to 'common/propertymapper.cpp')
-rw-r--r-- | common/propertymapper.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp index 9fe2d30..78c5021 100644 --- a/common/propertymapper.cpp +++ b/common/propertymapper.cpp | |||
@@ -18,7 +18,10 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "propertymapper.h" | 20 | #include "propertymapper.h" |
21 | |||
22 | #include "applicationdomaintype.h" | ||
21 | #include <QDateTime> | 23 | #include <QDateTime> |
24 | #include "mail_generated.h" | ||
22 | 25 | ||
23 | template <> | 26 | template <> |
24 | flatbuffers::uoffset_t variantToProperty<QString>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | 27 | flatbuffers::uoffset_t variantToProperty<QString>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) |
@@ -63,6 +66,26 @@ flatbuffers::uoffset_t variantToProperty<QByteArrayList>(const QVariant &propert | |||
63 | } | 66 | } |
64 | 67 | ||
65 | template <> | 68 | template <> |
69 | flatbuffers::uoffset_t variantToProperty<Sink::ApplicationDomain::Mail::Contact>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
70 | { | ||
71 | if (property.isValid()) { | ||
72 | const auto value = property.value<Sink::ApplicationDomain::Mail::Contact>(); | ||
73 | return Sink::ApplicationDomain::Buffer::CreateMailContactDirect(fbb, value.name.toUtf8().constData(), value.name.toUtf8().constData()).o; | ||
74 | } | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | |||
79 | QString propertyToString(const flatbuffers::String *property) | ||
80 | { | ||
81 | if (property) { | ||
82 | // We have to copy the memory, otherwise it would become eventually invalid | ||
83 | return QString::fromStdString(property->c_str()); | ||
84 | } | ||
85 | return QString(); | ||
86 | } | ||
87 | |||
88 | template <> | ||
66 | QVariant propertyToVariant<QString>(const flatbuffers::String *property) | 89 | QVariant propertyToVariant<QString>(const flatbuffers::String *property) |
67 | { | 90 | { |
68 | if (property) { | 91 | if (property) { |
@@ -108,6 +131,16 @@ QVariant propertyToVariant<QByteArrayList>(const flatbuffers::Vector<flatbuffers | |||
108 | } | 131 | } |
109 | 132 | ||
110 | template <> | 133 | template <> |
134 | QVariant propertyToVariant<Sink::ApplicationDomain::Mail::Contact>(const Sink::ApplicationDomain::Buffer::MailContact *property) | ||
135 | { | ||
136 | if (property) { | ||
137 | return QVariant::fromValue(Sink::ApplicationDomain::Mail::Contact{propertyToString(property->name()), propertyToString(property->email())}); | ||
138 | } | ||
139 | return QVariant(); | ||
140 | |||
141 | } | ||
142 | |||
143 | template <> | ||
111 | QVariant propertyToVariant<bool>(uint8_t property) | 144 | QVariant propertyToVariant<bool>(uint8_t property) |
112 | { | 145 | { |
113 | return static_cast<bool>(property); | 146 | return static_cast<bool>(property); |