diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-11-02 19:54:34 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-11-02 19:54:34 -0800 |
commit | 8ea7f404574c2ee571d2dde6bb6be3791e962150 (patch) | |
tree | 6a050178bfc71bf10558968f2a3bc0a12d8c525f /profile-widget/divetooltipitem.h | |
parent | b273c1b0ca7bfe933e7c83742f1610f6bbe3f4d3 (diff) | |
parent | df7818a9b8495285b4d9812e5d6d50d6f9c08813 (diff) | |
download | subsurface-8ea7f404574c2ee571d2dde6bb6be3791e962150.tar.gz |
Merge branch 'cmakeAndPreferences'
Diffstat (limited to 'profile-widget/divetooltipitem.h')
-rw-r--r-- | profile-widget/divetooltipitem.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/profile-widget/divetooltipitem.h b/profile-widget/divetooltipitem.h new file mode 100644 index 000000000..4fa7ec2d7 --- /dev/null +++ b/profile-widget/divetooltipitem.h @@ -0,0 +1,67 @@ +#ifndef DIVETOOLTIPITEM_H +#define DIVETOOLTIPITEM_H + +#include <QGraphicsRectItem> +#include <QVector> +#include <QPair> +#include <QRectF> +#include <QIcon> +#include <QTime> +#include "display.h" + +class DiveCartesianAxis; +class QGraphicsLineItem; +class QGraphicsSimpleTextItem; +class QGraphicsPixmapItem; +struct graphics_context; + +/* To use a tooltip, simply ->setToolTip on the QGraphicsItem that you want + * or, if it's a "global" tooltip, set it on the mouseMoveEvent of the ProfileGraphicsView. + */ +class ToolTipItem : public QObject, public QGraphicsRectItem { + Q_OBJECT + void updateTitlePosition(); + Q_PROPERTY(QRectF rect READ rect WRITE setRect) + +public: + enum Status { + COLLAPSED, + EXPANDED + }; + + explicit ToolTipItem(QGraphicsItem *parent = 0); + virtual ~ToolTipItem(); + + void collapse(); + void expand(); + void clear(); + void addToolTip(const QString &toolTip, const QIcon &icon = QIcon(), const QPixmap &pixmap = QPixmap()); + void refresh(const QPointF &pos); + bool isExpanded() const; + void persistPos(); + void readPos(); + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + void setTimeAxis(DiveCartesianAxis *axis); + void setPlotInfo(const plot_info &plot); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); +public +slots: + void setRect(const QRectF &rect); + +private: + typedef QPair<QGraphicsPixmapItem *, QGraphicsSimpleTextItem *> ToolTip; + QVector<ToolTip> toolTips; + ToolTip entryToolTip; + QGraphicsSimpleTextItem *title; + Status status; + QRectF rectangle; + QRectF nextRectangle; + DiveCartesianAxis *timeAxis; + plot_info pInfo; + int lastTime; + QTime refreshTime; + QList<QGraphicsItem*> oldSelection; +}; + +#endif // DIVETOOLTIPITEM_H |