mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Replace cylinder_is_used with is_cylinder_used
is_cylinder_used uses get_cylinder_index as underlaying function that does the right thing with with respect on how to find the closest matching cylinder, and handles both types of gaschange events correctly. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
810880ea1d
commit
950638ec1c
6 changed files with 7 additions and 32 deletions
|
@ -308,7 +308,7 @@ void CylindersModel::updateDive()
|
|||
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||
if (!cylinder_none(&displayed_dive.cylinder[i]) &&
|
||||
(prefs.display_unused_tanks ||
|
||||
cylinder_is_used(&displayed_dive, &displayed_dive.cylinder[i]) ||
|
||||
is_cylinder_used(&displayed_dive, i) ||
|
||||
displayed_dive.cylinder[i].manually_added))
|
||||
rows = i + 1;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ void CylindersModel::copyFromDive(dive *d)
|
|||
return;
|
||||
rows = 0;
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||
if (!cylinder_none(&d->cylinder[i]) && cylinder_is_used(d, &d->cylinder[i])) {
|
||||
if (!cylinder_none(&d->cylinder[i]) && is_cylinder_used(d, i)) {
|
||||
rows = i + 1;
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ void CylindersModel::remove(const QModelIndex &index)
|
|||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
||||
DivePlannerPointsModel::instance()->tankInUse(cyl->gasmix)) ||
|
||||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
|
||||
(cyl->manually_added || cylinder_is_used(&displayed_dive, cyl))))) {
|
||||
(cyl->manually_added || is_cylinder_used(&displayed_dive, index.row()))))) {
|
||||
QMessageBox::warning(MainWindow::instance(), TITLE_OR_TEXT(
|
||||
tr("Cylinder cannot be removed"),
|
||||
tr("This gas is in use. Only cylinders that are not used in the dive can be removed.")),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue