diff options
author | Robert Helling <helling@lmu.de> | 2013-09-19 09:13:53 -0500 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-09-19 09:13:53 -0500 |
commit | fc3b68bc191ddafa20167da6ed8b6c8b3548f929 (patch) | |
tree | 42f6c750a777a7115dee568bbf10e253aae8cb87 /qt-ui | |
parent | 40462d5008de546d12038b3b062052e180b02930 (diff) | |
download | subsurface-fc3b68bc191ddafa20167da6ed8b6c8b3548f929.tar.gz |
Continous update of planner
Make the planner update its display continuously upon moving points
including deco. This appears fast enough on typical PCs. If this ends up
being to slow on some systems we may have to make it configurable.
[Dirk Hohndel: cleaned up the two patches and turned into one commit]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 26 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 2 |
2 files changed, 21 insertions, 7 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index ba578fed1..612c29dee 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -427,7 +427,7 @@ void DivePlannerGraphics::createDecoStops() 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(); @@ -521,7 +521,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; @@ -534,13 +534,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(); + + createDecoStops(); + + } bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point) @@ -605,8 +619,8 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event) activeDraggedHandler->setBrush(QBrush(Qt::white)); activeDraggedHandler->setPos(QPointF(xpos, ypos)); - createDecoStops(); activeDraggedHandler = 0; + createDecoStops(); } } diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 8dd8db3e3..7f32290cb 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -149,7 +149,7 @@ private slots: void pointInserted(const QModelIndex&, int start, int end); void pointsRemoved(const QModelIndex&, int start, int end); private: - void moveActiveHandler(const QPointF& pos); + void moveActiveHandler(const QPointF& MappedPos, const int pos); /* This are the lines of the plotted dive. */ QList<QGraphicsLineItem*> lines; |