diff --git a/src/GUI/areaitem.h b/src/GUI/areaitem.h index 62f92c91..14bee989 100644 --- a/src/GUI/areaitem.h +++ b/src/GUI/areaitem.h @@ -28,6 +28,9 @@ public: ToolTip info(bool extended) const; + const QColor color() const {return _pen.color();} + const QString &name() const {return _area.name();} + protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); diff --git a/src/GUI/mapitem.h b/src/GUI/mapitem.h index b76e157d..a61b647b 100644 --- a/src/GUI/mapitem.h +++ b/src/GUI/mapitem.h @@ -29,6 +29,9 @@ public: ToolTip info(bool extended) const; + const QColor color() const {return _pen.color();} + const QString &name() const {return _name;} + signals: void triggered(); diff --git a/src/GUI/mapview.cpp b/src/GUI/mapview.cpp index 31f6e9a7..32094abe 100644 --- a/src/GUI/mapview.cpp +++ b/src/GUI/mapview.cpp @@ -159,6 +159,10 @@ void MapView::updateLegend() for (int i = 0; i < _routes.size(); i++) addLegendEntry(_routes.at(i)); } + if (_showAreas) { + for (int i = 0; i < _areas.size(); i++) + addLegendEntry(_areas.at(i)); + } } void MapView::addLegendEntry(const PathItem *ti) @@ -167,6 +171,12 @@ void MapView::addLegendEntry(const PathItem *ti) ? QFileInfo(ti->file()).fileName() : ti->name()); } +void MapView::addLegendEntry(const PlaneItem *plane) +{ + if (!plane->name().isEmpty()) + _legend->addItem(plane->color(), plane->name()); +} + PathItem *MapView::addTrack(const Track &track) { if (!track.isValid()) { @@ -254,8 +264,10 @@ void MapView::addArea(const Area &area) _ar |= ai->bounds(); _areas.append(ai); - if (_showAreas) + if (_showAreas) { addPOI(_poi->points(ai->bounds())); + addLegendEntry(ai); + } } void MapView::addWaypoints(const QVector &waypoints) @@ -295,8 +307,10 @@ MapItem *MapView::addMap(MapAction *map) _ar |= mi->bounds(); _areas.append(mi); - if (_showAreas) + if (_showAreas) { addPOI(_poi->points(mi->bounds())); + addLegendEntry(mi); + } return mi; } @@ -1330,6 +1344,8 @@ void MapView::useStyles(bool use) _areas.at(i)->updateStyle(); for (int i = 0; i < _waypoints.size(); i++) _waypoints.at(i)->updateStyle(); + + updateLegend(); } void MapView::setMarkerColor(const QColor &color) diff --git a/src/GUI/mapview.h b/src/GUI/mapview.h index 357f706f..36a35905 100644 --- a/src/GUI/mapview.h +++ b/src/GUI/mapview.h @@ -169,6 +169,7 @@ private: void skipColor() {_palette.nextColor();} void setHidpi(bool hidpi); void addLegendEntry(const PathItem *path); + void addLegendEntry(const PlaneItem *plane); void updateLegend(); void mouseMoveEvent(QMouseEvent *event); diff --git a/src/GUI/planeitem.h b/src/GUI/planeitem.h index 40b196c0..e24cda8a 100644 --- a/src/GUI/planeitem.h +++ b/src/GUI/planeitem.h @@ -20,6 +20,9 @@ public: virtual void setPenStyle(Qt::PenStyle style) = 0; virtual void setDigitalZoom(int zoom) = 0; virtual void updateStyle() {} + + virtual const QColor color() const = 0; + virtual const QString &name() const = 0; }; #endif // PLANEITEM_H