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>
This commit is contained in:
Dirk Hohndel 2017-01-28 21:00:47 -08:00
parent 279ba58236
commit f5a4838519
2 changed files with 7 additions and 4 deletions

View file

@ -6,6 +6,8 @@ _Subsurface_ next after 4.6 - January 2017
Some of the changes since _Subsurface_ 4.6
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fix scaling issue that prevent the visual dive editor from reaching
certain dive durations
- Prevent double click on dive number in dive list from (temporarily) editing
dive number
- Allow the user to disable tanks while planning dives (this makes it much

View file

@ -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();
}