diff options
-rw-r--r-- | desktop-widgets/downloadfromdivecomputer.cpp | 5 | ||||
-rw-r--r-- | qt-models/diveimportedmodel.cpp | 25 |
2 files changed, 9 insertions, 21 deletions
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index 3c70d8686..e88817cc8 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -492,10 +492,7 @@ void DownloadFromDCWidget::onDownloadThreadFinished() } ui.downloadCancelRetryButton->setText(tr("Retry download")); ui.downloadCancelRetryButton->setEnabled(true); - // regardless, if we got dives, we should show them to the user - if (downloadTable.nr) { - diveImportedModel->setImportedDivesIndexes(0, downloadTable.nr - 1); - } + diveImportedModel->repopulate(); } void DownloadFromDCWidget::on_cancel_clicked() diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp index e988a8678..3c5a4a76b 100644 --- a/qt-models/diveimportedmodel.cpp +++ b/qt-models/diveimportedmodel.cpp @@ -135,26 +135,17 @@ void DiveImportedModel::clearTable() endRemoveRows(); } -void DiveImportedModel::setImportedDivesIndexes(int first, int last) +void DiveImportedModel::repopulate() { - if (lastIndex >= firstIndex) { - beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex); - endRemoveRows(); - } - if (last >= first) - beginInsertRows(QModelIndex(), 0, last - first); - lastIndex = last; - firstIndex = first; + beginResetModel(); + + firstIndex = 0; + lastIndex = diveTable->nr - 1; delete[] checkStates; - checkStates = new bool[last - first + 1]; - memset(checkStates, true, last - first + 1); - if (last >= first) - endInsertRows(); -} + checkStates = new bool[diveTable->nr]; + memset(checkStates, true, diveTable->nr); -void DiveImportedModel::repopulate() -{ - setImportedDivesIndexes(0, diveTable->nr-1); + endResetModel(); } void DiveImportedModel::recordDives() |