mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
mobile/cleanup: create helper function to hide verbose casts
The strange enum casts (that apparently we needed in order to have strongly typed enums in QML) are really ugly and confusing in the code. Since we had this three times it seemed worth to create a little helper that hides this nonsense. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6aaa9a40b6
commit
8414f83926
2 changed files with 9 additions and 3 deletions
|
@ -511,7 +511,7 @@ void QMLManager::finishSetup()
|
|||
openLocalThenRemote(url);
|
||||
} else if (!empty_string(existing_filename) &&
|
||||
qPrefCloudStorage::cloud_verification_status() != qPrefCloudStorage::CS_UNKNOWN) {
|
||||
setOldStatus((qPrefCloudStorage::cloud_status)qPrefCloudStorage::cloud_verification_status());
|
||||
rememberOldStatus();
|
||||
set_filename(qPrintable(nocloud_localstorage()));
|
||||
qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_NOCLOUD);
|
||||
saveCloudCredentials(qPrefCloudStorage::cloud_storage_email(), qPrefCloudStorage::cloud_storage_password(), qPrefCloudStorage::cloud_storage_pin());
|
||||
|
@ -619,7 +619,7 @@ void QMLManager::saveCloudCredentials(const QString &newEmail, const QString &ne
|
|||
git_local_only = false;
|
||||
loadDivesWithValidCredentials();
|
||||
}
|
||||
setOldStatus((qPrefCloudStorage::cloud_status)qPrefCloudStorage::cloud_verification_status());
|
||||
rememberOldStatus();
|
||||
}
|
||||
|
||||
bool QMLManager::verifyCredentials(QString email, QString password, QString pin)
|
||||
|
@ -756,7 +756,7 @@ void QMLManager::revertToNoCloudIfNeeded()
|
|||
prefs.cloud_storage_password = NULL;
|
||||
qPrefCloudStorage::set_cloud_storage_email("");
|
||||
qPrefCloudStorage::set_cloud_storage_password("");
|
||||
setOldStatus((qPrefCloudStorage::cloud_status)qPrefCloudStorage::cloud_verification_status());
|
||||
rememberOldStatus();
|
||||
qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_NOCLOUD);
|
||||
set_filename(qPrintable(nocloud_localstorage()));
|
||||
setStartPageText(RED_FONT + tr("Failed to connect to cloud server, reverting to no cloud status") + END_FONT);
|
||||
|
@ -2160,6 +2160,11 @@ void QMLManager::setOldStatus(const qPrefCloudStorage::cloud_status value)
|
|||
}
|
||||
}
|
||||
|
||||
void QMLManager::rememberOldStatus()
|
||||
{
|
||||
setOldStatus((qPrefCloudStorage::cloud_status)qPrefCloudStorage::cloud_verification_status());
|
||||
}
|
||||
|
||||
void QMLManager::divesChanged(const QVector<dive *> &dives, DiveField field)
|
||||
{
|
||||
Q_UNUSED(field)
|
||||
|
|
|
@ -170,6 +170,7 @@ public:
|
|||
#endif
|
||||
qPrefCloudStorage::cloud_status oldStatus() const;
|
||||
void setOldStatus(const qPrefCloudStorage::cloud_status value);
|
||||
void rememberOldStatus();
|
||||
|
||||
public slots:
|
||||
void appInitialized();
|
||||
|
|
Loading…
Add table
Reference in a new issue