mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 17:33:24 +00:00
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>
This commit is contained in:
parent
35c5ec09b7
commit
1b14a211f0
1 changed files with 3 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue