1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Fixed areas tooltip handling

This commit is contained in:
Martin Tůma 2019-11-10 17:59:58 +01:00
parent db7e60bdfb
commit 65e04ce08b
2 changed files with 10 additions and 8 deletions

View File

@ -8,7 +8,7 @@
#include "areaitem.h"
ToolTip AreaItem::toolTip() const
QString AreaItem::info() const
{
ToolTip tt;
@ -18,11 +18,11 @@ ToolTip AreaItem::toolTip() const
tt.insert(qApp->translate("PolygonItem", "Description"),
_area.description());
return tt;
return tt.toString();
}
AreaItem::AreaItem(const Area &area, Map *map, QGraphicsItem *parent)
: QGraphicsItem(parent), _area(area)
AreaItem::AreaItem(const Area &area, Map *map, GraphicsItem *parent)
: GraphicsItem(parent), _area(area)
{
_map = map;
_digitalZoom = 0;
@ -173,6 +173,6 @@ void AreaItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void AreaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Popup::show(event->screenPos(), toolTip().toString(), event->widget());
Popup::show(event->screenPos(), info(), event->widget());
QGraphicsItem::mousePressEvent(event);
}

View File

@ -1,16 +1,16 @@
#ifndef AREAITEM_H
#define AREAITEM_H
#include <QGraphicsItem>
#include "data/area.h"
#include "graphicsscene.h"
#include "tooltip.h"
class Map;
class AreaItem : public QGraphicsItem
class AreaItem : public GraphicsItem
{
public:
AreaItem(const Area &area, Map *map, QGraphicsItem *parent = 0);
AreaItem(const Area &area, Map *map, GraphicsItem *parent = 0);
QPainterPath shape() const {return _painterPath;}
QRectF boundingRect() const {return _painterPath.boundingRect();}
@ -27,6 +27,8 @@ public:
void setStyle(Qt::PenStyle style);
void setDigitalZoom(int zoom);
virtual QString info() const;
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);