diff options
Diffstat (limited to 'common/domain/applicationdomaintype.cpp')
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 73143e8..23a63a7 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -20,6 +20,8 @@ | |||
20 | #include "applicationdomaintype.h" | 20 | #include "applicationdomaintype.h" |
21 | #include "log.h" | 21 | #include "log.h" |
22 | #include "../bufferadaptor.h" | 22 | #include "../bufferadaptor.h" |
23 | #include "definitions.h" | ||
24 | #include <QFile> | ||
23 | 25 | ||
24 | namespace Sink { | 26 | namespace Sink { |
25 | namespace ApplicationDomain { | 27 | namespace ApplicationDomain { |
@@ -86,6 +88,29 @@ void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &v | |||
86 | mAdaptor->setProperty(key, value); | 88 | mAdaptor->setProperty(key, value); |
87 | } | 89 | } |
88 | 90 | ||
91 | QByteArray ApplicationDomainType::getBlobProperty(const QByteArray &key) const | ||
92 | { | ||
93 | const auto path = getProperty(key).toByteArray(); | ||
94 | QFile file(path); | ||
95 | if (!file.open(QIODevice::ReadOnly)) { | ||
96 | ErrorMsg() << "Failed to open the file: " << file.errorString() << path; | ||
97 | return QByteArray(); | ||
98 | } | ||
99 | return file.readAll(); | ||
100 | } | ||
101 | |||
102 | void ApplicationDomainType::setBlobProperty(const QByteArray &key, const QByteArray &value) | ||
103 | { | ||
104 | const auto path = Sink::temporaryFileLocation() + "/" + QUuid::createUuid().toString(); | ||
105 | QFile file(path); | ||
106 | if (!file.open(QIODevice::WriteOnly)) { | ||
107 | ErrorMsg() << "Failed to open the file: " << file.errorString() << path; | ||
108 | return; | ||
109 | } | ||
110 | file.write(value); | ||
111 | setProperty(key, path); | ||
112 | } | ||
113 | |||
89 | void ApplicationDomainType::setChangedProperties(const QSet<QByteArray> &changeset) | 114 | void ApplicationDomainType::setChangedProperties(const QSet<QByteArray> &changeset) |
90 | { | 115 | { |
91 | mChangeSet = changeset; | 116 | mChangeSet = changeset; |