From 1b14a211f0719aa3a46bf0584d5652bc7c7a4b6f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 24 Jan 2021 08:50:10 +0100 Subject: 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 --- qt-models/diveplannermodel.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'qt-models') 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 &rows) { if (!rows.count()) return; - int firstRow = rowCount() - rows.count(); QVector 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(); } -- cgit v1.2.3-70-g09d2