2014-02-05 16:25:28 +00:00
|
|
|
#ifndef DIVETOOLTIPITEM_H
|
|
|
|
#define DIVETOOLTIPITEM_H
|
|
|
|
|
2015-01-16 18:01:54 +00:00
|
|
|
#include <QGraphicsRectItem>
|
2014-02-05 16:25:28 +00:00
|
|
|
#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.
|
|
|
|
*/
|
2015-01-16 18:01:54 +00:00
|
|
|
class ToolTipItem : public QObject, public QGraphicsRectItem {
|
2014-02-05 16:25:28 +00:00
|
|
|
Q_OBJECT
|
|
|
|
void updateTitlePosition();
|
2015-01-16 18:01:54 +00:00
|
|
|
Q_PROPERTY(QRectF rect READ rect WRITE setRect)
|
2014-02-05 16:25:28 +00:00
|
|
|
|
|
|
|
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;
|
2015-01-14 19:11:41 +00:00
|
|
|
ToolTip entryToolTip;
|
2014-02-05 16:25:28 +00:00
|
|
|
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
|