When the user cancels a download, reject already downloaded dives

This seems like the more logical behavior, anyway. Cancel means you didn't
want the result...

Fixes #341

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-12-08 06:33:46 +01:00
parent ad6fab9fb0
commit 50a1ed8d6e
2 changed files with 15 additions and 3 deletions

View file

@ -237,6 +237,9 @@ void DownloadFromDCWidget::on_ok_clicked()
MainWindow *w = mainWindow();
connect(thread, SIGNAL(finished()), w, SLOT(refreshDisplay()));
// before we start, remember where the dive_table ended
previousLast = dive_table.nr;
thread->start();
}
@ -262,10 +265,18 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
updateState(ERROR);
// I'm not sure if we should really call process_dives even
// if there's an error or a cancelation
process_dives(TRUE, preferDownloaded());
} else
// if there's an error
if (import_thread_cancelled) {
// walk backwards so we don't keep moving the dives
// down in the dive_table
for (int i = dive_table.nr - 1; i >= previousLast; i--)
delete_single_dive(i);
} else {
process_dives(TRUE, preferDownloaded());
}
} else {
updateState(CANCELLED);
}
}
void DownloadFromDCWidget::markChildrenAsDisabled()

View file

@ -59,6 +59,7 @@ private:
QHash<QString, QStringList> productList;
QMap<QString, dc_descriptor_t *> descriptorLookup;
device_data_t data;
int previousLast;
QStringListModel *vendorModel;
QStringListModel *productModel;