diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-24 08:50:10 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-04-02 13:53:23 -0700 |
commit | 1b14a211f0719aa3a46bf0584d5652bc7c7a4b6f (patch) | |
tree | 606ca1be340fbdf73aa5cf6aa6db4d564a5c6454 /qt-models | |
parent | 35c5ec09b7a6365241c02faf89bf9cefc1a23bf5 (diff) | |
download | subsurface-1b14a211f0719aa3a46bf0584d5652bc7c7a4b6f.tar.gz |
planner: fix removal of points from DivePlannerPointsModel
The beginRemoveRows() function was fed erroneous values. It
is a mystery why this didn't crash. In any case, deletion
of multiple points did not work properly. Instead of trying
to be fancy, remove each point one-by-one.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 1099e6785..2f9272415 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -28,20 +28,18 @@ CylindersModel *DivePlannerPointsModel::cylindersModel() return &cylinders; } -/* TODO: Port this to CleanerTableModel to remove a bit of boilerplate. */ void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows) { if (!rows.count()) return; - int firstRow = rowCount() - rows.count(); QVector<int> v2 = rows; std::sort(v2.begin(), v2.end()); - beginRemoveRows(QModelIndex(), firstRow, rowCount() - 1); for (int i = v2.count() - 1; i >= 0; i--) { - divepoints.remove(v2[i]); + beginRemoveRows(QModelIndex(), v2[i], v2[i]); + divepoints.erase(divepoints.begin() + v2[i]); + endRemoveRows(); } - endRemoveRows(); cylinders.updateTrashIcon(); } |