mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Tidy up code for cylinder remove decision in cylindermodel.cpp
Replace currentMode() != ...:NOTHING with equivalent in_planner() Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
parent
582ce3b0f1
commit
2bfcc5554f
1 changed files with 7 additions and 16 deletions
|
@ -233,11 +233,8 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
||||||
if (index.column() == REMOVE) {
|
if (index.column() == REMOVE) {
|
||||||
same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||||
|
|
||||||
if ((in_planner() || same_gas == -1) &&
|
if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
(!in_planner() && is_cylinder_used(&displayed_dive, index.row()) && same_gas == -1)) {
|
||||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
|
||||||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
|
|
||||||
is_cylinder_used(&displayed_dive, index.row())))) {
|
|
||||||
ret = trashForbiddenIcon();
|
ret = trashForbiddenIcon();
|
||||||
}
|
}
|
||||||
else ret = trashIcon();
|
else ret = trashIcon();
|
||||||
|
@ -249,11 +246,8 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||||
|
|
||||||
if ((in_planner() || same_gas == -1) &&
|
if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
(!in_planner() && is_cylinder_used(&displayed_dive, index.row()) && same_gas == -1)) {
|
||||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
|
||||||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
|
|
||||||
is_cylinder_used(&displayed_dive, index.row())))) {
|
|
||||||
ret = tr("This gas is in use. Only cylinders that are not used in the dive can be removed.");
|
ret = tr("This gas is in use. Only cylinders that are not used in the dive can be removed.");
|
||||||
}
|
}
|
||||||
else ret = tr("Clicking here will remove this cylinder.");
|
else ret = tr("Clicking here will remove this cylinder.");
|
||||||
|
@ -546,11 +540,8 @@ void CylindersModel::remove(const QModelIndex &index)
|
||||||
cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
||||||
int same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
int same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||||
|
|
||||||
if ((in_planner() || same_gas == -1) &&
|
if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
(!in_planner() && is_cylinder_used(&displayed_dive, index.row()) && same_gas == -1))
|
||||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
|
||||||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
|
|
||||||
is_cylinder_used(&displayed_dive, index.row()))))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
|
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
|
||||||
|
|
Loading…
Add table
Reference in a new issue