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

91 lines
2.0 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 "data/waypoint.h"
#include "map/map.h"
2016-11-02 17:35:26 +01:00
#include "format.h"
2016-08-09 01:16:19 +02:00
#include "waypointitem.h"
#include "tooltip.h"
2016-08-09 01:16:19 +02:00
#include "routeitem.h"
QString RouteItem::info() const
{
ToolTip tt;
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);
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
_units));
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
}
return tt.toString();
}
RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
: PathItem(route.path(), map, parent)
2016-08-09 01:16:19 +02:00
{
const RouteData &waypoints = route.data();
2016-08-09 01:16:19 +02:00
_waypoints.resize(waypoints.size());
for (int i = 0; i < waypoints.size(); i++)
_waypoints[i] = new WaypointItem(waypoints.at(i), map, this);
_name = route.name();
_desc = route.description();
2019-10-14 20:07:05 +02:00
_links = route.links();
_coordinatesFormat = DecimalDegrees;
2016-08-09 01:16:19 +02:00
}
void RouteItem::setMap(Map *map)
2016-08-09 01:16:19 +02:00
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setMap(map);
PathItem::setMap(map);
2016-08-09 01:16:19 +02:00
}
void RouteItem::setUnits(Units u)
{
if (_units == u)
return;
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setToolTipFormat(u, _coordinatesFormat);
PathItem::setUnits(u);
}
void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
{
if (_coordinatesFormat == format)
return;
_coordinatesFormat = format;
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setToolTipFormat(_units, _coordinatesFormat);
}
2016-08-09 10:47:49 +02:00
void RouteItem::showWaypoints(bool show)
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setVisible(show);
2016-08-09 10:47:49 +02:00
}
void RouteItem::showWaypointLabels(bool show)
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->showLabel(show);
}