diff options
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index fe1342112..36cd7f144 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -428,7 +428,7 @@ void DivePlannerGraphics::drawProfile() dp = dp->next; } - if (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum()) { + if (!activeDraggedHandler && (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum())) { double newMax = fmax(dp->time / 60.0 + 5, minMinutes); timeLine->setMaximum(newMax); timeLine->updateTicks(); @@ -522,7 +522,7 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event) depthString->setBrush( QColor(redDelta, greenDelta, blueDelta)); if (activeDraggedHandler) - moveActiveHandler(mappedPos); + moveActiveHandler(mappedPos, handles.indexOf(activeDraggedHandler)); if (!handles.count()) return; @@ -535,13 +535,27 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event) } } -void DivePlannerGraphics::moveActiveHandler(const QPointF& pos) +void DivePlannerGraphics::moveActiveHandler(const QPointF& mappedPos, const int pos) { - double xpos = timeLine->posAtValue(rint(timeLine->valueAt(pos))); - double ypos = depthLine->posAtValue(rint(depthLine->valueAt(pos))); + + divedatapoint data = plannerModel->at(pos); + int minutes = rint(timeLine->valueAt(mappedPos)); + int meters = rint(depthLine->valueAt(mappedPos)); + double xpos = timeLine->posAtValue(minutes); + double ypos = depthLine->posAtValue(meters); + + data.depth = rint(depthLine->valueAt(mappedPos)) * 1000; + data.time = rint(timeLine->valueAt(mappedPos)) * 60; + + plannerModel->editStop(pos, data); + activeDraggedHandler->setPos(QPointF(xpos, ypos)); qDeleteAll(lines); lines.clear(); + + drawProfile(); + + } bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point) @@ -606,8 +620,8 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event) activeDraggedHandler->setBrush(QBrush(Qt::white)); activeDraggedHandler->setPos(QPointF(xpos, ypos)); - drawProfile(); activeDraggedHandler = 0; + drawProfile(); } } |