mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
DiveImportedModel: be consistent with last = -1
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fd96daca6a
commit
f67b3a9852
1 changed files with 5 additions and 7 deletions
|
@ -139,26 +139,24 @@ void DiveImportedModel::clearTable()
|
||||||
|
|
||||||
void DiveImportedModel::setImportedDivesIndexes(int first, int last)
|
void DiveImportedModel::setImportedDivesIndexes(int first, int last)
|
||||||
{
|
{
|
||||||
Q_ASSERT(last >= first);
|
|
||||||
if (lastIndex >= firstIndex) {
|
if (lastIndex >= firstIndex) {
|
||||||
beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex);
|
beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
beginInsertRows(QModelIndex(), 0, last - first);
|
if (last >= first)
|
||||||
|
beginInsertRows(QModelIndex(), 0, last - first);
|
||||||
lastIndex = last;
|
lastIndex = last;
|
||||||
firstIndex = first;
|
firstIndex = first;
|
||||||
delete[] checkStates;
|
delete[] checkStates;
|
||||||
checkStates = new bool[last - first + 1];
|
checkStates = new bool[last - first + 1];
|
||||||
memset(checkStates, true, last - first + 1);
|
memset(checkStates, true, last - first + 1);
|
||||||
endInsertRows();
|
if (last >= first)
|
||||||
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveImportedModel::repopulate()
|
void DiveImportedModel::repopulate()
|
||||||
{
|
{
|
||||||
if (diveTable->nr)
|
setImportedDivesIndexes(0, diveTable->nr-1);
|
||||||
setImportedDivesIndexes(0, diveTable->nr-1);
|
|
||||||
else
|
|
||||||
setImportedDivesIndexes(0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveImportedModel::recordDives()
|
void DiveImportedModel::recordDives()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue