1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +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" #include "areaitem.h"
ToolTip AreaItem::toolTip() const QString AreaItem::info() const
{ {
ToolTip tt; ToolTip tt;
@ -18,11 +18,11 @@ ToolTip AreaItem::toolTip() const
tt.insert(qApp->translate("PolygonItem", "Description"), tt.insert(qApp->translate("PolygonItem", "Description"),
_area.description()); _area.description());
return tt; return tt.toString();
} }
AreaItem::AreaItem(const Area &area, Map *map, QGraphicsItem *parent) AreaItem::AreaItem(const Area &area, Map *map, GraphicsItem *parent)
: QGraphicsItem(parent), _area(area) : GraphicsItem(parent), _area(area)
{ {
_map = map; _map = map;
_digitalZoom = 0; _digitalZoom = 0;
@ -173,6 +173,6 @@ void AreaItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void AreaItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void AreaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
Popup::show(event->screenPos(), toolTip().toString(), event->widget()); Popup::show(event->screenPos(), info(), event->widget());
QGraphicsItem::mousePressEvent(event); QGraphicsItem::mousePressEvent(event);
} }

View File

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