diff options
author | Rick Walsh <rickmwalsh@gmail.com> | 2016-07-06 22:40:30 +1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-07-09 12:08:01 -0700 |
commit | 1ba61d7ad5025cf3bafc86705cf4c174aef8c264 (patch) | |
tree | cf7ee60af949fa971479d4b180199f5910993830 /qt-models | |
parent | b8271076193c76a0695302715753efff60fdb4dc (diff) | |
download | subsurface-1ba61d7ad5025cf3bafc86705cf4c174aef8c264.tar.gz |
Update gas deco MOD when deco pO2 is changed
This fix is reasonably straightforward when the divedatapoint structure stores
the cylinder rather than gasmix.
Fixes #970
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 | 16 | ||||
-rw-r--r-- | qt-models/cylindermodel.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 6ea27f167..829639318 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -426,3 +426,19 @@ void CylindersModel::remove(const QModelIndex &index) dc = dc->next; } } + +void CylindersModel::updateDecoDepths(pressure_t olddecopo2) +{ + pressure_t decopo2; + decopo2.mbar = prefs.decopo2; + for (int i = 0; i < MAX_CYLINDERS; i++) { + cylinder_t *cyl = &displayed_dive.cylinder[i]; + struct gasmix *mygas = &cyl->gasmix; + /* If the gas's deco MOD matches the old pO2, it will have been automatically calculated and should be updated. + * If they don't match, we should leave the user entered depth as it is */ + if (cyl->depth.mm == gas_mod(&cyl->gasmix, olddecopo2, &displayed_dive, M_OR_FT(3, 10)).mm) { + cyl->depth = gas_mod(&cyl->gasmix, decopo2, &displayed_dive, M_OR_FT(3, 10)); + } + } + emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1)); +} diff --git a/qt-models/cylindermodel.h b/qt-models/cylindermodel.h index 7115dbe25..f2ae0125e 100644 --- a/qt-models/cylindermodel.h +++ b/qt-models/cylindermodel.h @@ -35,6 +35,7 @@ public: void clear(); void updateDive(); void copyFromDive(struct dive *d); + void updateDecoDepths(pressure_t olddecopo2); cylinder_t *cylinderAt(const QModelIndex &index); bool changed; |