mobile: reduce the number of model reloads when opening cloud data

The whole load from cloud thing will have to be audited. It appears
to me that there are way too many model resets...?

The only thing that is left is dive editing. Let's do that next.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-01-02 08:33:37 +01:00 committed by Dirk Hohndel
parent 5493e7cbf6
commit 2a88ff0ffb

View file

@ -299,7 +299,6 @@ void QMLManager::applicationStateChanged(Qt::ApplicationState state)
void QMLManager::openLocalThenRemote(QString url)
{
DiveListModel::instance()->clear();
MobileModels::instance()->clear();
setNotificationText(tr("Open local dive data file"));
QByteArray fileNamePrt = QFile::encodeName(url);
@ -337,7 +336,6 @@ void QMLManager::openLocalThenRemote(QString url)
qPrefTechnicalDetails::set_show_ccr_sensors(git_prefs.show_ccr_sensors);
qPrefPartialPressureGas::set_po2(git_prefs.pp_graphs.po2);
process_loaded_dives();
DiveListModel::instance()->reload();
MobileModels::instance()->reset();
appendTextToLog(QStringLiteral("%1 dives loaded from cache").arg(dive_table.nr));
setNotificationText(tr("%1 dives loaded from local dive data file").arg(dive_table.nr));
@ -581,7 +579,6 @@ void QMLManager::saveCloudCredentials(const QString &newEmail, const QString &ne
manager()->clearAccessCache(); // remove any chached credentials
clear_git_id(); // invalidate our remembered GIT SHA
MobileModels::instance()->clear();
DiveListModel::instance()->reload();
GpsListModel::instance()->clear();
setStartPageText(tr("Attempting to open cloud storage with new credentials"));
// we therefore know that no one else is already accessing THIS git repo;
@ -769,7 +766,7 @@ void QMLManager::loadDivesWithValidCredentials()
// if we aren't switching from no-cloud mode, let's clear the dive data
if (!noCloudToCloud) {
appendTextToLog("Clear out in memory dive data");
DiveListModel::instance()->clear();
MobileModels::instance()->clear();
} else {
appendTextToLog("Switching from no cloud mode; keep in memory dive data");
}
@ -800,7 +797,7 @@ successful_exit:
if (noCloudToCloud) {
git_storage_update_progress(qPrintable(tr("Loading dives from local storage ('no cloud' mode)")));
mergeLocalRepo();
DiveListModel::instance()->reload();
MobileModels::instance()->reset();
appendTextToLog(QStringLiteral("%1 dives loaded after importing nocloud local storage").arg(dive_table.nr));
noCloudToCloud = false;
mark_divelist_changed(true);
@ -863,7 +860,7 @@ void QMLManager::consumeFinishedLoad(timestamp_t currentDiveTimestamp)
prefs.show_ccr_sensors = git_prefs.show_ccr_sensors;
prefs.pp_graphs.po2 = git_prefs.pp_graphs.po2;
process_loaded_dives();
DiveListModel::instance()->reload();
MobileModels::instance()->reset();
if (currentDiveTimestamp)
setUpdateSelectedDive(DiveListSortModel::instance()->getIdxForId(get_dive_id_closest_to(currentDiveTimestamp)));
appendTextToLog(QStringLiteral("%1 dives loaded").arg(dive_table.nr));
@ -874,7 +871,7 @@ void QMLManager::consumeFinishedLoad(timestamp_t currentDiveTimestamp)
void QMLManager::refreshDiveList()
{
DiveListModel::instance()->reload();
MobileModels::instance()->reset();
}
void QMLManager::setupDivesite(struct dive *d, struct dive_site *ds, double lat, double lon, const char *locationtext)