4 #include "speedgraphitem.h"
7 SpeedGraphItem::SpeedGraphItem(const Graph
&graph
, GraphType type
, int width
,
8 const QColor
&color
, Qt::PenStyle style
, qreal movingTime
,
9 QGraphicsItem
*parent
) : GraphItem(graph
, type
, width
, color
, style
, parent
)
13 _max
= GraphItem::max();
14 _avg
= graph
.last().last().s() / graph
.last().last().t();
15 _mavg
= graph
.last().last().s() / movingTime
;
18 ToolTip
SpeedGraphItem::info() const
21 qreal scale
= (_units
== Imperial
) ? MS2MIH
: (_units
== Nautical
)
23 QString su
= (_units
== Imperial
) ? tr("mi/h") : (_units
== Nautical
)
24 ? tr("kn") : tr("km/h");
25 QString pace
= Format::timeSpan((3600.0 / ((_timeType
== Total
)
26 ? avg() * scale
: mavg() * scale
)), false);
27 QString pu
= (_units
== Metric
) ? tr("min/km") : (_units
== Imperial
) ?
28 tr("min/mi") : tr("min/nmi");
29 QLocale
l(QLocale::system());
31 tt
.insert(tr("Maximum"), l
.toString(max() * scale
, 'f', 1)
33 tt
.insert(tr("Average"), l
.toString((_timeType
== Total
)
34 ? avg() * scale
: mavg() * scale
, 'f', 1) + UNIT_SPACE
+ su
);
35 tt
.insert(tr("Pace"), pace
+ UNIT_SPACE
+ pu
);
40 void SpeedGraphItem::setTimeType(TimeType type
)