2017-04-27 20:26:36 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-02-05 14:25:28 -02:00
|
|
|
#ifndef DIVETOOLTIPITEM_H
|
|
|
|
#define DIVETOOLTIPITEM_H
|
|
|
|
|
2015-01-16 16:01:54 -02:00
|
|
|
#include <QGraphicsRectItem>
|
2014-02-05 14:25:28 -02:00
|
|
|
#include <QVector>
|
|
|
|
#include <QPair>
|
|
|
|
#include <QRectF>
|
|
|
|
#include <QIcon>
|
2015-01-16 16:45:13 -02:00
|
|
|
#include <QTime>
|
2016-04-04 22:02:03 -07:00
|
|
|
#include "core/display.h"
|
2014-02-05 14:25:28 -02:00
|
|
|
|
2014-02-05 14:53:57 -02:00
|
|
|
class DiveCartesianAxis;
|
2014-02-05 14:25:28 -02:00
|
|
|
class QGraphicsLineItem;
|
|
|
|
class QGraphicsSimpleTextItem;
|
|
|
|
class QGraphicsPixmapItem;
|
|
|
|
|
|
|
|
/* 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 16:01:54 -02:00
|
|
|
class ToolTipItem : public QObject, public QGraphicsRectItem {
|
2014-02-05 14:25:28 -02:00
|
|
|
Q_OBJECT
|
|
|
|
void updateTitlePosition();
|
2015-01-16 16:01:54 -02:00
|
|
|
Q_PROPERTY(QRectF rect READ rect WRITE setRect)
|
2014-02-05 14:25:28 -02:00
|
|
|
|
|
|
|
public:
|
2014-02-27 20:09:57 -08:00
|
|
|
enum Status {
|
|
|
|
COLLAPSED,
|
|
|
|
EXPANDED
|
|
|
|
};
|
2014-10-15 15:30:47 +02:00
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
explicit ToolTipItem(QGraphicsItem *parent = 0);
|
2014-02-05 14:25:28 -02:00
|
|
|
virtual ~ToolTipItem();
|
|
|
|
|
|
|
|
void collapse();
|
|
|
|
void expand();
|
|
|
|
void clear();
|
2015-01-14 13:02:18 -02:00
|
|
|
void addToolTip(const QString &toolTip, const QIcon &icon = QIcon(), const QPixmap &pixmap = QPixmap());
|
2014-02-27 20:09:57 -08:00
|
|
|
void refresh(const QPointF &pos);
|
2014-02-05 14:53:57 -02:00
|
|
|
bool isExpanded() const;
|
2014-02-05 14:25:28 -02:00
|
|
|
void persistPos();
|
|
|
|
void readPos();
|
2014-05-23 21:06:30 -03:00
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
2014-02-27 20:09:57 -08:00
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2014-02-05 14:53:57 -02:00
|
|
|
void setTimeAxis(DiveCartesianAxis *axis);
|
2014-02-27 20:09:57 -08:00
|
|
|
void setPlotInfo(const plot_info &plot);
|
2015-01-16 16:17:26 -02:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
2014-02-27 20:09:57 -08:00
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void setRect(const QRectF &rect);
|
2014-02-05 14:25:28 -02:00
|
|
|
|
|
|
|
private:
|
2014-02-27 20:09:57 -08:00
|
|
|
typedef QPair<QGraphicsPixmapItem *, QGraphicsSimpleTextItem *> ToolTip;
|
2014-02-05 14:25:28 -02:00
|
|
|
QVector<ToolTip> toolTips;
|
2015-01-14 17:11:41 -02:00
|
|
|
ToolTip entryToolTip;
|
2014-02-05 14:25:28 -02:00
|
|
|
QGraphicsSimpleTextItem *title;
|
|
|
|
Status status;
|
|
|
|
QRectF rectangle;
|
|
|
|
QRectF nextRectangle;
|
2014-02-05 14:53:57 -02:00
|
|
|
DiveCartesianAxis *timeAxis;
|
|
|
|
plot_info pInfo;
|
2014-02-19 16:06:16 -08:00
|
|
|
int lastTime;
|
2015-01-16 16:45:13 -02:00
|
|
|
QTime refreshTime;
|
2014-05-23 21:06:30 -03:00
|
|
|
QList<QGraphicsItem*> oldSelection;
|
2014-02-05 14:25:28 -02:00
|
|
|
};
|
|
|
|
|
2014-02-11 19:14:46 +01:00
|
|
|
#endif // DIVETOOLTIPITEM_H
|