summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-11 07:46:21 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-11 07:46:21 -0800
commit578e9c22af7277430a0f8a3bd684ea22d91612fd (patch)
tree380e9b7d1cc0ac96654c194e86928d4b7349c32f /qt-ui
parentbccbdf8264cd86890f0719e10e665a73b062e96e (diff)
downloadsubsurface-578e9c22af7277430a0f8a3bd684ea22d91612fd.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp14
-rw-r--r--qt-ui/downloadfromdivecomputer.h2
2 files changed, 15 insertions, 1 deletions
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);
diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h
index c92190b78..92db09d66 100644
--- a/qt-ui/downloadfromdivecomputer.h
+++ b/qt-ui/downloadfromdivecomputer.h
@@ -36,7 +36,7 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
void setImportedDivesIndexes(int first, int last);
Qt::ItemFlags flags(const QModelIndex &index) const;
- void removeUnused();
+ void clearTable();
public
slots: