mobile: unify download code on mobile and desktop

Use the undo-command for importing dives also on mobile. This should make the
whole disconnect-model shenigans unnecessary.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-11-16 22:24:06 +01:00 committed by Dirk Hohndel
parent 3b6b9951ae
commit b6f821886b
4 changed files with 20 additions and 32 deletions

View file

@ -525,26 +525,13 @@ void DownloadFromDCWidget::on_ok_clicked()
if (currentState != DONE && currentState != ERRORED)
return;
// delete non-selected dives
diveImportedModel->deleteDeselected();
int flags = IMPORT_IS_DOWNLOADED;
if (preferDownloaded())
flags |= IMPORT_PREFER_IMPORTED;
if (ui.createNewTrip->isChecked())
flags |= IMPORT_ADD_TO_NEW_TRIP;
// TODO: use structured bindings once we go C++17
std::pair<struct dive_table, struct dive_site_table> tables = diveImportedModel->consumeTables();
if (tables.first.nr > 0) {
auto data = diveImportedModel->thread.data();
int flags = IMPORT_IS_DOWNLOADED;
if (preferDownloaded())
flags |= IMPORT_PREFER_IMPORTED;
if (ui.createNewTrip->isChecked())
flags |= IMPORT_ADD_TO_NEW_TRIP;
Command::importDives(&tables.first, nullptr, &tables.second, flags, data->devName());
} else {
clear_dive_site_table(&tables.second);
}
// The dives and dive sites have been consumed, but the arrays of the tables
// still exist. Free them.
free(tables.first.dives);
free(tables.second.dive_sites);
diveImportedModel->recordDives(flags);
if (ostcFirmwareCheck && currentState == DONE)
ostcFirmwareCheck->checkLatest(this, diveImportedModel->thread.data()->internalData());