diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-04-04 14:23:39 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-04-04 16:10:50 -0700 |
commit | 8414f8392690861b98ea59e9f412ca18e2b25f67 (patch) | |
tree | bbf72125e74ff86ee104bd2e77738d64034c00a6 | |
parent | 6aaa9a40b6ca57b018f1c9172049dbe34b8632f8 (diff) | |
download | subsurface-8414f8392690861b98ea59e9f412ca18e2b25f67.tar.gz |
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>
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 11 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 11e71c5a2..99811d66c 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -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) diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index e37f1c474..fd353cb76 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -170,6 +170,7 @@ public: #endif qPrefCloudStorage::cloud_status oldStatus() const; void setOldStatus(const qPrefCloudStorage::cloud_status value); + void rememberOldStatus(); public slots: void appInitialized(); |