1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00
GPXSee/src/GUI/trackitem.cpp

55 lines
1.4 KiB
C++
Raw Normal View History

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"
#include "trackitem.h"
ToolTip TrackItem::info() const
{
2016-08-02 00:28:56 +02:00
ToolTip tt;
QLocale l;
if (!_name.isEmpty())
2017-01-08 20:02:51 +01:00
tt.insert(tr("Name"), _name);
if (!_desc.isEmpty())
2017-01-08 20:02:51 +01:00
tt.insert(tr("Description"), _desc);
if (!_comment.isEmpty() && _comment != _desc)
tt.insert(tr("Comment"), _comment);
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
_units));
2016-08-02 00:28:56 +02:00
if (_time > 0)
tt.insert(tr("Total time"), Format::timeSpan(_time));
if (_movingTime > 0)
tt.insert(tr("Moving time"), Format::timeSpan(_movingTime));
2016-08-02 00:28:56 +02:00
if (!_date.isNull())
tt.insert(tr("Date"), l.toString(_date.toTimeZone(_timeZone),
QLocale::ShortFormat));
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
return tt;
}
TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *parent)
2022-09-25 02:15:24 +02:00
: PathItem(track.path(), map, parent)
{
2016-11-05 17:33:29 +01:00
_name = track.name();
_desc = track.description();
_comment = track.comment();
2019-10-14 20:07:05 +02:00
_links = track.links();
_date = track.date();
_time = track.time();
_movingTime = track.movingTime();
}