summaryrefslogtreecommitdiffstats
path: root/qt-ui/profilegraphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/profilegraphics.cpp')
-rw-r--r--qt-ui/profilegraphics.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 9c73e1fdc..1c6f76209 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -258,6 +258,7 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
scene()->setSceneRect(0,0, viewport()->width()-50, viewport()->height()-50);
toolTip = new ToolTipItem();
+ installEventFilter(toolTip);
scene()->addItem(toolTip);
// Fix this for printing / screen later.
@@ -1355,12 +1356,9 @@ ToolTipItem::ToolTipItem(QGraphicsItem* parent): QGraphicsPathItem(parent), back
{
title = new QGraphicsSimpleTextItem(tr("Information"), this);
separator = new QGraphicsLineItem(this);
-
+ dragging = false;
setFlag(ItemIgnoresTransformations);
- setFlag(ItemIsMovable);
-
status = COLLAPSED;
-
updateTitlePosition();
setZValue(99);
}
@@ -1407,6 +1405,12 @@ bool ToolTipItem::isExpanded() {
void ToolTipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
persistPos();
+ dragging = false;
+}
+
+void ToolTipItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
+{
+ dragging = true;
}
void ToolTipItem::persistPos()
@@ -1417,7 +1421,6 @@ void ToolTipItem::persistPos()
s.setValue("tooltip_position", currentPos);
s.endGroup();
s.sync();
- qDebug() << "Salvou" << currentPos;
}
void ToolTipItem::readPos()
@@ -1430,6 +1433,15 @@ void ToolTipItem::readPos()
setPos(value);
}
+bool ToolTipItem::eventFilter(QObject* view, QEvent* event)
+{
+ if (event->type() == QEvent::HoverMove && dragging){
+ QHoverEvent *e = static_cast<QHoverEvent*>(event);
+ QGraphicsView *v = scene()->views().at(0);
+ setPos( v->mapToScene(e->pos()));
+ }
+ return false;
+}
EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent)
{