diff options
Diffstat (limited to 'qt-ui/profile')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 5 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 1 | ||||
-rw-r--r-- | qt-ui/profile/ruleritem.cpp | 15 |
3 files changed, 19 insertions, 2 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index a196b346a..73df4f99d 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -830,6 +830,11 @@ bool ProfileWidget2::isPlanner() return currentState == PLAN; } +bool ProfileWidget2::isAddOrPlanner() +{ + return currentState == PLAN || currentState == ADD; +} + void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) { if (currentState == ADD || currentState == PLAN) { diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index b1a415eb3..9c7610526 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -72,6 +72,7 @@ public: void setPrintMode(bool mode, bool grayscale = false); bool isPointOutOfBoundaries(const QPointF &point) const; bool isPlanner(); + bool isAddOrPlanner(); State currentState; public 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); } |