mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: remove DiveImportedModel::setImportedDivesIndexes()
This function resets the DiveImportedModel. It takes two arguments: first and last index. All callers passed in 0 and number-of dives anyway, so remove the arguments. Since this now does the same as repopulate(), merge the two functions. Moreover, implement Qt-model semantics by using a beginResetModel()/endResetModel() pair. This simplifies the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
abf942f303
commit
6febe22b6b
2 changed files with 10 additions and 22 deletions
|
@ -492,10 +492,7 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
|
||||||
}
|
}
|
||||||
ui.downloadCancelRetryButton->setText(tr("Retry download"));
|
ui.downloadCancelRetryButton->setText(tr("Retry download"));
|
||||||
ui.downloadCancelRetryButton->setEnabled(true);
|
ui.downloadCancelRetryButton->setEnabled(true);
|
||||||
// regardless, if we got dives, we should show them to the user
|
diveImportedModel->repopulate();
|
||||||
if (downloadTable.nr) {
|
|
||||||
diveImportedModel->setImportedDivesIndexes(0, downloadTable.nr - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadFromDCWidget::on_cancel_clicked()
|
void DownloadFromDCWidget::on_cancel_clicked()
|
||||||
|
|
|
@ -135,26 +135,17 @@ void DiveImportedModel::clearTable()
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveImportedModel::setImportedDivesIndexes(int first, int last)
|
|
||||||
{
|
|
||||||
if (lastIndex >= firstIndex) {
|
|
||||||
beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex);
|
|
||||||
endRemoveRows();
|
|
||||||
}
|
|
||||||
if (last >= first)
|
|
||||||
beginInsertRows(QModelIndex(), 0, last - first);
|
|
||||||
lastIndex = last;
|
|
||||||
firstIndex = first;
|
|
||||||
delete[] checkStates;
|
|
||||||
checkStates = new bool[last - first + 1];
|
|
||||||
memset(checkStates, true, last - first + 1);
|
|
||||||
if (last >= first)
|
|
||||||
endInsertRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiveImportedModel::repopulate()
|
void DiveImportedModel::repopulate()
|
||||||
{
|
{
|
||||||
setImportedDivesIndexes(0, diveTable->nr-1);
|
beginResetModel();
|
||||||
|
|
||||||
|
firstIndex = 0;
|
||||||
|
lastIndex = diveTable->nr - 1;
|
||||||
|
delete[] checkStates;
|
||||||
|
checkStates = new bool[diveTable->nr];
|
||||||
|
memset(checkStates, true, diveTable->nr);
|
||||||
|
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveImportedModel::recordDives()
|
void DiveImportedModel::recordDives()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue