2016-08-09 01:16:19 +02:00
|
|
|
#include <QPainter>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "map/map.h"
|
2021-01-17 18:39:57 +01:00
|
|
|
#include "data/track.h"
|
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"
|
|
|
|
|
|
|
|
|
2021-08-04 08:57:42 +02:00
|
|
|
ToolTip TrackItem::info() const
|
2016-07-28 00:23:22 +02:00
|
|
|
{
|
2016-08-02 00:28:56 +02:00
|
|
|
ToolTip tt;
|
2020-12-22 22:09:09 +01:00
|
|
|
QLocale l;
|
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);
|
2020-03-09 20:04:13 +01:00
|
|
|
if (!_comment.isEmpty() && _comment != _desc)
|
|
|
|
tt.insert(tr("Comment"), _comment);
|
2019-05-24 18:37:15 +02:00
|
|
|
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
|
2019-10-15 23:59:15 +02:00
|
|
|
_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())
|
2020-12-22 22:09:09 +01:00
|
|
|
tt.insert(tr("Date"), l.toString(_date.toTimeZone(_timeZone)));
|
2019-10-22 22:27:12 +02:00
|
|
|
if (!_links.isEmpty()) {
|
|
|
|
QString links;
|
|
|
|
for (int i = 0; i < _links.size(); i++) {
|
|
|
|
const Link &link = _links.at(i);
|
|
|
|
links.append(QString("<a href=\"%0\">%1</a>").arg(link.URL(),
|
|
|
|
link.text().isEmpty() ? link.URL() : link.text()));
|
|
|
|
if (i != _links.size() - 1)
|
|
|
|
links.append("<br/>");
|
|
|
|
}
|
|
|
|
tt.insert(tr("Links"), links);
|
2019-10-14 20:07:05 +02:00
|
|
|
}
|
2016-08-02 00:28:56 +02:00
|
|
|
|
2021-08-04 08:57:42 +02:00
|
|
|
return tt;
|
2016-07-28 00:23:22 +02:00
|
|
|
}
|
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *parent)
|
2022-09-25 02:15:24 +02:00
|
|
|
: PathItem(track.path(), map, parent)
|
2016-07-28 00:23:22 +02:00
|
|
|
{
|
2016-11-05 17:33:29 +01:00
|
|
|
_name = track.name();
|
|
|
|
_desc = track.description();
|
2020-03-09 20:04:13 +01:00
|
|
|
_comment = track.comment();
|
2019-10-14 20:07:05 +02:00
|
|
|
_links = track.links();
|
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
|
|
|
}
|