summaryrefslogtreecommitdiffstats
path: root/qt-models/diveimportedmodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-12-09 18:56:51 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-12-17 07:37:32 -0800
commit6febe22b6b0b03a99a2b1f08df8e75f43f5ba867 (patch)
tree6203cee04cb714f3aee3cbb24630f34ef58b91a2 /qt-models/diveimportedmodel.cpp
parentabf942f30300e6d46652c312f2b531dc3540b19a (diff)
downloadsubsurface-6febe22b6b0b03a99a2b1f08df8e75f43f5ba867.tar.gz
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>
Diffstat (limited to 'qt-models/diveimportedmodel.cpp')
-rw-r--r--qt-models/diveimportedmodel.cpp25
1 files changed, 8 insertions, 17 deletions
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()