2014-02-05 16:25:28 +00:00
|
|
|
#ifndef DIVETOOLTIPITEM_H
|
|
|
|
#define DIVETOOLTIPITEM_H
|
|
|
|
|
|
|
|
#include <QGraphicsPathItem>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QPair>
|
|
|
|
#include <QRectF>
|
|
|
|
#include <QIcon>
|
2014-02-05 16:53:57 +00:00
|
|
|
#include "display.h"
|
2014-02-05 16:25:28 +00:00
|
|
|
|
2014-02-05 16:53:57 +00:00
|
|
|
class DiveCartesianAxis;
|
2014-02-05 16:25:28 +00:00
|
|
|
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.
|
|
|
|
*/
|
2014-02-28 04:09:57 +00:00
|
|
|
class ToolTipItem : public QObject, public QGraphicsPathItem {
|
2014-02-05 16:25:28 +00:00
|
|
|
Q_OBJECT
|
|
|
|
void updateTitlePosition();
|
|
|
|
Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect)
|
|
|
|
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
enum Status {
|
|
|
|
COLLAPSED,
|
|
|
|
EXPANDED
|
|
|
|
};
|
2014-10-15 13:30:47 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit ToolTipItem(QGraphicsItem *parent = 0);
|
2014-02-05 16:25:28 +00:00
|
|
|
virtual ~ToolTipItem();
|
|
|
|
|
|
|
|
void collapse();
|
|
|
|
void expand();
|
|
|
|
void clear();
|
2015-01-14 15:02:18 +00:00
|
|
|
void addToolTip(const QString &toolTip, const QIcon &icon = QIcon(), const QPixmap &pixmap = QPixmap());
|
2014-02-28 04:09:57 +00:00
|
|
|
void refresh(const QPointF &pos);
|
2014-02-05 16:53:57 +00:00
|
|
|
bool isExpanded() const;
|
2014-02-05 16:25:28 +00:00
|
|
|
void persistPos();
|
|
|
|
void readPos();
|
2014-05-24 00:06:30 +00:00
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
2014-02-28 04:09:57 +00:00
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2014-02-05 16:53:57 +00:00
|
|
|
void setTimeAxis(DiveCartesianAxis *axis);
|
2014-02-28 04:09:57 +00:00
|
|
|
void setPlotInfo(const plot_info &plot);
|
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void setRect(const QRectF &rect);
|
2014-02-05 16:25:28 +00:00
|
|
|
|
|
|
|
private:
|
2014-02-28 04:09:57 +00:00
|
|
|
typedef QPair<QGraphicsPixmapItem *, QGraphicsSimpleTextItem *> ToolTip;
|
2014-02-05 16:25:28 +00:00
|
|
|
QVector<ToolTip> toolTips;
|
|
|
|
QGraphicsPathItem *background;
|
|
|
|
QGraphicsLineItem *separator;
|
|
|
|
QGraphicsSimpleTextItem *title;
|
|
|
|
Status status;
|
|
|
|
QRectF rectangle;
|
|
|
|
QRectF nextRectangle;
|
2014-02-05 16:53:57 +00:00
|
|
|
DiveCartesianAxis *timeAxis;
|
|
|
|
plot_info pInfo;
|
2014-02-20 00:06:16 +00:00
|
|
|
int lastTime;
|
2014-05-24 00:06:30 +00:00
|
|
|
|
|
|
|
QList<QGraphicsItem*> oldSelection;
|
2014-02-05 16:25:28 +00:00
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DIVETOOLTIPITEM_H
|