Mobile: factor out syncToCloud [3/3]

After the previous commits, we now have a preference that nicely
preserves the state of the UI, and we have the well known git_local_only
global, that is used to denote whether we want to use to local repo
only, or we want to interact with the online cloud as well.

This commit gets rid of the now superfluous syncToCloud logic. Instead
we simply set the git_local_only directly.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
Jan Mulder 2018-10-09 10:23:24 +02:00 committed by Dirk Hohndel
parent 87b8155576
commit a95e658946
5 changed files with 14 additions and 21 deletions

View file

@ -375,7 +375,7 @@ void QMLManager::finishSetup()
// Initialize cloud credentials.
QMLPrefs::instance()->setCloudUserName(qPrefCloudStorage::cloud_storage_email());
QMLPrefs::instance()->setCloudPassword(qPrefCloudStorage::cloud_storage_password());
setSyncToCloud(!git_local_only);
git_local_only = !prefs.cloud_auto_sync;
QMLPrefs::instance()->setCredentialStatus((qPrefCloudStorage::cloud_status) prefs.cloud_verification_status);
// if the cloud credentials are valid, we should get the GPS Webservice ID as well
QString url;
@ -679,9 +679,9 @@ successful_exit:
noCloudToCloud = false;
mark_divelist_changed(true);
saveChangesLocal();
if (m_syncToCloud == false) {
if (git_local_only == false) {
appendTextToLog(QStringLiteral("taking things back offline now that storage is synced"));
git_local_only = m_syncToCloud;
git_local_only = true;
}
}
// if we got here just for an initial connection to the cloud, reset to offline
@ -705,9 +705,9 @@ void QMLManager::revertToNoCloudIfNeeded()
// and cloud data) failed - so let's delete the cloud credentials and go
// back to CS_NOCLOUD mode in order to prevent us from losing the locally stored
// dives
if (m_syncToCloud == false) {
if (git_local_only == true) {
appendTextToLog(QStringLiteral("taking things back offline since sync with cloud failed"));
git_local_only = m_syncToCloud;
git_local_only = false;
}
free((void *)prefs.cloud_storage_email);
prefs.cloud_storage_email = NULL;
@ -1492,13 +1492,6 @@ void QMLManager::setNotificationText(QString text)
emit notificationTextChanged();
}
void QMLManager::setSyncToCloud(bool status)
{
m_syncToCloud = status;
git_local_only = !status;
emit syncToCloudChanged();
}
void QMLManager::setUpdateSelectedDive(int idx)
{
m_updateSelectedDive = idx;
@ -1764,6 +1757,11 @@ int QMLManager::getConnectionIndex(const QString &deviceSubstr)
return connectionListModel.indexOf(deviceSubstr);
}
void QMLManager::setGitLocalOnly(const bool &value)
{
git_local_only = value;
}
void QMLManager::showDownloadPage(QString deviceString)
{
// we pass the indices for the three combo boxes for vendor, product, and connection