From a24b1a402767a7df16d101ee54d2ea565ec49498 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 22 Sep 2019 18:55:45 +0200 Subject: 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 --- desktop-widgets/downloadfromdivecomputer.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'desktop-widgets') 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(); -- cgit v1.2.3-70-g09d2