diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-06 18:32:32 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-06 18:32:32 +0100 |
commit | 319a303bdceba18d0e5629f3de7a2b85646223be (patch) | |
tree | 7e4ccb76fa5ee875f49ea3d65e9e519e90573354 /common/propertymapper.cpp | |
parent | 59aa460cf704d5f1a1fb1fe6b8ede4457da083ff (diff) | |
download | sink-319a303bdceba18d0e5629f3de7a2b85646223be.tar.gz sink-319a303bdceba18d0e5629f3de7a2b85646223be.zip |
Wrap blob properties in type so we can distinguish it from other properties.
When moving an entity to another resource we have to move the blob
properties to a temporary directory first, and that requires that we are
able to distinguish blob properties from the rest at runtime.
Diffstat (limited to 'common/propertymapper.cpp')
-rw-r--r-- | common/propertymapper.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp index 754c874..249221a 100644 --- a/common/propertymapper.cpp +++ b/common/propertymapper.cpp | |||
@@ -33,6 +33,15 @@ flatbuffers::uoffset_t variantToProperty<QString>(const QVariant &property, flat | |||
33 | } | 33 | } |
34 | 34 | ||
35 | template <> | 35 | template <> |
36 | flatbuffers::uoffset_t variantToProperty<Sink::ApplicationDomain::BLOB>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
37 | { | ||
38 | if (property.isValid()) { | ||
39 | return fbb.CreateString(property.value<Sink::ApplicationDomain::BLOB>().value.toStdString()).o; | ||
40 | } | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | template <> | ||
36 | flatbuffers::uoffset_t variantToProperty<QByteArray>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | 45 | flatbuffers::uoffset_t variantToProperty<QByteArray>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) |
37 | { | 46 | { |
38 | if (property.isValid()) { | 47 | if (property.isValid()) { |
@@ -111,6 +120,16 @@ QVariant propertyToVariant<QString>(const flatbuffers::String *property) | |||
111 | } | 120 | } |
112 | 121 | ||
113 | template <> | 122 | template <> |
123 | QVariant propertyToVariant<Sink::ApplicationDomain::BLOB>(const flatbuffers::String *property) | ||
124 | { | ||
125 | if (property) { | ||
126 | // We have to copy the memory, otherwise it would become eventually invalid | ||
127 | return QVariant::fromValue(Sink::ApplicationDomain::BLOB{QString::fromStdString(property->c_str())}); | ||
128 | } | ||
129 | return QVariant(); | ||
130 | } | ||
131 | |||
132 | template <> | ||
114 | QVariant propertyToVariant<QByteArray>(const flatbuffers::String *property) | 133 | QVariant propertyToVariant<QByteArray>(const flatbuffers::String *property) |
115 | { | 134 | { |
116 | if (property) { | 135 | if (property) { |