summaryrefslogtreecommitdiffstats
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, 25 insertions, 1 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 42c3bda80..fa7be75b3 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -74,6 +74,18 @@ void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event)
scene()->addItem(line);
create_deco_stop();
}
+ item->setTime(timeLine->valueAt(mappedPos));
+ item->setDepth(depthLine->valueAt(mappedPos));
+}
+
+void DiveHandler::setDepth(qreal d)
+{
+ depth = d;
+}
+
+void DiveHandler::setTime(qreal t)
+{
+ time =t;
}
void DivePlanner::clear_generated_deco()
@@ -200,8 +212,12 @@ void DivePlanner::mousePressEvent(QMouseEvent* event)
void DivePlanner::mouseReleaseEvent(QMouseEvent* event)
{
- if (activeDraggedHandler)
+ if (activeDraggedHandler){
+ QPointF mappedPos = mapToScene(event->pos());
+ activeDraggedHandler ->setTime(timeLine->valueAt(mappedPos));
+ activeDraggedHandler ->setDepth(depthLine->valueAt(mappedPos));
activeDraggedHandler = 0;
+ }
}
DiveHandler::DiveHandler(): QGraphicsEllipseItem(), from(0), to(0)
@@ -251,3 +267,11 @@ void Ruler::setTickInterval(double i)
{
interval = i;
}
+
+qreal Ruler::valueAt(const QPointF& p)
+{
+ QLineF m = line();
+ return orientation == Qt::Horizontal
+ ? max * (p.x() - m.x1()) / (m.x2() - m.x1())
+ : max * (p.y() - m.y1()) / (m.y2() - m.y1());
+}