mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-07 18:53:02 +02:00
Hover the areas when the legend item is selected
This commit is contained in:
parent
1466de5ddf
commit
73a60f5046
@ -178,6 +178,16 @@ void AreaItem::setDigitalZoom(int zoom)
|
|||||||
_pen.setWidthF(width() * pow(2, -_digitalZoom));
|
_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)
|
void AreaItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
class AreaItem : public PlaneItem
|
class AreaItem : public PlaneItem
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AreaItem(const Area &area, Map *map, GraphicsItem *parent = 0);
|
AreaItem(const Area &area, Map *map, GraphicsItem *parent = 0);
|
||||||
|
|
||||||
@ -31,6 +33,9 @@ public:
|
|||||||
const QColor color() const {return _pen.color();}
|
const QColor color() const {return _pen.color();}
|
||||||
const QString &name() const {return _area.name();}
|
const QString &name() const {return _area.name();}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void hover(bool hvr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
@ -66,6 +66,8 @@ void LegendItem::addItem(PlaneItem *item)
|
|||||||
|
|
||||||
_boundingRect = QRectF(0, 0, qMax(_boundingRect.width(),
|
_boundingRect = QRectF(0, 0, qMax(_boundingRect.width(),
|
||||||
li->boundingRect().width()), _items.size() * li->boundingRect().height());
|
li->boundingRect().width()), _items.size() * li->boundingRect().height());
|
||||||
|
|
||||||
|
QObject::connect(li, &LegendEntryItem::selected, item, &PlaneItem::hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LegendItem::setColor(const QColor &color)
|
void LegendItem::setColor(const QColor &color)
|
||||||
|
@ -205,6 +205,16 @@ void MapItem::setDigitalZoom(int zoom)
|
|||||||
_pen.setWidthF(_width * pow(2, -_digitalZoom));
|
_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)
|
void MapItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
class MapAction;
|
class MapAction;
|
||||||
class Projection;
|
class Projection;
|
||||||
|
|
||||||
class MapItem : public QObject, public PlaneItem
|
class MapItem : public PlaneItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -32,6 +32,9 @@ public:
|
|||||||
const QColor color() const {return _pen.color();}
|
const QColor color() const {return _pen.color();}
|
||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void hover(bool hvr);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void triggered();
|
void triggered();
|
||||||
|
|
||||||
|
@ -6,8 +6,10 @@
|
|||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
class PlaneItem : public GraphicsItem
|
class PlaneItem : public QObject, public GraphicsItem
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlaneItem(GraphicsItem *parent = 0) : GraphicsItem(parent) {}
|
PlaneItem(GraphicsItem *parent = 0) : GraphicsItem(parent) {}
|
||||||
|
|
||||||
@ -23,6 +25,9 @@ public:
|
|||||||
|
|
||||||
virtual const QColor color() const = 0;
|
virtual const QColor color() const = 0;
|
||||||
virtual const QString &name() const = 0;
|
virtual const QString &name() const = 0;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void hover(bool hvr) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLANEITEM_H
|
#endif // PLANEITEM_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user