2016-08-09 01:16:19 +02:00
|
|
|
#include <QPainter>
|
2016-11-02 17:35:26 +01:00
|
|
|
#include "format.h"
|
2016-08-02 00:28:56 +02:00
|
|
|
#include "tooltip.h"
|
2016-07-28 00:23:22 +02:00
|
|
|
#include "trackitem.h"
|
|
|
|
|
|
|
|
|
|
|
|
QString TrackItem::toolTip()
|
|
|
|
{
|
2016-08-02 00:28:56 +02:00
|
|
|
ToolTip tt;
|
2016-07-28 00:23:22 +02:00
|
|
|
|
2016-10-28 14:33:36 +02:00
|
|
|
if (!_name.isEmpty())
|
2017-01-08 20:02:51 +01:00
|
|
|
tt.insert(tr("Name"), _name);
|
2016-10-28 14:33:36 +02:00
|
|
|
if (!_desc.isEmpty())
|
2017-01-08 20:02:51 +01:00
|
|
|
tt.insert(tr("Description"), _desc);
|
|
|
|
tt.insert(tr("Distance"), Format::distance(_distance.last(), _units));
|
2016-08-02 00:28:56 +02:00
|
|
|
if (_time > 0)
|
2017-02-12 19:57:55 +01:00
|
|
|
tt.insert(tr("Total time"), Format::timeSpan(_time));
|
2017-01-31 09:37:01 +01:00
|
|
|
if (_movingTime > 0)
|
2017-02-12 19:57:55 +01:00
|
|
|
tt.insert(tr("Moving time"), Format::timeSpan(_movingTime));
|
2016-08-02 00:28:56 +02:00
|
|
|
if (!_date.isNull())
|
2017-01-08 20:02:51 +01:00
|
|
|
tt.insert(tr("Date"), _date.toString(Qt::SystemLocaleShortDate));
|
2016-08-02 00:28:56 +02:00
|
|
|
|
|
|
|
return tt.toString();
|
2016-07-28 00:23:22 +02:00
|
|
|
}
|
|
|
|
|
2016-08-02 00:28:56 +02:00
|
|
|
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
2016-09-19 00:56:10 +02:00
|
|
|
: PathItem(parent)
|
2016-07-28 00:23:22 +02:00
|
|
|
{
|
2016-10-24 00:21:40 +02:00
|
|
|
QPointF p;
|
2016-11-13 09:49:31 +01:00
|
|
|
const Path &path = track.path();
|
|
|
|
Q_ASSERT(path.count() >= 2);
|
2016-07-28 00:23:22 +02:00
|
|
|
|
2016-11-14 22:12:43 +01:00
|
|
|
p = path.first().coordinates().toMercator();
|
2016-10-24 00:21:40 +02:00
|
|
|
_path.moveTo(QPointF(p.x(), -p.y()));
|
2016-11-14 22:12:43 +01:00
|
|
|
_distance.append(path.first().distance());
|
2016-11-13 09:49:31 +01:00
|
|
|
for (int i = 1; i < path.size(); i++) {
|
2016-11-15 18:08:44 +01:00
|
|
|
if (path.at(i).coordinates() == path.at(i-1).coordinates())
|
|
|
|
continue;
|
2016-11-14 22:12:43 +01:00
|
|
|
p = path.at(i).coordinates().toMercator();
|
2016-10-24 00:21:40 +02:00
|
|
|
_path.lineTo(QPointF(p.x(), -p.y()));
|
2016-11-14 22:12:43 +01:00
|
|
|
_distance.append(path.at(i).distance());
|
2016-07-28 00:23:22 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 21:01:58 +02:00
|
|
|
updateShape();
|
|
|
|
|
2016-11-05 17:33:29 +01:00
|
|
|
_name = track.name();
|
|
|
|
_desc = track.description();
|
2016-07-28 00:23:22 +02:00
|
|
|
_date = track.date();
|
|
|
|
_time = track.time();
|
2017-01-31 09:37:01 +01:00
|
|
|
_movingTime = track.movingTime();
|
2016-07-28 00:23:22 +02:00
|
|
|
|
2016-11-15 18:08:44 +01:00
|
|
|
_marker->setPos(_path.elementAt(0));
|
2016-08-09 01:16:19 +02:00
|
|
|
|
2016-09-26 21:01:58 +02:00
|
|
|
setToolTip(toolTip());
|
2016-07-28 00:23:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrackItem::setUnits(enum Units units)
|
|
|
|
{
|
2016-09-26 21:01:58 +02:00
|
|
|
PathItem::setUnits(units);
|
2016-07-28 00:23:22 +02:00
|
|
|
setToolTip(toolTip());
|
|
|
|
}
|