diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-06 22:11:41 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-07 08:46:15 -0700 |
commit | 6790e07a4cf03b02ea2163dd4a55ff5bcf04f834 (patch) | |
tree | f1a291663c5b9b7c23f2dafb888ebad1640e3cbe /qt-models | |
parent | 1cd9229ae0e01c2e3d7fd81faa566b3a8e02e09e (diff) | |
download | subsurface-6790e07a4cf03b02ea2163dd4a55ff5bcf04f834.tar.gz |
cleanup: use begin/endResetModel in ExtraDataModel
As we do in most other models, use begin/endResetModel() to
reset the model. This is distinctly less errorprone than
the add/removeRows() version as we don't have to check for
empty ranges, etc.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divecomputerextradatamodel.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/qt-models/divecomputerextradatamodel.cpp b/qt-models/divecomputerextradatamodel.cpp index 815c6cd81..2b2710f95 100644 --- a/qt-models/divecomputerextradatamodel.cpp +++ b/qt-models/divecomputerextradatamodel.cpp @@ -13,10 +13,9 @@ ExtraDataModel::ExtraDataModel(QObject *parent) : CleanerTableModel(parent), void ExtraDataModel::clear() { - if (rows > 0) { - beginRemoveRows(QModelIndex(), 0, rows - 1); - endRemoveRows(); - } + beginResetModel(); + rows = 0; + endResetModel(); } QVariant ExtraDataModel::data(const QModelIndex &index, int role) const @@ -57,15 +56,12 @@ int ExtraDataModel::rowCount(const QModelIndex&) const void ExtraDataModel::updateDive() { - clear(); + beginResetModel(); rows = 0; struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data; while (ed) { rows++; ed = ed->next; } - if (rows > 0) { - beginInsertRows(QModelIndex(), 0, rows - 1); - endInsertRows(); - } + endResetModel(); } |