From 3fc8bee85f1bebf02e8a602ba0726823d1639f51 Mon Sep 17 00:00:00 2001 From: Joern Date: Sun, 16 Nov 2014 19:20:25 +0100 Subject: [PATCH] Fix Metric/Imperial - conversion issues In LTM Plot and on Summary Windows conversion ... data already converted for the curves was converted again ... for "Best" Summary the conversion was missing Referring to issues #1067 #1071 (see also comments on issue #1069 --- src/LTMPlot.cpp | 9 +++------ src/LTMWindow.cpp | 3 +-- src/SummaryMetrics.cpp | 5 ++++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/LTMPlot.cpp b/src/LTMPlot.cpp index 42c4730b9..c2c9313c6 100644 --- a/src/LTMPlot.cpp +++ b/src/LTMPlot.cpp @@ -1006,8 +1006,7 @@ LTMPlot::setData(LTMSettings *set) if (metricDetail.uunits == "km") precision=0; // we have a metric so lets be precise ... - labelString = QString("%1").arg(value * (context->athlete->useMetricUnits ? 1 : m->conversion()) - + (context->athlete->useMetricUnits ? 0 : m->conversionSum()), 0, 'f', precision); + labelString = QString("%1").arg(value, 0, 'f', precision); } else { // no precision @@ -1857,8 +1856,7 @@ LTMPlot::setCompareData(LTMSettings *set) if (metricDetail.uunits == "km") precision=0; // we have a metric so lets be precise ... - labelString = QString("%1").arg(value * (context->athlete->useMetricUnits ? 1 : m->conversion()) - + (context->athlete->useMetricUnits ? 0 : m->conversionSum()), 0, 'f', precision); + labelString = QString("%1").arg(value , 0, 'f', precision); } else { // no precision @@ -2019,8 +2017,7 @@ LTMPlot::setCompareData(LTMSettings *set) if (metricDetail.uunits == "km") precision=0; // we have a metric so lets be precise ... - labelString = QString("%1").arg(value * (context->athlete->useMetricUnits ? 1 : m->conversion()) - + (context->athlete->useMetricUnits ? 0 : m->conversionSum()), 0, 'f', precision); + labelString = QString("%1").arg(value, 0, 'f', precision); } else { // no precision diff --git a/src/LTMWindow.cpp b/src/LTMWindow.cpp index 5d2435eed..8a523eb14 100644 --- a/src/LTMWindow.cpp +++ b/src/LTMWindow.cpp @@ -1291,8 +1291,7 @@ LTMWindow::dataTable(bool html) if (settings.metrics[j].uunits == "seconds" || settings.metrics[j].uunits == tr("seconds")) precision=1; // we have a metric so lets be precise ... - QString v = QString("%1").arg(aggregates[j].y[i] * (context->athlete->useMetricUnits ? 1 : m->conversion()) - + (context->athlete->useMetricUnits ? 0 : m->conversionSum()), 0, 'f', precision); + QString v = QString("%1").arg(aggregates[j].y[i], 0, 'f', precision); summary = summary.arg(v); diff --git a/src/SummaryMetrics.cpp b/src/SummaryMetrics.cpp index 271cd3b05..ef031fdac 100644 --- a/src/SummaryMetrics.cpp +++ b/src/SummaryMetrics.cpp @@ -211,7 +211,7 @@ QList SummaryMetrics::getBests(Context *context, QString symbol, int n, const QList &data, const QStringList &filters, bool filtered, - bool /* useMetricUnits */) + bool useMetricUnits ) { QList results; @@ -229,6 +229,9 @@ SummaryMetrics::getBests(Context *context, QString symbol, int n, // get this value SummaryBest add; add.nvalue = rideMetrics.getForSymbol(symbol); + if (useMetricUnits == false) { + add.nvalue *= metric->conversion(); + } add.date = rideMetrics.getRideDate().date(); // XXX this needs improving for all cases ... hack for now