diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-12-02 11:29:35 +0100 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2017-12-02 20:48:02 +0100 |
commit | de26a50ba32cf20728c846fb98f6972a0e05e852 (patch) | |
tree | 14a6b8e65e80da918ccebfe945e569220e0e2f62 /qt-models/diveplannermodel.cpp | |
parent | 1bd2f3fe3e780f642b1c0b9c11dca793e19c40ab (diff) | |
download | subsurface-de26a50ba32cf20728c846fb98f6972a0e05e852.tar.gz |
In planner variations use variables for delta values
Plus a small layout change: Add a colon behind "Stop time".
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'qt-models/diveplannermodel.cpp')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 75650ac3d..bfd718ae5 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -1034,11 +1034,23 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s if (in_planner() && prefs.display_variations && decoMode() != RECREATIONAL) { int my_instance = ++instanceCounter; cache_deco_state(&ds, &save); + + duration_t delta_time = { .seconds = 60 }; + QString time_units = tr("min"); + depth_t delta_depth; + QString depth_units; + + if (prefs.units.length == units::METERS) { + delta_depth.mm = 1000; // 1m + depth_units = tr("m"); + } else { + delta_depth.mm = feet_to_mm(1.0); // 1ft + depth_units = tr("ft"); + } last_segment = cloneDiveplan(original_plan, &plan_copy); - if (!last_segment) { + if (!last_segment) goto finish; - } if (my_instance != instanceCounter) goto finish; plan(&ds, &plan_copy, dive, 1, original, &cache, true, false); @@ -1046,8 +1058,8 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s restore_deco_state(save, &ds, false); last_segment = cloneDiveplan(original_plan, &plan_copy); - last_segment->depth.mm += 1000; - last_segment->next->depth.mm += 1000; + last_segment->depth.mm += delta_depth.mm; + last_segment->next->depth.mm += delta_depth.mm; if (my_instance != instanceCounter) goto finish; plan(&ds, &plan_copy, dive, 1, deeper, &cache, true, false); @@ -1055,8 +1067,8 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s restore_deco_state(save, &ds, false); last_segment = cloneDiveplan(original_plan, &plan_copy); - last_segment->depth.mm -= 1000; - last_segment->next->depth.mm -= 1000; + last_segment->depth.mm -= delta_depth.mm; + last_segment->next->depth.mm -= delta_depth.mm; if (my_instance != instanceCounter) goto finish; plan(&ds, &plan_copy, dive, 1, shallower, &cache, true, false); @@ -1064,7 +1076,7 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s restore_deco_state(save, &ds, false); last_segment = cloneDiveplan(original_plan, &plan_copy); - last_segment->next->time += 60; + last_segment->next->time += delta_time.seconds; if (my_instance != instanceCounter) goto finish; plan(&ds, &plan_copy, dive, 1, longer, &cache, true, false); @@ -1072,7 +1084,7 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s restore_deco_state(save, &ds, false); last_segment = cloneDiveplan(original_plan, &plan_copy); - last_segment->next->time -= 60; + last_segment->next->time -= delta_time.seconds; if (my_instance != instanceCounter) goto finish; plan(&ds, &plan_copy, dive, 1, shorter, &cache, true, false); @@ -1080,14 +1092,9 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s restore_deco_state(save, &ds, false); char buf[200]; - char *deco_time = tr("Stop times").toUtf8().data(); - if (prefs.units.length == units::METERS) - sprintf(buf, ", %s + %d:%02d /m + %d:%02d /min", deco_time, FRACTION(analyzeVariations(shallower, original, deeper, "m"),60), - FRACTION(analyzeVariations(shorter, original, longer, "min"), 60)); - else - sprintf(buf, ", %s + %d:%02d /ft + %d:%02d /min", deco_time, - FRACTION(analyzeVariations(shallower, original, deeper, "ft") * feet_to_mm(1.0) / 1000,60), - FRACTION(analyzeVariations(shorter, original, longer, "min"), 60)); + sprintf(buf, ", %s: + %d:%02d /%s + %d:%02d /min", tr("Stop times").toUtf8().data(), + FRACTION(analyzeVariations(shallower, original, deeper, depth_units.toUtf8().data()), 60), depth_units.toUtf8().data(), + FRACTION(analyzeVariations(shorter, original, longer, time_units.toUtf8().data()), 60)); emit variationsComputed(QString(buf)); #ifdef DEBUG_STOPVAR |