summaryrefslogtreecommitdiffstats
path: root/qt-models/divetripmodel.cpp
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 /qt-models/divetripmodel.cpp
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 'qt-models/divetripmodel.cpp')
-rw-r--r--qt-models/divetripmodel.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index 0293f6a45..5c6dd30ff 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -4,6 +4,7 @@
#include "core/metrics.h"
#include "core/divelist.h"
#include "core/helpers.h"
+#include "core/dive.h"
#include <QIcon>
static int nitrox_sort_value(struct dive *dive)
@@ -325,12 +326,12 @@ QString DiveItem::displayDepthWithUnit() const
int DiveItem::countPhotos(dive *dive) const
{ // Determine whether dive has pictures, and whether they were taken during or before/after dive.
const int bufperiod = 120; // A 2-min buffer period. Photos within 2 min of dive are assumed as
- int diveDuration = dive->duration.seconds; // taken during the dive, not before/after.
+ int diveTotaltime = dive_endtime(dive) - dive->when; // taken during the dive, not before/after.
int pic_offset, icon_index = 0;
FOR_EACH_PICTURE (dive) { // Step through each of the pictures for this dive:
if (!picture) break; // if there are no pictures for this dive, return 0
pic_offset = picture->offset.seconds;
- if ((pic_offset < -bufperiod) | (pic_offset > diveDuration+bufperiod)) {
+ if ((pic_offset < -bufperiod) | (pic_offset > diveTotaltime+bufperiod)) {
icon_index |= 0x02; // If picture is before/after the dive
} // then set the appropriate bit ...
else {