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

37 lines
818 B
C++
Raw Normal View History

#include <QMap>
#include <QLocale>
#include "tooltip.h"
#include "gearratiographitem.h"
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 19:16:51 +02:00
qreal val = NAN;
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;
QLocale l(QLocale::system());
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));
return tt.toString();
}