summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-27 08:32:15 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-27 10:06:33 -0800
commit739d7d74e767b181974226179c5f1a4b56146e4a (patch)
tree43706e0d6da3a8d18e1cfefd47ef9eac4065c9d5
parent83bd46cf799bcacf9ce259571b911b86592564d3 (diff)
downloadsubsurface-739d7d74e767b181974226179c5f1a4b56146e4a.tar.gz
QML UI: load from cache before trying to sync with the cloud server
This is a simple way to deal with a "no network" situation. But this isn't ideal, yet, if there is a slow network as the dive list will be reset again once the sync from the cloud finishes. So there is some more thought needed to make this work "mostly as expected". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-mobile/qmlmanager.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index c0a2149b3..7a226a542 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -57,8 +57,27 @@ void QMLManager::finishSetup()
setCloudPassword(prefs.cloud_storage_password);
setSaveCloudPassword(prefs.save_password_local);
// if the cloud credentials are valid, we should get the GPS Webservice ID as well
+ QString url;
if (!same_string(prefs.cloud_storage_email, "") &&
- !same_string(prefs.cloud_storage_password, "")) {
+ !same_string(prefs.cloud_storage_password, "") &&
+ getCloudURL(url) == 0) {
+ clear_dive_file_data();
+ QByteArray fileNamePrt = QFile::encodeName(url);
+ prefs.git_local_only = true;
+ int error = parse_file(fileNamePrt.data());
+ prefs.git_local_only = false;
+ if (error) {
+ appendTextToLog(QString("loading dives from cache failed %1").arg(error));
+ } else {
+ int i;
+ struct dive *d;
+ process_dives(false, false);
+ DiveListModel::instance()->clear();
+ for_each_dive(i, d) {
+ DiveListModel::instance()->addDive(d);
+ }
+ appendTextToLog(QString("%1 dives loaded from cache").arg(i));
+ }
appendTextToLog("have cloud credentials, trying to connect");
tryRetrieveDataFromBackend();
} else {