From 8d8e694b0dae1d84c27d76aa7c68749ab2a014ac Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Thu, 14 Sep 2017 21:09:03 +0200 Subject: End tankbar at the correct end of the dive plot Go back to the old startegy of retrieving the correct end of the dive plot by looking at the plot data instead of looking at dc->duration. Signed-off-by: Stefan Fuchs --- profile-widget/tankitem.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'profile-widget/tankitem.cpp') diff --git a/profile-widget/tankitem.cpp b/profile-widget/tankitem.cpp index b6e099c7b..c4c1aeeee 100644 --- a/profile-widget/tankitem.cpp +++ b/profile-widget/tankitem.cpp @@ -97,6 +97,9 @@ void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &b qreal width, left; + // Find correct end of the dive plot for correct end of the tankbar + struct plot_data *last_entry = &pInfoEntry[pInfoNr-1]; + // get the information directly from the displayed_dive (the dc always exists) struct divecomputer *dc = get_dive_dc(&displayed_dive, dc_number); @@ -107,7 +110,7 @@ void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &b // work through all the gas changes and add the rectangle for each gas while it was used struct event *ev = get_next_event(dc->events, "gaschange"); - while (ev && ev->time.seconds < dc->duration.seconds) { + while (ev && ev->time.seconds < last_entry->sec) { width = hAxis->posAtValue(ev->time.seconds) - hAxis->posAtValue(startTime); left = hAxis->posAtValue(startTime); createBar(left, width, gasmix); @@ -115,7 +118,7 @@ void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &b gasmix = get_gasmix_from_event(&displayed_dive, ev); ev = get_next_event(ev->next, "gaschange"); } - width = hAxis->posAtValue(dc->duration.seconds) - hAxis->posAtValue(startTime); + width = hAxis->posAtValue(last_entry->sec) - hAxis->posAtValue(startTime); left = hAxis->posAtValue(startTime); createBar(left, width, gasmix); } -- cgit v1.2.3-70-g09d2