summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/dive.c3
-rw-r--r--core/dive.h11
-rw-r--r--core/divelist.c11
-rw-r--r--core/load-git.c2
-rw-r--r--core/parse-xml.c6
-rw-r--r--core/save-git.c2
-rw-r--r--core/save-xml.c2
-rw-r--r--core/uemis-downloader.c2
-rw-r--r--mobile-widgets/qmlmanager.cpp2
9 files changed, 13 insertions, 28 deletions
diff --git a/core/dive.c b/core/dive.c
index 22f88d43f..47143aaa3 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -2564,10 +2564,9 @@ static void merge_temperatures(struct dive *res, const struct dive *a, const str
*/
static void pick_trip(struct dive *res, const struct dive *pick)
{
- tripflag_t tripflag = pick->tripflag;
dive_trip_t *trip = pick->divetrip;
- res->tripflag = tripflag;
+ res->notrip = pick->notrip;
add_dive_to_trip(res, trip);
}
diff --git a/core/dive.h b/core/dive.h
index cc21c3447..8b98d3b49 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -278,13 +278,6 @@ struct divecomputer {
#define W_IDX_PRIMARY 0
#define W_IDX_SECONDARY 1
-typedef enum {
- TF_NONE,
- NO_TRIP,
- IN_TRIP,
- NUM_TRIPFLAGS
-} tripflag_t;
-
struct dive_table {
int nr, allocated;
struct dive **dives;
@@ -307,7 +300,7 @@ extern dive_trip_t *dive_trip_list;
struct picture;
struct dive {
int number;
- tripflag_t tripflag;
+ bool notrip; /* Don't autogroup this dive to a trip */
dive_trip_t *divetrip;
bool selected;
bool hidden_by_filter;
@@ -418,8 +411,6 @@ extern bool autogroup;
* regularly dive at a local facility; this is why trips are an optional feature */
#define TRIP_THRESHOLD 3600 * 24 * 3
-#define DIVE_NEEDS_TRIP(_dive) ((_dive)->tripflag == TF_NONE)
-
extern void add_dive_to_trip(struct dive *, dive_trip_t *);
struct dive *unregister_dive(int idx);
diff --git a/core/divelist.c b/core/divelist.c
index f887cc82c..41036a65f 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -875,10 +875,6 @@ struct dive_trip *unregister_dive_from_trip(struct dive *dive, short was_autogen
if (idx)
unregister_dive_from_table(&trip->dives, idx);
dive->divetrip = NULL;
- if (was_autogen)
- dive->tripflag = TF_NONE;
- else
- dive->tripflag = NO_TRIP;
return trip;
}
@@ -896,7 +892,6 @@ void add_dive_to_trip(struct dive *dive, dive_trip_t *trip)
remove_dive_from_trip(dive, false);
add_dive_to_table(&trip->dives, -1, dive);
dive->divetrip = trip;
- dive->tripflag = IN_TRIP;
}
dive_trip_t *alloc_trip(void)
@@ -981,7 +976,9 @@ dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocat
continue;
}
- if (!DIVE_NEEDS_TRIP(dive)) {
+ /* Only consider dives that have not been explicitly removed from
+ * a dive trip by the user. */
+ if (dive->notrip) {
lastdive = NULL;
continue;
}
@@ -1002,7 +999,7 @@ dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocat
lastdive = dive;
*from = i;
for (*to = *from + 1; (dive = get_dive(*to)) != NULL; (*to)++) {
- if (dive->divetrip || !DIVE_NEEDS_TRIP(dive) ||
+ if (dive->divetrip || dive->notrip ||
dive->when >= lastdive->when + TRIP_THRESHOLD)
break;
if (get_dive_location(dive) && !trip->location)
diff --git a/core/load-git.c b/core/load-git.c
index 1447becb2..59434c64e 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -261,7 +261,7 @@ static void parse_dive_notrip(char *line, struct membuffer *str, void *_dive)
{
UNUSED(str);
UNUSED(line);
- struct dive *dive = _dive; dive->tripflag = NO_TRIP;
+ struct dive *dive = _dive; dive->notrip = true;
}
static void parse_site_description(char *line, struct membuffer *str, void *_ds)
diff --git a/core/parse-xml.c b/core/parse-xml.c
index d9185cd32..931d12f6b 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -565,9 +565,9 @@ static void dive_site(char *buffer, struct dive_site **ds)
*ds = get_dive_site_by_uuid(uuid);
}
-static void get_tripflag(char *buffer, tripflag_t *tf)
+static void get_notrip(char *buffer, bool *notrip)
{
- *tf = strcmp(buffer, "NOTRIP") ? TF_NONE : NO_TRIP;
+ *notrip = !strcmp(buffer, "NOTRIP");
}
/*
@@ -1241,7 +1241,7 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf, str
return;
if (MATCH("tags", divetags, &dive->tag_list))
return;
- if (MATCH("tripflag", get_tripflag, &dive->tripflag))
+ if (MATCH("tripflag", get_notrip, &dive->notrip))
return;
if (MATCH_STATE("date", divedate, &dive->when))
return;
diff --git a/core/save-git.c b/core/save-git.c
index c53c2bb97..7b903a5e9 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -429,7 +429,7 @@ static void create_dive_buffer(struct dive *dive, struct membuffer *b)
put_format(b, "duration %u:%02u min\n", FRACTION(dive->dc.duration.seconds, 60));
SAVE("rating", rating);
SAVE("visibility", visibility);
- cond_put_format(dive->tripflag == NO_TRIP, b, "notrip\n");
+ cond_put_format(dive->notrip, b, "notrip\n");
save_tags(b, dive->tag_list);
if (dive->dive_site)
put_format(b, "divesiteid %08x\n", dive->dive_site->uuid);
diff --git a/core/save-xml.c b/core/save-xml.c
index 4abb3cc12..baebb0ad9 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -476,7 +476,7 @@ void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize)
put_string(b, "<dive");
if (dive->number)
put_format(b, " number='%d'", dive->number);
- if (dive->tripflag == NO_TRIP)
+ if (dive->notrip)
put_format(b, " tripflag='NOTRIP'");
if (dive->rating)
put_format(b, " rating='%d'", dive->rating);
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index 52b4276c2..3ae6f7b8d 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -858,7 +858,7 @@ static bool uemis_delete_dive(device_data_t *devdata, uint32_t diveid)
}
if (dive) {
devdata->download_table->dives[--devdata->download_table->nr] = NULL;
- if (dive->tripflag != TF_NONE)
+ if (dive->notrip)
remove_dive_from_trip(dive, false);
free(dive->dc.sample);
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index cc98286a2..70ab87ea5 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1273,10 +1273,8 @@ bool QMLManager::undoDelete(int id)
insert_trip(deletedTrip);
if (deletedDive->divetrip) {
struct dive_trip *trip = deletedDive->divetrip;
- tripflag_t tripflag = deletedDive->tripflag; // this gets overwritten in add_dive_to_trip()
deletedDive->divetrip = NULL;
add_dive_to_trip(deletedDive, trip);
- deletedDive->tripflag = tripflag;
}
record_dive(deletedDive);
QList<dive *>diveAsList;