summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-04-10 10:55:56 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-04-10 10:55:56 +0200
commit5adfceae08872b9d7f143d8b9464578fb8e43a69 (patch)
treec57dd610148cc7c42ebbfd50490d71d94cfd3beb
parent6b5ec926275ec3d0431ce74c5c5af905f407aa24 (diff)
downloadsink-5adfceae08872b9d7f143d8b9464578fb8e43a69.tar.gz
sink-5adfceae08872b9d7f143d8b9464578fb8e43a69.zip
Allow clients to request a temporary file for BLOB properties
-rw-r--r--common/definitions.cpp10
-rw-r--r--common/definitions.h1
-rw-r--r--common/store.cpp6
-rw-r--r--common/store.h9
4 files changed, 24 insertions, 2 deletions
diff --git a/common/definitions.cpp b/common/definitions.cpp
index daf354c..101279e 100644
--- a/common/definitions.cpp
+++ b/common/definitions.cpp
@@ -21,12 +21,22 @@
21#include "definitions.h" 21#include "definitions.h"
22 22
23#include <QStandardPaths> 23#include <QStandardPaths>
24#include <QDir>
24 25
25QString Sink::storageLocation() 26QString Sink::storageLocation()
26{ 27{
27 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/storage"; 28 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/storage";
28} 29}
29 30
31QString Sink::temporaryFileLocation()
32{
33 auto path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/temporaryFiles";
34 //FIXME create in a singleton on startup?
35 QDir dir;
36 dir.mkpath(path);
37 return path;
38}
39
30QByteArray Sink::resourceName(const QByteArray &instanceIdentifier) 40QByteArray Sink::resourceName(const QByteArray &instanceIdentifier)
31{ 41{
32 auto split = instanceIdentifier.split('.'); 42 auto split = instanceIdentifier.split('.');
diff --git a/common/definitions.h b/common/definitions.h
index 96ec27e..a90b15a 100644
--- a/common/definitions.h
+++ b/common/definitions.h
@@ -26,5 +26,6 @@
26 26
27namespace Sink { 27namespace Sink {
28QString SINK_EXPORT storageLocation(); 28QString SINK_EXPORT storageLocation();
29QString SINK_EXPORT temporaryFileLocation();
29QByteArray SINK_EXPORT resourceName(const QByteArray &instanceIdentifier); 30QByteArray SINK_EXPORT resourceName(const QByteArray &instanceIdentifier);
30} 31}
diff --git a/common/store.cpp b/common/store.cpp
index 4bf1c58..700263b 100644
--- a/common/store.cpp
+++ b/common/store.cpp
@@ -22,6 +22,7 @@
22 22
23#include <QTime> 23#include <QTime>
24#include <QAbstractItemModel> 24#include <QAbstractItemModel>
25#include <QUuid>
25#include <functional> 26#include <functional>
26#include <memory> 27#include <memory>
27 28
@@ -45,6 +46,11 @@ QString Store::storageLocation()
45 return Sink::storageLocation(); 46 return Sink::storageLocation();
46} 47}
47 48
49QString Store::getTemporaryFilePath()
50{
51 return Sink::temporaryFileLocation() + "/" + QUuid::createUuid().toString();
52}
53
48static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type = QByteArray()) 54static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type = QByteArray())
49{ 55{
50 // Return the global resource (signified by an empty name) for types that don't belong to a specific resource 56 // Return the global resource (signified by an empty name) for types that don't belong to a specific resource
diff --git a/common/store.h b/common/store.h
index af8e971..aed3be4 100644
--- a/common/store.h
+++ b/common/store.h
@@ -43,6 +43,11 @@ namespace Store {
43 43
44QString SINK_EXPORT storageLocation(); 44QString SINK_EXPORT storageLocation();
45 45
46/**
47 * Returns a unique path for a writable file that can be used to write BLOB properties.
48 */
49QString SINK_EXPORT getTemporaryFilePath();
50
46enum Roles 51enum Roles
47{ 52{
48 DomainObjectRole = Qt::UserRole + 1, // Must be the same as in ModelResult 53 DomainObjectRole = Qt::UserRole + 1, // Must be the same as in ModelResult
@@ -51,8 +56,8 @@ enum Roles
51}; 56};
52 57
53/** 58/**
54 * Asynchronusly load a dataset with tree structure information 59* Asynchronusly load a dataset with tree structure information
55 */ 60*/
56template <class DomainType> 61template <class DomainType>
57QSharedPointer<QAbstractItemModel> SINK_EXPORT loadModel(Query query); 62QSharedPointer<QAbstractItemModel> SINK_EXPORT loadModel(Query query);
58 63