diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-10-08 05:14:57 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2017-10-16 17:14:17 +0200 |
commit | c29456f0bb11f07befc3af66ee7973258b491d20 (patch) | |
tree | 1450d12fc2763686a52d15e942d35a95a7984f97 /qt-models/diveplannermodel.cpp | |
parent | 8fd1c72f040cd2b3163de31c4f48659366979a39 (diff) | |
download | subsurface-c29456f0bb11f07befc3af66ee7973258b491d20.tar.gz |
Used gas in dive planner points: Support for multiple cyl with same gas
In the planner if one adds two or more cylinders with the same gasmix
(e.g. back gas and bottom stage 18/45) the drop down and data in the
used gas column of the planner points table will be filled with a more
verbose string mentioning also the cyl number and the cyl type
description.
Makes it easier in such a case to select the right cylinder.
Introduces also a helper function which tells you if there is another
cylinder with the same gasmix as the provided cylinder.
This also has an option if it should consider unused cylinders or not.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'qt-models/diveplannermodel.cpp')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 482647575..57866b9e8 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -181,7 +181,14 @@ QStringList &DivePlannerPointsModel::getGasList() cylinder_t *cyl = &displayed_dive.cylinder[i]; if (cylinder_nodata(cyl)) break; - list.push_back(get_gas_string(cyl->gasmix)); + /* Check if we have the same gasmix two or more times + * If yes return more verbose string */ + int same_gas = same_gasmix_cylinder(cyl, i, &displayed_dive, true); + if (same_gas == -1) + list.push_back(get_gas_string(cyl->gasmix)); + else + list.push_back(get_gas_string(cyl->gasmix) + QString(" (%1 %2 ").arg(tr("cyl.")).arg(i + 1) + + cyl->type.description + ")"); } return list; } @@ -258,7 +265,15 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const else return p.time / 60; case GAS: - return get_gas_string(displayed_dive.cylinder[p.cylinderid].gasmix); + /* Check if we have the same gasmix two or more times + * If yes return more verbose string */ + int same_gas = same_gasmix_cylinder(&displayed_dive.cylinder[p.cylinderid], p.cylinderid, &displayed_dive, true); + if (same_gas == -1) + return get_gas_string(displayed_dive.cylinder[p.cylinderid].gasmix); + else + return get_gas_string(displayed_dive.cylinder[p.cylinderid].gasmix) + + QString(" (%1 %2 ").arg(tr("cyl.")).arg(p.cylinderid + 1) + + displayed_dive.cylinder[p.cylinderid].type.description + ")"; } } else if (role == Qt::DecorationRole) { switch (index.column()) { |