diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-10 10:55:56 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-10 10:55:56 +0200 |
commit | 5adfceae08872b9d7f143d8b9464578fb8e43a69 (patch) | |
tree | c57dd610148cc7c42ebbfd50490d71d94cfd3beb | |
parent | 6b5ec926275ec3d0431ce74c5c5af905f407aa24 (diff) | |
download | sink-5adfceae08872b9d7f143d8b9464578fb8e43a69.tar.gz sink-5adfceae08872b9d7f143d8b9464578fb8e43a69.zip |
Allow clients to request a temporary file for BLOB properties
-rw-r--r-- | common/definitions.cpp | 10 | ||||
-rw-r--r-- | common/definitions.h | 1 | ||||
-rw-r--r-- | common/store.cpp | 6 | ||||
-rw-r--r-- | common/store.h | 9 |
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 | ||
25 | QString Sink::storageLocation() | 26 | QString Sink::storageLocation() |
26 | { | 27 | { |
27 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/storage"; | 28 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/storage"; |
28 | } | 29 | } |
29 | 30 | ||
31 | QString 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 | |||
30 | QByteArray Sink::resourceName(const QByteArray &instanceIdentifier) | 40 | QByteArray 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 | ||
27 | namespace Sink { | 27 | namespace Sink { |
28 | QString SINK_EXPORT storageLocation(); | 28 | QString SINK_EXPORT storageLocation(); |
29 | QString SINK_EXPORT temporaryFileLocation(); | ||
29 | QByteArray SINK_EXPORT resourceName(const QByteArray &instanceIdentifier); | 30 | QByteArray 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 | ||
49 | QString Store::getTemporaryFilePath() | ||
50 | { | ||
51 | return Sink::temporaryFileLocation() + "/" + QUuid::createUuid().toString(); | ||
52 | } | ||
53 | |||
48 | static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type = QByteArray()) | 54 | static 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 | ||
44 | QString SINK_EXPORT storageLocation(); | 44 | QString SINK_EXPORT storageLocation(); |
45 | 45 | ||
46 | /** | ||
47 | * Returns a unique path for a writable file that can be used to write BLOB properties. | ||
48 | */ | ||
49 | QString SINK_EXPORT getTemporaryFilePath(); | ||
50 | |||
46 | enum Roles | 51 | enum 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 | */ |
56 | template <class DomainType> | 61 | template <class DomainType> |
57 | QSharedPointer<QAbstractItemModel> SINK_EXPORT loadModel(Query query); | 62 | QSharedPointer<QAbstractItemModel> SINK_EXPORT loadModel(Query query); |
58 | 63 | ||