From 578e9c22af7277430a0f8a3bd684ea22d91612fd Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 11 Jan 2015 07:46:21 -0800 Subject: Dive d/l selection UI: clear table when retrying After a partial download (because the user hits cancel or because there was an error, if the user hits Retry the list of dives downloaded so far should be cleared because we will simply try to re-download the same dives again. Signed-off-by: Dirk Hohndel --- qt-ui/downloadfromdivecomputer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'qt-ui/downloadfromdivecomputer.cpp') diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index da3bb136b..10a3a20b8 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -286,6 +286,12 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() updateState(CANCELLING); return; } + if (currentState == DONE) { + // this means we are retrying - so we better clean out the partial + // list of downloaded dives from the last attempt + diveImportedModel->clearTable(); + clear_table(&downloadTable); + } updateState(DOWNLOADING); // you cannot cancel the dialog, just the download @@ -620,6 +626,14 @@ Qt::ItemFlags DiveImportedModel::flags(const QModelIndex &index) const return QAbstractTableModel::flags(index) | Qt::ItemIsUserCheckable; } +void DiveImportedModel::clearTable() +{ + beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex); + lastIndex = -1; + firstIndex = 0; + endRemoveRows(); +} + void DiveImportedModel::setImportedDivesIndexes(int first, int last) { Q_ASSERT(last >= first); -- cgit v1.2.3-70-g09d2