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
|
|
|
|
|
|
|
|
#include <QVector>
|
|
|
|
#include <QPair>
|
|
|
|
#include <QRectF>
|
|
|
|
#include <QIcon>
|
2020-01-01 18:56:34 -08:00
|
|
|
#include <QElapsedTimer>
|
2021-07-20 08:17:08 +02:00
|
|
|
#include <QPainter>
|
2021-01-03 12:46:56 +01:00
|
|
|
#include "backend-shared/roundrectitem.h"
|
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.
|
|
|
|
*/
|
2021-01-03 12:46:56 +01:00
|
|
|
class ToolTipItem : public QObject, public RoundRectItem {
|
2014-02-05 14:25:28 -02:00
|
|
|
Q_OBJECT
|
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);
|
2018-07-31 07:41:19 +02:00
|
|
|
~ToolTipItem();
|
2014-02-05 14:25:28 -02:00
|
|
|
|
2021-02-12 18:19:24 +01:00
|
|
|
void refresh(const dive *d, const QPointF &pos, bool inPlanner);
|
2014-02-05 14:25:28 -02:00
|
|
|
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);
|
2019-11-15 20:50:44 +01:00
|
|
|
void clearPlotInfo();
|
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;
|
2021-07-20 08:17:08 +02:00
|
|
|
QPixmap tissues;
|
|
|
|
QPainter painter;
|
2014-02-05 14:25:28 -02:00
|
|
|
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;
|
2020-01-01 18:56:34 -08:00
|
|
|
QElapsedTimer refreshTime;
|
2014-05-23 21:06:30 -03:00
|
|
|
QList<QGraphicsItem*> oldSelection;
|
2021-02-12 18:28:35 +01:00
|
|
|
|
2021-02-12 18:32:40 +01:00
|
|
|
void addToolTip(const QString &toolTip, const QPixmap &pixmap);
|
2021-04-25 17:53:39 +02:00
|
|
|
void collapse();
|
|
|
|
void expand();
|
|
|
|
void clear();
|
|
|
|
bool isExpanded() const;
|
|
|
|
void persistPos() const;
|
|
|
|
void updateTitlePosition();
|
2014-02-05 14:25:28 -02:00
|
|
|
};
|
|
|
|
|
2014-02-11 19:14:46 +01:00
|
|
|
#endif // DIVETOOLTIPITEM_H
|