From f5a48385192606fd6a0b68f26d3cc10b8376c576 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 28 Jan 2017 21:00:47 -0800 Subject: Fix dive visual editor being too quick to rescale time When moving the last handle of a dive (in the planner, in dive add, or when editing a dive), we rescaled the time axis whenever our idea of the maximum duration that we should show changed. That lead to the odd situation that you couldn't get to certain dive durations with the visual editor (e.g. 64 minutes) because just as you approach that time the scale changes and the dive duration jumps past the desired value. Fixes issue #174 Signed-off-by: Dirk Hohndel --- profile-widget/profilewidget2.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index e85e41fd2..0ad2b5601 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -624,8 +624,9 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) */ plotInfo = calculate_max_limits_new(&displayed_dive, currentdc); create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth); - if (shouldCalculateMaxTime) - maxtime = get_maxtime(&plotInfo); + int newMaxtime = get_maxtime(&plotInfo); + if (shouldCalculateMaxTime || newMaxtime > maxtime) + maxtime = newMaxtime; /* Only update the max depth if it's bigger than the current ones * when we are dragging the handler to plan / add dive. @@ -856,7 +857,7 @@ void ProfileWidget2::mousePressEvent(QMouseEvent *event) if (zoomLevel) return; QGraphicsView::mousePressEvent(event); - if (currentState == PLAN) + if (currentState == PLAN || currentState == ADD || currentState == EDIT) shouldCalculateMaxTime = false; } @@ -881,7 +882,7 @@ void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event) if (zoomLevel) return; QGraphicsView::mouseReleaseEvent(event); - if (currentState == PLAN) { + if (currentState == PLAN || currentState == ADD || currentState == EDIT) { shouldCalculateMaxTime = true; replot(); } -- cgit v1.2.3-70-g09d2