diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-04-10 19:22:16 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-10 19:22:16 -0700 |
commit | 18b7ee3875f8e469a456b61f78fa3ab85b7f5041 (patch) | |
tree | 38f99f7ef452a4d7d1e01c0ca24df22b7656656c /mobile-widgets/qmlmanager.cpp | |
parent | 4ed369b9759d2a720cffcba3062d50713233150d (diff) | |
download | subsurface-18b7ee3875f8e469a456b61f78fa3ab85b7f5041.tar.gz |
QML UI: try to do the right thing for changes on all platforms
On Android we can save locally right away, but we don't want to make the user
wait for a network sync. Sadly, on Android currently the saving in the
background doesn't work and the save will run when the user comes back.
Definitely not ideal.
On iOS the situation is different - a save to the local git cache takes
surprisingly long. Must be the shitty file system they use or something.
Because of that we only mark the dive list changed and instead save the next
time the app is not in the foreground (which works on iOS but not on Android -
go figure).
On all the other OSs (I guess that would be desktop builds of
Subsurface-mobile? But there may be other mobile OSs that people might want to
build it on) we save both locally and to the cloud right away.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 67b8d993b..d16ef1eab 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -737,10 +737,24 @@ parsed: DiveListModel::instance()->updateDive(oldModelIdx, d); } if (diveChanged || needResort) - // we no longer save right away, but only the next time the app is not - // in the foreground (or when explicitly requested) - mark_divelist_changed(true); + changesNeedSaving(); +} +void QMLManager::changesNeedSaving() +{ + // we no longer save right away on iOS because file access is so slow; on the other hand, + // on Android the save as the user switches away doesn't seem to work... drat. + // as a compromise for now we save just to local storage on Android right away (that appears + // to be reasonably fast), but don't save at all (and only remember that we need to save things + // on iOS + // on all other platforms we just save the changes and be done with it +#if defined(Q_OS_IOS) + mark_divelist_changed(true); +#elif defined(Q_OS_ANDROID) + saveChangesLocal(); +#else + saveChanges(); +#endif } void QMLManager::saveChangesLocal() { @@ -823,9 +837,7 @@ void QMLManager::undoDelete(int id) QList<dive *>diveAsList; diveAsList << deletedDive; DiveListModel::instance()->addDive(diveAsList); - // make sure the changes get saved if the app is no longer in the foreground - // or if the user requests a save - mark_divelist_changed(true); + changesNeedSaving(); deletedDive = NULL; deletedTrip = NULL; } @@ -860,9 +872,7 @@ void QMLManager::deleteDive(int id) } DiveListModel::instance()->removeDiveById(id); delete_single_dive(get_idx_by_uniq_id(id)); - // make sure the changes get saved if the app is no longer in the foreground - // or if the user requests a save - mark_divelist_changed(true); + changesNeedSaving(); } QString QMLManager::addDive() |