diff options
Diffstat (limited to 'qt-ui/profile/ruleritem.cpp')
-rw-r--r-- | qt-ui/profile/ruleritem.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index 0f2a24a80..295d81213 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -1,7 +1,8 @@ #include "ruleritem.h" #include "divetextitem.h" #include "profilewidget2.h" -#include "../preferences.h" +#include "preferences.h" +#include "mainwindow.h" #include <QFont> #include <QFontMetrics> @@ -59,9 +60,19 @@ void RulerNodeItem2::recalculate() QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &value) { - if (change == ItemPositionHasChanged) { + // 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); } |