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 <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-06-01 19:27:44 -03:00 committed by Dirk Hohndel
parent 59785345f8
commit 57d3baa410
2 changed files with 6 additions and 18 deletions

View file

@ -9,6 +9,7 @@
#include <QPainter> #include <QPainter>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsView> #include <QGraphicsView>
#include <qgraphicssceneevent.h>
#include <QDebug> #include <QDebug>
#include <stdint.h> #include <stdint.h>
@ -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 setPos(event->scenePos());
ProfileWidget2 *profWidget = NULL; recalculate();
if (scene() && scene()->views().count()) ruler->recalculate();
profWidget = qobject_cast<ProfileWidget2 *>(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);
} }
RulerItem2::RulerItem2() : source(new RulerNodeItem2()), RulerItem2::RulerItem2() : source(new RulerNodeItem2()),

View file

@ -21,8 +21,7 @@ public:
void recalculate(); void recalculate();
protected: protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
private: private:
struct plot_info pInfo; struct plot_info pInfo;
struct plot_data *entry; struct plot_data *entry;