1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 13:41:16 +01:00
GPXSee/src/GUI/temperaturegraphitem.cpp

33 lines
924 B
C++
Raw Normal View History

#include <QLocale>
#include "tooltip.h"
#include "temperaturegraphitem.h"
2017-10-04 23:15:39 +02:00
TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
int width, const QColor &color, QGraphicsItem *parent)
: GraphItem(graph, type, width, color, Qt::SolidLine, parent)
{
2019-02-11 23:28:08 +01:00
_min = GraphItem::min();
_max = GraphItem::max();
_avg = GraphItem::avg();
}
ToolTip TemperatureGraphItem::info() const
{
ToolTip tt;
qreal scale = (_units == Metric) ? 1.0 : C2FS;
qreal offset = (_units == Metric) ? 0 : C2FO;
QString su = (_units == Metric) ?
QChar(0x00B0) + tr("C") : QChar(0x00B0) + tr("F");
QLocale l(QLocale::system());
tt.insert(tr("Average"), l.toString(avg() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Maximum"), l.toString(max() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
tt.insert(tr("Minimum"), l.toString(min() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
return tt;
}