diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-05-07 15:44:54 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-07 16:14:11 -0700 |
commit | c928b9cb94b7e43983aaee46c82074466a6179a6 (patch) | |
tree | 602039d54a4560c501e8014c74fc3e3273dbdc1b /qt-ui/profilegraphics.h | |
parent | 5e4f06e6ad2da553ac7b47bf6837d8053b888f6f (diff) | |
download | subsurface-c928b9cb94b7e43983aaee46c82074466a6179a6.tar.gz |
Added the first overlay of the tooltips, with some test data.
The tooltips now can:
1 - be moved around the canvas
2 - dynamically expand / retreat when a new tooltip is added.
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 | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index 928c8ea89..9ad04674b 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -2,17 +2,59 @@ #define PROFILEGRAPHICS_H #include <QGraphicsView> +#include <QGraphicsItem> +#include <QIcon> struct text_render_options; 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 + Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect) + +public: + enum Status {COLLAPSED, EXPANDED}; + enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32}; + + explicit ToolTipItem(QGraphicsItem* parent = 0); + + void collapse(); + void expand(); + void clear(); + void addToolTip(const QString& toolTip, const QIcon& icon = QIcon()); + void removeToolTip(const QString& toolTip); + +public Q_SLOTS: + void setRect(const QRectF& rect); + +private: + typedef QPair<QGraphicsPixmapItem*, QGraphicsSimpleTextItem*> ToolTip; + enum Status status; + QMap<QString, ToolTip > toolTips; + QGraphicsRectItem *background; + QRectF rectangle; +}; + class ProfileGraphicsView : public QGraphicsView { Q_OBJECT public: ProfileGraphicsView(QWidget* parent = 0); void plot(struct dive *d); + void addToolTip(const QString& text, const QIcon& icon = QIcon()); + void removeToolTip(const QString& text); protected: void resizeEvent(QResizeEvent *event); @@ -25,6 +67,8 @@ private: QPen defaultPen; QBrush defaultBrush; + ToolTipItem *toolTip; }; + #endif |