aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-06-06 09:51:40 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-06-07 19:47:52 -0700
commitdd821497263f7d95ed5e7fae759004a966b4a46f (patch)
treeb2dab8dde194a0e24be5358d1193a964b90a9483 /mobile-widgets/qmlmanager.cpp
parent8b167c14ad021e9835519ecd04b23ae6a9219a4b (diff)
downloadsubsurface-dd821497263f7d95ed5e7fae759004a966b4a46f.tar.gz
mobile: make list of local cloud cache directories available
This way QML can show those to the user. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index b56be67aa..7ec3df7ba 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -403,6 +403,8 @@ void QMLManager::openLocalThenRemote(QString url)
updateAllGlobalLists();
setDiveListProcessing(false);
+ // this could have added a new local cache directory
+ emit cloudCacheListChanged();
}
// Convenience function to accesss dive directly via its row.
@@ -534,6 +536,9 @@ void QMLManager::finishSetup()
}
m_initialized = true;
emit initializedChanged();
+ // this could have brought in new cache directories, so make sure QML
+ // calls our getter function again and doesn't show us outdated information
+ emit cloudCacheListChanged();
}
QMLManager::~QMLManager()
@@ -2201,3 +2206,22 @@ void QMLManager::setDiveListProcessing(bool value)
}
}
+
+QStringList QMLManager::cloudCacheList() const
+{
+ QDir localCacheDir(QString("%1/cloudstorage/").arg(system_default_directory()));
+ QStringList dirs = localCacheDir.entryList().filter(QRegExp("...+"));
+ QStringList result;
+ foreach(QString dir, dirs) {
+ QString originsDir = QString("%1/cloudstorage/%2/.git/refs/remotes/origin/").arg(system_default_directory()).arg(dir);
+ QDir remote(originsDir);
+ if (dir == "localrepo") {
+ result << QString("localrepo[master]");
+ } else {
+ foreach(QString branch, remote.entryList().filter(QRegExp("...+"))) {
+ result << QString("%1[%2]").arg(dir).arg(branch);
+ }
+ }
+ }
+ return result;
+}