summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-11-10 19:51:03 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-11 05:17:00 +0100
commit38c79d149db09cbb856e4827ce7a24d742c91917 (patch)
treee828d5d1c93d21cfa44532a6296ce998f7736dd2 /dive.h
parentf53788e5e4066f0ef36041031de6bc2726274fc9 (diff)
downloadsubsurface-38c79d149db09cbb856e4827ce7a24d742c91917.tar.gz
Simplify and clean up dive trip management
This adds a couple of helper functions to manage dive trips ("add_dive_to_trip()" and "remove_dive_from_trip()") and makes those functions do the trip statistics maintenance (trip beginning times, number of dives, etc). This was needed because the dive merge cases for multiple dive computers showed some rather nasty special cases: especially if the new dive information has been loaded into an XML file with trips auto-generated, merging several of these kinds of xml files with multiple dives in several overlapping trips would completely confuse our previous code. In particular, auto-generated trips that had the exact same date as previous trips (because they were generated from the same dive computer) really confused the code that used the trip timestamp to manage the trips. Adding the helper functions allows us to get the general case right without having to have each piece of code that handles trip information having to bother about all the odd rules. It will eventually also allow us to make the dive trip data structures more logical: right now the dive trip list is largely designed around the odd gtk model handling, rather than some more higher-level conceptual relationship with the actual dives. But for now, this keeps all the data structures unchanged, and just modifies them using the new helper functions. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/dive.h b/dive.h
index 1e54e1273..a2d14215b 100644
--- a/dive.h
+++ b/dive.h
@@ -252,6 +252,7 @@ typedef struct dive_trip {
timestamp_t when_from_file;
char *location;
char *notes;
+ int nrdives;
int expanded:1, selected:1;
} dive_trip_t;
@@ -300,8 +301,10 @@ extern gboolean autogroup;
#define DIVE_TRIP(_trip) ((dive_trip_t *)(_trip)->data)
#define DIVE_FITS_TRIP(_dive, _dive_trip) ((_dive_trip)->when - TRIP_THRESHOLD <= (_dive)->when)
+extern void add_dive_to_trip(struct dive *, dive_trip_t *);
+extern void remove_dive_from_trip(struct dive *);
+
extern void insert_trip(dive_trip_t **trip);
-extern void delete_trip(dive_trip_t *trip);
/*
* We keep our internal data in well-specified units, but