summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-09-22 18:55:45 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-02 08:04:49 -0700
commita24b1a402767a7df16d101ee54d2ea565ec49498 (patch)
treeff1de31aff6c3aa1189fdc2c49e4eba2d69f8230 /desktop-widgets/downloadfromdivecomputer.cpp
parent30b384cebd3d488c24c211ccbb4511566d00d4f1 (diff)
downloadsubsurface-a24b1a402767a7df16d101ee54d2ea565ec49498.tar.gz
Desktop: Use DiveImportedModel::deleteDeselected()
In DownloadFromDCWidget::on_ok_clicked() deselected dives were directly deleted from the dive table, leaving DiveImportedModel in an inconsistent state. Use the function in DiveImportedModel instead. This also removes code duplication. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/downloadfromdivecomputer.cpp')
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index 129870727..1e957808f 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -529,14 +529,7 @@ void DownloadFromDCWidget::on_ok_clicked()
struct dive_site_table *sites = diveImportedModel->thread.sites();
// delete non-selected dives
- int total = table->nr;
- int j = 0;
- for (int i = 0; i < total; i++) {
- if (diveImportedModel->data(diveImportedModel->index(i, 0), Qt::CheckStateRole) == Qt::Checked)
- j++;
- else
- delete_dive_from_table(diveImportedModel->thread.table(), j);
- }
+ diveImportedModel->deleteDeselected();
if (table->nr > 0) {
auto data = diveImportedModel->thread.data();