2018-09-09 18:46:43 +02:00
|
|
|
#include <QLocale>
|
2017-09-24 19:54:13 +02:00
|
|
|
#include "tooltip.h"
|
|
|
|
#include "temperaturegraphitem.h"
|
|
|
|
|
2018-09-09 18:46:43 +02:00
|
|
|
|
2017-10-04 23:15:39 +02:00
|
|
|
TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
|
2019-08-25 10:54:25 +02:00
|
|
|
int width, const QColor &color, QGraphicsItem *parent)
|
2020-03-25 23:08:26 +01:00
|
|
|
: GraphItem(graph, type, width, color, Qt::SolidLine, parent)
|
2017-09-24 19:54:13 +02:00
|
|
|
{
|
2019-02-11 23:28:08 +01:00
|
|
|
_min = GraphItem::min();
|
|
|
|
_max = GraphItem::max();
|
|
|
|
_avg = GraphItem::avg();
|
2017-09-24 19:54:13 +02:00
|
|
|
}
|
|
|
|
|
2021-08-04 08:57:42 +02:00
|
|
|
ToolTip TemperatureGraphItem::info() const
|
2017-09-24 19:54:13 +02:00
|
|
|
{
|
|
|
|
ToolTip tt;
|
2019-10-15 23:59:15 +02:00
|
|
|
qreal scale = (_units == Metric) ? 1.0 : C2FS;
|
|
|
|
qreal offset = (_units == Metric) ? 0 : C2FO;
|
|
|
|
QString su = (_units == Metric) ?
|
2017-09-24 19:54:13 +02:00
|
|
|
QChar(0x00B0) + tr("C") : QChar(0x00B0) + tr("F");
|
2018-09-09 18:46:43 +02:00
|
|
|
QLocale l(QLocale::system());
|
2017-09-24 19:54:13 +02:00
|
|
|
|
2018-09-09 18:46:43 +02:00
|
|
|
tt.insert(tr("Average"), l.toString(avg() * scale + offset, 'f', 1)
|
2017-09-24 19:54:13 +02:00
|
|
|
+ UNIT_SPACE + su);
|
2018-09-09 18:46:43 +02:00
|
|
|
tt.insert(tr("Maximum"), l.toString(max() * scale + offset, 'f', 1)
|
2017-09-24 19:54:13 +02:00
|
|
|
+ UNIT_SPACE + su);
|
2018-09-09 18:46:43 +02:00
|
|
|
tt.insert(tr("Minimum"), l.toString(min() * scale + offset, 'f', 1)
|
2017-09-24 19:54:13 +02:00
|
|
|
+ UNIT_SPACE + su);
|
|
|
|
|
2021-08-04 08:57:42 +02:00
|
|
|
return tt;
|
2017-09-24 19:54:13 +02:00
|
|
|
}
|