diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-06-13 13:45:06 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-06-14 13:35:33 -0700 |
commit | 01de67a5a6f62f0c7d0b5b381c053e6db16f4e96 (patch) | |
tree | 82ac7b71a083d07d67d64a0453b79be361450483 /mobile-widgets/qmlmanager.cpp | |
parent | 8b478a969dbd10b3f07affd2f614886d27211c2a (diff) | |
download | subsurface-01de67a5a6f62f0c7d0b5b381c053e6db16f4e96.tar.gz |
mobile: track if we have changes that aren't synced to cloud
If we haven't connected at all to the cloud server we assume that there are
local changes. And whenever we save changes only locally, we also set that
flag.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index f338e5ba5..be4dc4ec3 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -304,6 +304,9 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), // get updates to the undo/redo texts connect(Command::getUndoStack(), &QUndoStack::undoTextChanged, this, &QMLManager::undoTextChanged); connect(Command::getUndoStack(), &QUndoStack::redoTextChanged, this, &QMLManager::redoTextChanged); + + // we start out with clean data + updateHaveLocalChanges(false); } void QMLManager::applicationStateChanged(Qt::ApplicationState state) @@ -401,6 +404,8 @@ void QMLManager::openLocalThenRemote(QString url) if (git_local_only && qPrefCloudStorage::cloud_verification_status() != qPrefCloudStorage::CS_NOCLOUD) appendTextToLog(QStringLiteral("have cloud credentials, but user asked not to connect to network")); + // if we were unable to sync with the remote, we assume that there are local changes + updateHaveLocalChanges(!git_remote_sync_successful); updateAllGlobalLists(); setDiveListProcessing(false); // this could have added a new local cache directory @@ -527,6 +532,7 @@ void QMLManager::finishSetup() } else { // successfully opened the local file, now add thigs to the dive list consumeFinishedLoad(); + updateHaveLocalChanges(true); appendTextToLog(QString("working in no-cloud mode, finished loading %1 dives from %2").arg(dive_table.nr).arg(existing_filename)); } } else { @@ -718,6 +724,7 @@ void QMLManager::loadDivesWithValidCredentials() consumeFinishedLoad(); } setLoadFromCloud(true); + // if we came from local storage mode, let's merge the local data into the local cache // for the remote data - which then later gets merged with the remote data if necessary if (noCloudToCloud) { @@ -732,6 +739,8 @@ void QMLManager::loadDivesWithValidCredentials() git_local_only = true; } } + // if we successfully synced with the cloud, update that status + updateHaveLocalChanges(!git_remote_sync_successful); // if we got here just for an initial connection to the cloud, reset to offline if (currentGitLocalOnly) { currentGitLocalOnly = false; @@ -1346,6 +1355,7 @@ void QMLManager::saveChangesLocal() } mark_divelist_changed(false); Command::setClean(); + updateHaveLocalChanges(true); } else { appendTextToLog("local save requested with no unsaved changes"); } @@ -2237,3 +2247,8 @@ QStringList QMLManager::cloudCacheList() const } return result; } + +void QMLManager::updateHaveLocalChanges(bool status) +{ + localChanges = status; +} |