diff --git a/core/units.h b/core/units.h index a67f4aa6f..61d1a3e50 100644 --- a/core/units.h +++ b/core/units.h @@ -14,6 +14,7 @@ extern "C" { #endif #define FRACTION(n, x) ((unsigned)(n) / (x)), ((unsigned)(n) % (x)) +#define SIGNED_FRAC(n, x) ((n) >= 0 ? '+': '-'), ((n) >= 0 ? (unsigned)(n) / (x) : (-(n) / (x))), ((unsigned)((n) >= 0 ? (n) : -(n)) % (x)) #define O2_IN_AIR 209 // permille #define N2_IN_AIR 781 diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index b952202d3..1f77ab5ca 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -1258,9 +1258,9 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, c restore_deco_state(save, &ds, false); char buf[200]; - sprintf(buf, ", %s: + %d:%02d /%s + %d:%02d /min", qPrintable(tr("Stop times")), - FRACTION(analyzeVariations(shallower, original, deeper, qPrintable(depth_units)), 60), qPrintable(depth_units), - FRACTION(analyzeVariations(shorter, original, longer, qPrintable(time_units)), 60)); + sprintf(buf, ", %s: %c %d:%02d /%s %c %d:%02d /min", qPrintable(tr("Stop times")), + SIGNED_FRAC(analyzeVariations(shallower, original, deeper, qPrintable(depth_units)), 60), qPrintable(depth_units), + SIGNED_FRAC(analyzeVariations(shorter, original, longer, qPrintable(time_units)), 60)); // By using a signal, we can transport the variations to the main thread. emit variationsComputed(QString(buf));