summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-09-30 18:00:34 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-10-01 23:55:37 +0300
commit7713c7e607b11c0828decdbf35d910280153f880 (patch)
tree8e08d80032ba7cdcaa344042da7e220f217b75c5 /desktop-widgets
parent325c4459ade70f626d6a39fecfb9e0c27f0c5cee (diff)
downloadsubsurface-7713c7e607b11c0828decdbf35d910280153f880.tar.gz
Use helper function dive_endtime() where apropriate
Calculating dive.when + dive.duration doesn't always give the correct endtime of a dive especially when a dive has surface interval(s) in the middle. Using the helper function dive_endtime() fixes this issue. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/subsurfacewebservices.cpp9
-rw-r--r--desktop-widgets/tab-widgets/TabDiveInformation.cpp3
2 files changed, 7 insertions, 5 deletions
diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp
index 371a8475a..6c982d27f 100644
--- a/desktop-widgets/subsurfacewebservices.cpp
+++ b/desktop-widgets/subsurfacewebservices.cpp
@@ -12,6 +12,7 @@
#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <errno.h>
#include "core/cloudstorage.h"
+#include "core/dive.h"
#include <QDir>
#include <QHttpMultiPart>
@@ -70,7 +71,7 @@ static bool merge_locations_into_dives(void)
qDebug() << "processing gpsfix @" << get_dive_date_string(gpsfix->when) <<
"which is withing six hours of dive from" <<
get_dive_date_string(dive->when) << "until" <<
- get_dive_date_string(dive->when + dive->duration.seconds);
+ get_dive_date_string(dive_endtime(dive));
/*
* If position is fixed during dive. This is the good one.
* Asign and mark position, and end gps_location loop
@@ -106,7 +107,7 @@ static bool merge_locations_into_dives(void)
if (verbose)
qDebug() << "which is closer to the start of the dive, do continue with that";
continue;
- } else if (gpsfix->when > dive->when + dive->duration.seconds) {
+ } else if (gpsfix->when > dive_endtime(dive)) {
if (verbose)
qDebug() << "which is even later after the end of the dive, so pick the previous one";
copy_gps_location(gpsfix, dive);
@@ -115,7 +116,7 @@ static bool merge_locations_into_dives(void)
break;
} else {
/* ok, gpsfix is before, nextgpsfix is after */
- if (dive->when - gpsfix->when <= nextgpsfix->when - (dive->when + dive->duration.seconds)) {
+ if (dive->when - gpsfix->when <= nextgpsfix->when - dive_endtime(dive)) {
if (verbose)
qDebug() << "pick the one before as it's closer to the start";
copy_gps_location(gpsfix, dive);
@@ -147,7 +148,7 @@ static bool merge_locations_into_dives(void)
/* If position is out of SAME_GROUP range and in the future, mark position for
* next dive iteration and end the gps_location loop
*/
- if (gpsfix->when >= dive->when + dive->duration.seconds + SAME_GROUP) {
+ if (gpsfix->when >= dive_endtime(dive) + SAME_GROUP) {
tracer = j;
break;
}
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp
index 419e73739..ae3998ed8 100644
--- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp
@@ -6,6 +6,7 @@
#include <core/helpers.h>
#include <core/statistics.h>
#include <core/display.h>
+#include <core/dive.h>
TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveInformation())
{
@@ -81,7 +82,7 @@ void TabDiveInformation::updateData()
process_all_dives(&displayed_dive, &prevd);
if (prevd)
- ui->surfaceIntervalText->setText(get_dive_surfint_string(displayed_dive.when - (prevd->when + prevd->duration.seconds), tr("d"), tr("h"), tr("min")));
+ ui->surfaceIntervalText->setText(get_dive_surfint_string(displayed_dive.when - (dive_endtime(prevd)), tr("d"), tr("h"), tr("min")));
else
ui->surfaceIntervalText->clear();