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>
This commit is contained in:
Berthold Stoeger 2019-09-22 18:55:45 +02:00 committed by Dirk Hohndel
parent 30b384cebd
commit a24b1a4027

View file

@ -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();