mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
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:
parent
59785345f8
commit
57d3baa410
2 changed files with 6 additions and 18 deletions
|
@ -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) {
|
||||
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()),
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue