summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-01-28 21:00:47 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-01-28 21:04:50 -0800
commitf5a48385192606fd6a0b68f26d3cc10b8376c576 (patch)
treec6bba1952134a36930ea1ecb6be41d8733d5cbd2 /profile-widget
parent279ba5823645aef97f0cf9f210cde6adfd9ae3a6 (diff)
downloadsubsurface-f5a48385192606fd6a0b68f26d3cc10b8376c576.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/profilewidget2.cpp9
1 files changed, 5 insertions, 4 deletions
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();
}