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