diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-10-20 13:30:04 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2017-10-30 21:45:56 +0100 |
commit | 2bfcc5554f4ed77e22244f3ea3b2ae960fa81c80 (patch) | |
tree | df228d267f31a6828d1c5e765534af1168dba098 /qt-models/cylindermodel.cpp | |
parent | 582ce3b0f11eb7cd645ee26c80d59b89f5883df7 (diff) | |
download | subsurface-2bfcc5554f4ed77e22244f3ea3b2ae960fa81c80.tar.gz |
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>
Diffstat (limited to 'qt-models/cylindermodel.cpp')
-rw-r--r-- | qt-models/cylindermodel.cpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 854c148f3..e61926084 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -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--; |