4 #include "speedgraphitem.h"
7 SpeedGraphItem::SpeedGraphItem(const Graph
&graph
, GraphType type
, int width
,
8 const QColor
&color
, qreal movingTime
, QGraphicsItem
*parent
)
9 : GraphItem(graph
, type
, width
, color
, parent
)
14 _max
= GraphItem::max();
15 _avg
= graph
.last().last().s() / graph
.last().last().t();
16 _mavg
= graph
.last().last().s() / movingTime
;
18 setToolTip(toolTip());
21 QString
SpeedGraphItem::toolTip() const
24 qreal scale
= (_units
== Imperial
) ? MS2MIH
: (_units
== Nautical
)
26 QString su
= (_units
== Imperial
) ? tr("mi/h") : (_units
== Nautical
)
27 ? tr("kn") : tr("km/h");
28 QString pace
= Format::timeSpan((3600.0 / ((_timeType
== Total
)
29 ? avg() * scale
: mavg() * scale
)), false);
30 QString pu
= (_units
== Metric
) ? tr("min/km") : (_units
== Imperial
) ?
31 tr("min/mi") : tr("min/nmi");
32 QLocale
l(QLocale::system());
34 tt
.insert(tr("Maximum"), l
.toString(max() * scale
, 'f', 1)
36 tt
.insert(tr("Average"), l
.toString((_timeType
== Total
)
37 ? avg() * scale
: mavg() * scale
, 'f', 1) + UNIT_SPACE
+ su
);
38 tt
.insert(tr("Pace"), pace
+ UNIT_SPACE
+ pu
);
43 void SpeedGraphItem::setUnits(Units units
)
46 setToolTip(toolTip());
49 void SpeedGraphItem::setTimeType(TimeType type
)
52 setToolTip(toolTip());