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 <QGraphicsScene>
#include <QGraphicsView>
#include <qgraphicssceneevent.h>
#include <QDebug>
#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
ProfileWidget2 *profWidget = NULL;
if (scene() && scene()->views().count())
profWidget = qobject_cast<ProfileWidget2 *>(scene()->views().first());
if (ruler &&
profWidget &&
!profWidget->isAddOrPlanner() &&
change == ItemPositionHasChanged) {
setPos(event->scenePos());
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()),

View file

@ -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;