summaryrefslogtreecommitdiffstats
path: root/common/propertymapper.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-06 18:32:32 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-06 18:32:32 +0100
commit319a303bdceba18d0e5629f3de7a2b85646223be (patch)
tree7e4ccb76fa5ee875f49ea3d65e9e519e90573354 /common/propertymapper.cpp
parent59aa460cf704d5f1a1fb1fe6b8ede4457da083ff (diff)
downloadsink-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.cpp19
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
35template <> 35template <>
36flatbuffers::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
44template <>
36flatbuffers::uoffset_t variantToProperty<QByteArray>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) 45flatbuffers::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
113template <> 122template <>
123QVariant 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
132template <>
114QVariant propertyToVariant<QByteArray>(const flatbuffers::String *property) 133QVariant propertyToVariant<QByteArray>(const flatbuffers::String *property)
115{ 134{
116 if (property) { 135 if (property) {