summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-14 21:58:04 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-14 21:58:04 +0900
commit8d284b0e2480a6a33e422186b34e0b189b026db1 (patch)
tree04dbc19f83b598ebaf43b3bee335b19f00615a5e
parent77a1ef9ebec188865c01b08b32ea1fde29575e69 (diff)
downloadsubsurface-8d284b0e2480a6a33e422186b34e0b189b026db1.tar.gz
Hook up the tank change and tank update for the planner
This failed spectacularly when I first tried it, so I put it on the back burner. And it appears that with all my recent fixes for "add dive" as a side effect this is working, too. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/diveplanner.cpp50
1 files changed, 24 insertions, 26 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 0cb3a67f3..49d89da1f 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -1302,37 +1302,35 @@ bool DivePlannerPointsModel::tankInUse(int o2, int he)
void DivePlannerPointsModel::tanksUpdated()
{
- if (mode == ADD) {
- // we don't know exactly what changed - what we care about is
- // "did a gas change on us". So we look through the diveplan to
- // see if there is a gas that is now missing and if there is, we
- // replace it with the matching new gas.
- QList<QPair<int,int> > gases = collectGases(stagingDive);
- if (gases.length() == oldGases.length()) {
- // either nothing relevant changed, or exactly ONE gasmix changed
- for (int i = 0; i < gases.length(); i++) {
- if (gases.at(i) != oldGases.at(i)) {
- if (oldGases.count(oldGases.at(i)) > 1) {
- // we had this gas more than once, so don't
- // change segments that used this gas as it still exists
- break;
- }
- for (int j = 0; j < rowCount(); j++) {
- divedatapoint& p = divepoints[j];
- int o2 = oldGases.at(i).first;
- int he = oldGases.at(i).second;
- if ((p.o2 == o2 && p.he == he) ||
- (is_air(p.o2, p.he) && (is_air(o2, he) || (o2 == 0 && he == 0)))) {
- p.o2 = gases.at(i).first;
- p.he = gases.at(i).second;
- }
- }
+ // we don't know exactly what changed - what we care about is
+ // "did a gas change on us". So we look through the diveplan to
+ // see if there is a gas that is now missing and if there is, we
+ // replace it with the matching new gas.
+ QList<QPair<int,int> > gases = collectGases(stagingDive);
+ if (gases.length() == oldGases.length()) {
+ // either nothing relevant changed, or exactly ONE gasmix changed
+ for (int i = 0; i < gases.length(); i++) {
+ if (gases.at(i) != oldGases.at(i)) {
+ if (oldGases.count(oldGases.at(i)) > 1) {
+ // we had this gas more than once, so don't
+ // change segments that used this gas as it still exists
break;
}
+ for (int j = 0; j < rowCount(); j++) {
+ divedatapoint& p = divepoints[j];
+ int o2 = oldGases.at(i).first;
+ int he = oldGases.at(i).second;
+ if ((p.o2 == o2 && p.he == he) ||
+ (is_air(p.o2, p.he) && (is_air(o2, he) || (o2 == 0 && he == 0)))) {
+ p.o2 = gases.at(i).first;
+ p.he = gases.at(i).second;
+ }
+ }
+ break;
}
}
- emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1));
}
+ emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1));
}
void DivePlannerPointsModel::clear()