1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 13:41:16 +01:00
GPXSee/src/GUI/routeitem.cpp

86 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"
2021-01-17 18:39:57 +01:00
#include "data/route.h"
2017-11-26 18:54:03 +01:00
#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"
ToolTip 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);
if (!_comment.isEmpty() && _comment != _desc)
tt.insert(tr("Comment"), _comment);
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;
}
RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
: PathItem(route.path(), route.style(), 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();
_comment = route.comment();
2019-10-14 20:07:05 +02:00
_links = route.links();
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++)
2021-10-10 08:38:38 +02:00
_waypoints.at(i)->setMap(map);
PathItem::setMap(map);
2016-08-09 01:16:19 +02:00
}
2016-08-09 10:47:49 +02:00
void RouteItem::showWaypoints(bool show)
{
for (int i = 0; i < _waypoints.count(); i++)
2021-10-10 08:38:38 +02:00
_waypoints.at(i)->setVisible(show);
2016-08-09 10:47:49 +02:00
}
void RouteItem::showWaypointLabels(bool show)
{
for (int i = 0; i < _waypoints.count(); i++)
2021-10-10 08:38:38 +02:00
_waypoints.at(i)->showLabel(show);
}
void RouteItem::showWaypointIcons(bool show)
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints.at(i)->showIcon(show);
}
void RouteItem::setDigitalZoom(int zoom)
{
for (int i = 0; i < _waypoints.count(); i++)
2021-10-10 08:38:38 +02:00
_waypoints.at(i)->setDigitalZoom(zoom);
PathItem::setDigitalZoom(zoom);
}