aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlengine.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-01-09 17:06:25 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-02 13:19:57 +0000
commitf96b77bf46a29b1c09d6ebff2f18a475c7ca0b2f (patch)
tree3367d385eb85ba80bad41b155a48057a548c02e8 /src/qml/qml/qqmlengine.cpp
parent6ba26317d0fc0573aca7638eda8bdb91e52d1ab3 (diff)
add QQmlEngine::offlineStorageDatabaseFilePath(db), use in LocalStorage
This is C++ API to get the actual storage path for a particular database. [ChangeLog][QtQml] Added QQmlEngine::offlineStorageDatabaseFilePath(dbName) to allow getting the actual storage path for a particular database. Task-number: QTBUG-52013 Change-Id: I1cbd9454c537f08c97f4dafc06fd6b14e81c51af Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlengine.cpp')
-rw-r--r--src/qml/qml/qqmlengine.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index e1fa97b52f..fe3f1dbaf1 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -2178,6 +2178,27 @@ QString QQmlEngine::offlineStoragePath() const
return d->offlineStoragePath;
}
+/*!
+ Returns the file path where a \l{QtQuick.LocalStorage}{Local Storage}
+ database with the identifier \a databaseName is (or would be) located.
+
+ \sa LocalStorage.openDatabaseSync()
+ \since 5.9
+*/
+QString QQmlEngine::offlineStorageDatabaseFilePath(const QString &databaseName) const
+{
+ Q_D(const QQmlEngine);
+ QCryptographicHash md5(QCryptographicHash::Md5);
+ md5.addData(databaseName.toUtf8());
+ return d->offlineStorageDatabaseDirectory() + QLatin1String(md5.result().toHex());
+}
+
+QString QQmlEnginePrivate::offlineStorageDatabaseDirectory() const
+{
+ Q_Q(const QQmlEngine);
+ return q->offlineStoragePath() + QDir::separator() + QLatin1String("Databases") + QDir::separator();
+}
+
QQmlPropertyCache *QQmlEnginePrivate::createCache(QQmlType *type, int minorVersion)
{
QList<QQmlType *> types;