diff options
author | Rick Walsh <rickmwalsh@gmail.com> | 2016-07-06 22:40:32 +1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-07-09 12:08:10 -0700 |
commit | 6ed5e0d621dfaf481821bf8167e28fe61d4ba583 (patch) | |
tree | 84550bd9855c963af82cd3a715b85a8ff193765a /qt-models | |
parent | 9fbd11744f1bfffbc6973e0f9483ae1630dd8722 (diff) | |
download | subsurface-6ed5e0d621dfaf481821bf8167e28fe61d4ba583.tar.gz |
Add MOD and MND fields to cylindermodel
Adds fields to the planner cylinder model for maximum operating depth (MOD)
for a bottom mix gas, and maximum narcotic depth (MND). Fields are read/write,
so changing MOD changes %O2 and vice-versa. Changing MND changes %He and
vice-versa.
When setting MOD directly, the %O2 is truncated (rounded down) to an integer,
which re-calculates the MOD, which is sometimes a few metres greater than the
input depth. This is desireable behaviour, as the rounding is conservative.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/cylindermodel.cpp | 35 | ||||
-rw-r--r-- | qt-models/cylindermodel.h | 2 |
2 files changed, 26 insertions, 11 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 829639318..eff2a334a 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -12,9 +12,9 @@ CylindersModel::CylindersModel(QObject *parent) : changed(false), rows(0) { - // enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH}; + // enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH, MOD, MND, USE}; setHeaderDataStrings(QStringList() << "" << tr("Type") << tr("Size") << tr("Work press.") << tr("Start press.") << tr("End press.") << tr("O₂%") << tr("He%") - << tr("Switch at") << tr("Use")); + << tr("Switch at") <<tr("Bot. MOD") <<tr("MND") << tr("Use")); } @@ -134,6 +134,14 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const case DEPTH: ret = get_depth_string(cyl->depth, true); break; + case MOD: + pressure_t modpO2; + modpO2.mbar = prefs.bottompo2; + ret = get_depth_string(gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1))); + break; + case MND: + ret = get_depth_string(gas_mnd(&cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1))); + break; case USE: ret = gettextFromC::instance()->trGettext(cylinderuse_text[cyl->cylinder_use]); break; @@ -273,19 +281,24 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in break; case DEPTH: if (CHANGED()) { - /* Calculate best nitrox mix for cylinder depth if input text ends with "bn", - * or best (trimix) mix if input text ends with "b" */ - if (vString.toLower().endsWith("bn")) { - cyl->gasmix.o2 = best_o2(string_to_depth(vString.toUtf8().data()), &displayed_dive); - cyl->gasmix.he.permille = 0; - } else if (vString.toLower().endsWith("b")) { - cyl->gasmix.o2 = best_o2(string_to_depth(vString.toUtf8().data()), &displayed_dive); - cyl->gasmix.he = best_He(string_to_depth(vString.toUtf8().data()), &displayed_dive); - } cyl->depth = string_to_depth(vString.toUtf8().data()); changed = true; } break; + case MOD: + if (CHANGED()) { + // Calculate fO2 for input depth + cyl->gasmix.o2 = best_o2(string_to_depth(vString.toUtf8().data()), &displayed_dive); + changed = true; + } + break; + case MND: + if (CHANGED()) { + // Calculate fHe for input depth + cyl->gasmix.he = best_He(string_to_depth(vString.toUtf8().data()), &displayed_dive); + changed = true; + } + break; case USE: if (CHANGED()) { int use = vString.toInt(); diff --git a/qt-models/cylindermodel.h b/qt-models/cylindermodel.h index f2ae0125e..85cca1a9c 100644 --- a/qt-models/cylindermodel.h +++ b/qt-models/cylindermodel.h @@ -19,6 +19,8 @@ public: O2, HE, DEPTH, + MOD, + MND, USE, COLUMNS }; |