diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-01 11:23:35 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-01 11:23:35 +0100 |
commit | 63ca9c4e0be265a4db6b89d444e6fcd8bdd135c1 (patch) | |
tree | 60a6ae376e6091009ebd1a988785c890cc6f45b8 /common/propertymapper.cpp | |
parent | 18f04f0ea8da9c635742571eb0de01d12d856e9f (diff) | |
download | sink-63ca9c4e0be265a4db6b89d444e6fcd8bdd135c1.tar.gz sink-63ca9c4e0be265a4db6b89d444e6fcd8bdd135c1.zip |
Set to/cc/bcc
Diffstat (limited to 'common/propertymapper.cpp')
-rw-r--r-- | common/propertymapper.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp index 78c5021..754c874 100644 --- a/common/propertymapper.cpp +++ b/common/propertymapper.cpp | |||
@@ -70,7 +70,22 @@ flatbuffers::uoffset_t variantToProperty<Sink::ApplicationDomain::Mail::Contact> | |||
70 | { | 70 | { |
71 | if (property.isValid()) { | 71 | if (property.isValid()) { |
72 | const auto value = property.value<Sink::ApplicationDomain::Mail::Contact>(); | 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; | 73 | return Sink::ApplicationDomain::Buffer::CreateMailContactDirect(fbb, value.name.toUtf8().constData(), value.emailAddress.toUtf8().constData()).o; |
74 | } | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | template <> | ||
79 | flatbuffers::uoffset_t variantToProperty<QList<Sink::ApplicationDomain::Mail::Contact>>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
80 | { | ||
81 | if (property.isValid()) { | ||
82 | const auto list = property.value<QList<Sink::ApplicationDomain::Mail::Contact>>(); | ||
83 | std::vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::MailContact>> vector; | ||
84 | for (const auto &value : list) { | ||
85 | auto offset = Sink::ApplicationDomain::Buffer::CreateMailContactDirect(fbb, value.name.toUtf8().constData(), value.emailAddress.toUtf8().constData()).o; | ||
86 | vector.push_back(offset); | ||
87 | } | ||
88 | return fbb.CreateVector(vector).o; | ||
74 | } | 89 | } |
75 | return 0; | 90 | return 0; |
76 | } | 91 | } |
@@ -141,6 +156,21 @@ QVariant propertyToVariant<Sink::ApplicationDomain::Mail::Contact>(const Sink::A | |||
141 | } | 156 | } |
142 | 157 | ||
143 | template <> | 158 | template <> |
159 | QVariant propertyToVariant<QList<Sink::ApplicationDomain::Mail::Contact>>(const flatbuffers::Vector<flatbuffers::Offset<Sink::ApplicationDomain::Buffer::MailContact>> *property) | ||
160 | { | ||
161 | if (property) { | ||
162 | QList<Sink::ApplicationDomain::Mail::Contact> list; | ||
163 | for (auto it = property->begin(); it != property->end();) { | ||
164 | // We have to copy the memory, otherwise it would become eventually invalid | ||
165 | list << Sink::ApplicationDomain::Mail::Contact{propertyToString(it->name()), propertyToString(it->email())}; | ||
166 | it.operator++(); | ||
167 | } | ||
168 | return QVariant::fromValue(list); | ||
169 | } | ||
170 | return QVariant(); | ||
171 | } | ||
172 | |||
173 | template <> | ||
144 | QVariant propertyToVariant<bool>(uint8_t property) | 174 | QVariant propertyToVariant<bool>(uint8_t property) |
145 | { | 175 | { |
146 | return static_cast<bool>(property); | 176 | return static_cast<bool>(property); |