From 65e04ce08b117f1a1baa7442a40aebe69ec72d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 10 Nov 2019 17:59:58 +0100 Subject: [PATCH] Fixed areas tooltip handling --- src/GUI/areaitem.cpp | 10 +++++----- src/GUI/areaitem.h | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/GUI/areaitem.cpp b/src/GUI/areaitem.cpp index 17a29b14..f2427f0e 100644 --- a/src/GUI/areaitem.cpp +++ b/src/GUI/areaitem.cpp @@ -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); } diff --git a/src/GUI/areaitem.h b/src/GUI/areaitem.h index e0bedf5f..8ed5f33a 100644 --- a/src/GUI/areaitem.h +++ b/src/GUI/areaitem.h @@ -1,16 +1,16 @@ #ifndef AREAITEM_H #define AREAITEM_H -#include #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);