diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-10 14:48:31 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-06-10 14:48:31 -0300 |
commit | ad5c18655365d5f8adad9397d7dc0e52d2522fdd (patch) | |
tree | 71e186526a16c1cf507084c05981b990493c4816 /qt-ui/profilegraphics.cpp | |
parent | 34c6eec9bac57846da042aac546578bdb5dcb1af (diff) | |
download | subsurface-ad5c18655365d5f8adad9397d7dc0e52d2522fdd.tar.gz |
Implemented the movement of the ToolTip by Hand.
Reimplement the movement of the tooltip by hand,
we were adding / removing childs of the tooltip
quite often, wich broke the movement of the item
using the default behavior, aparently Qt uses
a cache of the transformation of the item, assuming
that the bounding box of it will not get modified
while dragging. wich in our particular case, is
a falacy.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/profilegraphics.cpp')
-rw-r--r-- | qt-ui/profilegraphics.cpp | 22 |
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) { |