aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index f0dad6ca4..f772a1c28 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -557,16 +557,30 @@ void DivePlannerGraphics::showEvent(QShowEvent* event)
void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event)
{
QPointF mappedPos = mapToScene(event->pos());
- if (isPointOutOfBoundaries(mappedPos))
- return;
- verticalLine->setPos(mappedPos.x(), fromPercent(0, Qt::Vertical));
- horizontalLine->setPos(fromPercent(0, Qt::Horizontal), mappedPos.y());
+
+ double xpos = timeLine->valueAt(mappedPos);
+ double ypos = depthLine->valueAt(mappedPos);
+
+ xpos = (xpos > timeLine->maximum()) ? timeLine->posAtValue(timeLine->maximum())
+ : (xpos < timeLine->minimum()) ? timeLine->posAtValue(timeLine->minimum())
+ : timeLine->posAtValue(xpos);
+
+ ypos = (ypos > depthLine->maximum()) ? depthLine->posAtValue(depthLine->maximum())
+ : ( ypos < depthLine->minimum()) ? depthLine->posAtValue(depthLine->minimum())
+ : depthLine->posAtValue(ypos);
+
+ verticalLine->setPos(xpos, fromPercent(0, Qt::Vertical));
+ horizontalLine->setPos(fromPercent(0, Qt::Horizontal), ypos);
+
+ depthString->setPos(fromPercent(1, Qt::Horizontal), ypos);
+ timeString->setPos(xpos+1, fromPercent(95, Qt::Vertical));
+
+ if(isPointOutOfBoundaries(mappedPos))
+ return;
depthString->setText(get_depth_string(depthLine->valueAt(mappedPos), true, false));
- depthString->setPos(fromPercent(1, Qt::Horizontal), mappedPos.y());
timeString->setText(QString::number(rint(timeLine->valueAt(mappedPos))) + "min");
- timeString->setPos(mappedPos.x()+1, fromPercent(95, Qt::Vertical));
// calculate the correct color for the depthString.
// QGradient doesn't returns it's interpolation, meh.