summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-16 22:24:06 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-10 09:25:57 -0700
commitb6f821886b2ed29230d08357df5c09ee66f7cc8d (patch)
tree24d78ae358f527374432c6fa77a22a30f2478bbd /desktop-widgets/downloadfromdivecomputer.cpp
parent3b6b9951ae0595c21dc35d95126e644babbfbc2d (diff)
downloadsubsurface-b6f821886b2ed29230d08357df5c09ee66f7cc8d.tar.gz
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>
Diffstat (limited to 'desktop-widgets/downloadfromdivecomputer.cpp')
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp27
1 files changed, 7 insertions, 20 deletions
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index a14a8a665..cf3aad492 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -525,26 +525,13 @@ void DownloadFromDCWidget::on_ok_clicked()
if (currentState != DONE && currentState != ERRORED)
return;
- // delete non-selected dives
- diveImportedModel->deleteDeselected();
-
- // 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);
+ int flags = IMPORT_IS_DOWNLOADED;
+ if (preferDownloaded())
+ flags |= IMPORT_PREFER_IMPORTED;
+ if (ui.createNewTrip->isChecked())
+ flags |= IMPORT_ADD_TO_NEW_TRIP;
+
+ diveImportedModel->recordDives(flags);
if (ostcFirmwareCheck && currentState == DONE)
ostcFirmwareCheck->checkLatest(this, diveImportedModel->thread.data()->internalData());