From 57d3baa410743154fefa1e40d991e24bc594f17a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 1 Jun 2014 19:27:44 -0300 Subject: Simplify ruler update code. This should fix the infinite recursion on OSX and also clean a lot of code, which is also very nice. <3 Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/ruleritem.cpp | 21 +++++---------------- qt-ui/profile/ruleritem.h | 3 +-- 2 files changed, 6 insertions(+), 18 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index 295d81213..0bf97f947 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -58,23 +59,11 @@ void RulerNodeItem2::recalculate() } } -QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &value) +void RulerNodeItem2::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - // only run this if we actually have a ruler and are not adding or planning a dive - ProfileWidget2 *profWidget = NULL; - if (scene() && scene()->views().count()) - profWidget = qobject_cast(scene()->views().first()); - if (ruler && - profWidget && - !profWidget->isAddOrPlanner() && - change == ItemPositionHasChanged) { - recalculate(); - ruler->recalculate(); - } else { - if (profWidget && profWidget->isAddOrPlanner()) - qDebug() << "don't recalc ruler on Add/Plan"; - } - return QGraphicsEllipseItem::itemChange(change, value); + setPos(event->scenePos()); + recalculate(); + ruler->recalculate(); } RulerItem2::RulerItem2() : source(new RulerNodeItem2()), diff --git a/qt-ui/profile/ruleritem.h b/qt-ui/profile/ruleritem.h index 3eda33225..5d144f286 100644 --- a/qt-ui/profile/ruleritem.h +++ b/qt-ui/profile/ruleritem.h @@ -21,8 +21,7 @@ public: void recalculate(); protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); private: struct plot_info pInfo; struct plot_data *entry; -- cgit v1.2.3-70-g09d2