mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 00:03:24 +00:00
When removing a cylinder completely fill the mapping table
When deleting a cylinder the mapping was not filled with all necessary values. Values for cylinders before deleted cylinder were missing. Plus do the endRemoveRows at the right time. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
parent
daac80b7bd
commit
96d2e57843
1 changed files with 8 additions and 4 deletions
|
@ -563,6 +563,8 @@ void CylindersModel::remove(const QModelIndex &index)
|
||||||
// as first gas
|
// as first gas
|
||||||
memmove(cyl, &displayed_dive.cylinder[same_gas], sizeof(*cyl));
|
memmove(cyl, &displayed_dive.cylinder[same_gas], sizeof(*cyl));
|
||||||
remove_cylinder(&displayed_dive, same_gas);
|
remove_cylinder(&displayed_dive, same_gas);
|
||||||
|
for (int i = 0; i < same_gas - 1; i++)
|
||||||
|
mapping[i] = i;
|
||||||
mapping[same_gas] = 0;
|
mapping[same_gas] = 0;
|
||||||
for (int i = same_gas + 1; i < MAX_CYLINDERS; i++)
|
for (int i = same_gas + 1; i < MAX_CYLINDERS; i++)
|
||||||
mapping[i] = i - 1;
|
mapping[i] = i - 1;
|
||||||
|
@ -570,15 +572,17 @@ void CylindersModel::remove(const QModelIndex &index)
|
||||||
remove_cylinder(&displayed_dive, index.row());
|
remove_cylinder(&displayed_dive, index.row());
|
||||||
if (same_gas > index.row())
|
if (same_gas > index.row())
|
||||||
same_gas--;
|
same_gas--;
|
||||||
|
for (int i = 0; i < index.row(); i++)
|
||||||
|
mapping[i] = i;
|
||||||
mapping[index.row()] = same_gas;
|
mapping[index.row()] = same_gas;
|
||||||
for (int i = index.row() + 1; i < MAX_CYLINDERS; i++)
|
for (int i = index.row() + 1; i < MAX_CYLINDERS; i++)
|
||||||
mapping[i] = i - 1;
|
mapping[i] = i - 1;
|
||||||
}
|
}
|
||||||
changed = true;
|
|
||||||
endRemoveRows();
|
|
||||||
cylinder_renumber(&displayed_dive, mapping);
|
cylinder_renumber(&displayed_dive, mapping);
|
||||||
if (in_planner())
|
if (in_planner())
|
||||||
DivePlannerPointsModel::instance()->cylinderRenumber(mapping);
|
DivePlannerPointsModel::instance()->cylinderRenumber(mapping);
|
||||||
|
changed = true;
|
||||||
|
endRemoveRows();
|
||||||
dataChanged(index, index);
|
dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,11 +601,11 @@ void CylindersModel::moveAtFirst(int cylid)
|
||||||
mapping[cylid] = 0;
|
mapping[cylid] = 0;
|
||||||
for (int i = cylid + 1; i < MAX_CYLINDERS; i++)
|
for (int i = cylid + 1; i < MAX_CYLINDERS; i++)
|
||||||
mapping[i] = i;
|
mapping[i] = i;
|
||||||
changed = true;
|
|
||||||
endMoveRows();
|
|
||||||
cylinder_renumber(&displayed_dive, mapping);
|
cylinder_renumber(&displayed_dive, mapping);
|
||||||
if (in_planner())
|
if (in_planner())
|
||||||
DivePlannerPointsModel::instance()->cylinderRenumber(mapping);
|
DivePlannerPointsModel::instance()->cylinderRenumber(mapping);
|
||||||
|
changed = true;
|
||||||
|
endMoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
|
void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
|
||||||
|
|
Loading…
Add table
Reference in a new issue