2018-07-03 01:29:14 +02:00
|
|
|
#include <QMap>
|
2018-09-09 18:46:43 +02:00
|
|
|
#include <QLocale>
|
2018-07-03 01:29:14 +02:00
|
|
|
#include "tooltip.h"
|
|
|
|
#include "gearratiographitem.h"
|
|
|
|
|
2018-09-09 18:46:43 +02:00
|
|
|
|
2018-07-03 01:29:14 +02:00
|
|
|
GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type,
|
2018-07-10 08:58:37 +02:00
|
|
|
QGraphicsItem *parent) : GraphItem(graph, type, parent), _top(NAN)
|
2018-07-03 01:29:14 +02:00
|
|
|
{
|
2018-07-03 19:16:51 +02:00
|
|
|
qreal val = NAN;
|
2018-07-03 01:29:14 +02:00
|
|
|
|
|
|
|
for (QMap<qreal, qreal>::const_iterator it = _map.constBegin();
|
|
|
|
it != _map.constEnd(); ++it) {
|
|
|
|
if (it == _map.constBegin()) {
|
|
|
|
val = it.value();
|
|
|
|
_top = it.key();
|
|
|
|
} else if (it.value() > val) {
|
|
|
|
val = it.value();
|
|
|
|
_top = it.key();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setToolTip(toolTip());
|
|
|
|
}
|
|
|
|
|
|
|
|
QString GearRatioGraphItem::toolTip() const
|
|
|
|
{
|
|
|
|
ToolTip tt;
|
2018-09-09 18:46:43 +02:00
|
|
|
QLocale l(QLocale::system());
|
2018-07-03 01:29:14 +02:00
|
|
|
|
2018-09-09 18:46:43 +02:00
|
|
|
tt.insert(tr("Minimum"), l.toString(min(), 'f', 2));
|
|
|
|
tt.insert(tr("Maximum"), l.toString(max(), 'f', 2));
|
|
|
|
tt.insert(tr("Most used"), l.toString(top(), 'f', 2));
|
2018-07-03 01:29:14 +02:00
|
|
|
|
|
|
|
return tt.toString();
|
|
|
|
}
|