1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-07 07:13:21 +02:00
GPXSee/src/GUI/speedgraphitem.cpp

41 lines
943 B
C++
Raw Normal View History

#include "tooltip.h"
#include "speedgraphitem.h"
2017-10-04 23:15:39 +02:00
SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
qreal movingTime, QGraphicsItem *parent) : GraphItem(graph, type, parent)
{
2017-09-25 19:56:04 +02:00
_units = Metric;
_timeType = Total;
_avg = graph.last().s() / graph.last().t();
_mavg = graph.last().s() / movingTime;
2017-09-25 19:56:04 +02:00
setToolTip(toolTip());
}
2017-09-25 19:56:04 +02:00
QString SpeedGraphItem::toolTip() const
{
ToolTip tt;
2017-09-25 19:56:04 +02:00
qreal scale = (_units == Metric) ? MS2KMH : MS2MIH;
QString su = (_units == Metric) ? tr("km/h") : tr("mi/h");
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1)
+ UNIT_SPACE + su);
2017-09-25 19:56:04 +02:00
tt.insert(tr("Average"), QString::number((_timeType == Total)
? avg() * scale : mavg() * scale, 'f', 1) + UNIT_SPACE + su);
return tt.toString();
}
void SpeedGraphItem::setUnits(Units units)
{
2017-09-25 19:56:04 +02:00
_units = units;
setToolTip(toolTip());
}
void SpeedGraphItem::setTimeType(TimeType type)
{
_timeType = type;
setToolTip(toolTip());
}