1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-05 17:53:02 +02:00

Hover the areas when the legend item is selected

This commit is contained in:
Martin Tůma 2025-06-01 11:31:38 +02:00
parent 1466de5ddf
commit 73a60f5046
6 changed files with 37 additions and 2 deletions

View File

@ -178,6 +178,16 @@ void AreaItem::setDigitalZoom(int zoom)
_pen.setWidthF(width() * pow(2, -_digitalZoom));
}
void AreaItem::hover(bool hvr)
{
if (hvr)
_pen.setWidthF((_width + 1) * pow(2, -_digitalZoom));
else
_pen.setWidthF(_width * pow(2, -_digitalZoom));
update();
}
void AreaItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);

View File

@ -6,6 +6,8 @@
class AreaItem : public PlaneItem
{
Q_OBJECT
public:
AreaItem(const Area &area, Map *map, GraphicsItem *parent = 0);
@ -31,6 +33,9 @@ public:
const QColor color() const {return _pen.color();}
const QString &name() const {return _area.name();}
public slots:
void hover(bool hvr);
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);

View File

@ -66,6 +66,8 @@ void LegendItem::addItem(PlaneItem *item)
_boundingRect = QRectF(0, 0, qMax(_boundingRect.width(),
li->boundingRect().width()), _items.size() * li->boundingRect().height());
QObject::connect(li, &LegendEntryItem::selected, item, &PlaneItem::hover);
}
void LegendItem::setColor(const QColor &color)

View File

@ -205,6 +205,16 @@ void MapItem::setDigitalZoom(int zoom)
_pen.setWidthF(_width * pow(2, -_digitalZoom));
}
void MapItem::hover(bool hvr)
{
if (hvr)
_pen.setWidthF((_width + 1) * pow(2, -_digitalZoom));
else
_pen.setWidthF(_width * pow(2, -_digitalZoom));
update();
}
void MapItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);

View File

@ -6,7 +6,7 @@
class MapAction;
class Projection;
class MapItem : public QObject, public PlaneItem
class MapItem : public PlaneItem
{
Q_OBJECT
@ -32,6 +32,9 @@ public:
const QColor color() const {return _pen.color();}
const QString &name() const {return _name;}
public slots:
void hover(bool hvr);
signals:
void triggered();

View File

@ -6,8 +6,10 @@
class Map;
class PlaneItem : public GraphicsItem
class PlaneItem : public QObject, public GraphicsItem
{
Q_OBJECT
public:
PlaneItem(GraphicsItem *parent = 0) : GraphicsItem(parent) {}
@ -23,6 +25,9 @@ public:
virtual const QColor color() const = 0;
virtual const QString &name() const = 0;
public slots:
virtual void hover(bool hvr) = 0;
};
#endif // PLANEITEM_H