mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Core: replace tripflag by notrip boolean
The only remaining use of the tripflag was to mark dives that were removed explicitly from a trip, i.e. shouldn't be autogrouped. Therefore replace the enum by a simple boolean. Currently, there is no way of unsetting the notrip flag. But this shouldn't result in a user-visible change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3b9e0b5931
commit
6bf4120dbb
9 changed files with 13 additions and 28 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
11
core/dive.h
11
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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue