diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-07 16:09:51 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-07 16:14:15 -0700 |
commit | d590cb951988976f21bacc39d5ea1581c65d3b20 (patch) | |
tree | 55c759415b303b1c961b049c00fe50a7c2ded687 /qt-ui/profilegraphics.h | |
parent | c928b9cb94b7e43983aaee46c82074466a6179a6 (diff) | |
download | subsurface-d590cb951988976f21bacc39d5ea1581c65d3b20.tar.gz |
Adds real support for ToolTips.
This patch changes the Event drawing so it can display tooltips. It is now
the responsibility of the item to show / hide a tooltip.
A bit of code-refactoring got on here too because I was using only
QGraphicsItem calls and I wanted to use a hover in / hover out event
to show / hide the tooltip.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profilegraphics.h')
-rw-r--r-- | qt-ui/profilegraphics.h | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index 9ad04674b..776b3141e 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -10,26 +10,16 @@ struct graphics_context; struct plot_info; typedef struct text_render_options text_render_options_t; - -class ToolTipItem; -class ToolTipStatusHandler; - -class ToolTipStatusHandler :public QObject, public QGraphicsEllipseItem { -public: - explicit ToolTipStatusHandler(QObject* parent = 0); -protected: - void mousePressEvent(QGraphicsSceneMouseEvent* event); -}; - class ToolTipItem :public QObject, public QGraphicsPathItem { Q_OBJECT + void updateTitlePosition(); Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect) public: - enum Status {COLLAPSED, EXPANDED}; - enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32}; + enum Status{COLLAPSED, EXPANDED}; + enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32, SPACING=4}; - explicit ToolTipItem(QGraphicsItem* parent = 0); + explicit ToolTipItem(QGraphicsItem* parent = 0); void collapse(); void expand(); @@ -42,12 +32,30 @@ public Q_SLOTS: private: typedef QPair<QGraphicsPixmapItem*, QGraphicsSimpleTextItem*> ToolTip; - enum Status status; QMap<QString, ToolTip > toolTips; QGraphicsRectItem *background; + QGraphicsLineItem *separator; + QGraphicsSimpleTextItem *title; + QRectF rectangle; }; +class EventItem : public QGraphicsPolygonItem{ +public: + explicit EventItem(QGraphicsItem* parent = 0); + void addToolTip(const QString& text,const QIcon& icon = QIcon()); + void setToolTipController(ToolTipItem *controller); + +protected: + void hoverEnterEvent(QGraphicsSceneHoverEvent* event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); + +private: + ToolTipItem *controller; + QString text; + QIcon icon; +}; + class ProfileGraphicsView : public QGraphicsView { Q_OBJECT public: @@ -70,5 +78,4 @@ private: ToolTipItem *toolTip; }; - #endif |