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) {
|
||||
same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||
|
||||
if ((in_planner() || same_gas == -1) &&
|
||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
|
||||
is_cylinder_used(&displayed_dive, index.row())))) {
|
||||
if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
(!in_planner() && is_cylinder_used(&displayed_dive, index.row()) && same_gas == -1)) {
|
||||
ret = trashForbiddenIcon();
|
||||
}
|
||||
else ret = trashIcon();
|
||||
|
@ -249,11 +246,8 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
|||
case REMOVE:
|
||||
same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||
|
||||
if ((in_planner() || same_gas == -1) &&
|
||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
|
||||
is_cylinder_used(&displayed_dive, index.row())))) {
|
||||
if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
(!in_planner() && is_cylinder_used(&displayed_dive, index.row()) && same_gas == -1)) {
|
||||
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.");
|
||||
|
@ -546,12 +540,9 @@ void CylindersModel::remove(const QModelIndex &index)
|
|||
cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
||||
int same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||
|
||||
if ((in_planner() || same_gas == -1) &&
|
||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
|
||||
is_cylinder_used(&displayed_dive, index.row()))))
|
||||
return;
|
||||
if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
(!in_planner() && is_cylinder_used(&displayed_dive, index.row()) && same_gas == -1))
|
||||
return;
|
||||
|
||||
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
|
||||
rows--;
|
||||
|
|
Loading…
Add table
Reference in a new issue