mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Switch from locations to dive sites in dive.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
8bea7cbdc7
commit
99ba2f0687
1 changed files with 8 additions and 15 deletions
23
dive.c
23
dive.c
|
@ -437,7 +437,6 @@ void clear_dive(struct dive *d)
|
||||||
/* free the strings */
|
/* free the strings */
|
||||||
free(d->buddy);
|
free(d->buddy);
|
||||||
free(d->divemaster);
|
free(d->divemaster);
|
||||||
free(d->location);
|
|
||||||
free(d->notes);
|
free(d->notes);
|
||||||
free(d->suit);
|
free(d->suit);
|
||||||
/* free tags, additional dive computers, and pictures */
|
/* free tags, additional dive computers, and pictures */
|
||||||
|
@ -463,7 +462,6 @@ void copy_dive(struct dive *s, struct dive *d)
|
||||||
*d = *s;
|
*d = *s;
|
||||||
d->buddy = copy_string(s->buddy);
|
d->buddy = copy_string(s->buddy);
|
||||||
d->divemaster = copy_string(s->divemaster);
|
d->divemaster = copy_string(s->divemaster);
|
||||||
d->location = copy_string(s->location);
|
|
||||||
d->notes = copy_string(s->notes);
|
d->notes = copy_string(s->notes);
|
||||||
d->suit = copy_string(s->suit);
|
d->suit = copy_string(s->suit);
|
||||||
for (int i = 0; i < MAX_CYLINDERS; i++)
|
for (int i = 0; i < MAX_CYLINDERS; i++)
|
||||||
|
@ -500,7 +498,6 @@ void selective_copy_dive(struct dive *s, struct dive *d, struct dive_components
|
||||||
{
|
{
|
||||||
if (clear)
|
if (clear)
|
||||||
clear_dive(d);
|
clear_dive(d);
|
||||||
CONDITIONAL_COPY_STRING(location);
|
|
||||||
CONDITIONAL_COPY_STRING(notes);
|
CONDITIONAL_COPY_STRING(notes);
|
||||||
CONDITIONAL_COPY_STRING(divemaster);
|
CONDITIONAL_COPY_STRING(divemaster);
|
||||||
CONDITIONAL_COPY_STRING(buddy);
|
CONDITIONAL_COPY_STRING(buddy);
|
||||||
|
@ -509,10 +506,8 @@ void selective_copy_dive(struct dive *s, struct dive *d, struct dive_components
|
||||||
d->rating = s->rating;
|
d->rating = s->rating;
|
||||||
if (what.visibility)
|
if (what.visibility)
|
||||||
d->visibility = s->visibility;
|
d->visibility = s->visibility;
|
||||||
if (what.gps) {
|
if (what.divesite)
|
||||||
d->longitude = s->longitude;
|
d->dive_site_uuid = s->dive_site_uuid;
|
||||||
d->latitude = s->latitude;
|
|
||||||
}
|
|
||||||
if (what.tags)
|
if (what.tags)
|
||||||
STRUCTURED_LIST_COPY(struct tag_entry, s->tag_list, d->tag_list, copy_tl);
|
STRUCTURED_LIST_COPY(struct tag_entry, s->tag_list, d->tag_list, copy_tl);
|
||||||
if (what.cylinders)
|
if (what.cylinders)
|
||||||
|
@ -2699,7 +2694,7 @@ int count_dives_with_location(const char *location)
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
|
|
||||||
for_each_dive (i, d) {
|
for_each_dive (i, d) {
|
||||||
if (same_string(d->location, location))
|
if (same_string(get_dive_location(d), location))
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
return counter;
|
return counter;
|
||||||
|
@ -2744,9 +2739,6 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer
|
||||||
res->when = dl ? dl->when : a->when;
|
res->when = dl ? dl->when : a->when;
|
||||||
res->selected = a->selected || b->selected;
|
res->selected = a->selected || b->selected;
|
||||||
merge_trip(res, a, b);
|
merge_trip(res, a, b);
|
||||||
MERGE_NONZERO(res, a, b, latitude.udeg);
|
|
||||||
MERGE_NONZERO(res, a, b, longitude.udeg);
|
|
||||||
MERGE_TXT(res, a, b, location);
|
|
||||||
MERGE_TXT(res, a, b, notes);
|
MERGE_TXT(res, a, b, notes);
|
||||||
MERGE_TXT(res, a, b, buddy);
|
MERGE_TXT(res, a, b, buddy);
|
||||||
MERGE_TXT(res, a, b, divemaster);
|
MERGE_TXT(res, a, b, divemaster);
|
||||||
|
@ -2766,7 +2758,7 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer
|
||||||
interleave_dive_computers(&res->dc, &a->dc, &b->dc, offset);
|
interleave_dive_computers(&res->dc, &a->dc, &b->dc, offset);
|
||||||
else
|
else
|
||||||
join_dive_computers(&res->dc, &a->dc, &b->dc, 0);
|
join_dive_computers(&res->dc, &a->dc, &b->dc, 0);
|
||||||
|
res->dive_site_uuid = a->dive_site_uuid ?: b->dive_site_uuid;
|
||||||
fixup_dive(res);
|
fixup_dive(res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -2931,9 +2923,10 @@ unsigned int dive_get_picture_count(struct dive *d)
|
||||||
|
|
||||||
void dive_set_geodata_from_picture(struct dive *d, struct picture *pic)
|
void dive_set_geodata_from_picture(struct dive *d, struct picture *pic)
|
||||||
{
|
{
|
||||||
if (!d->latitude.udeg && pic->latitude.udeg) {
|
struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid);
|
||||||
d->latitude = pic->latitude;
|
if (!dive_site_has_gps_location(ds) && (pic->latitude.udeg || pic->longitude.udeg)) {
|
||||||
d->longitude = pic->longitude;
|
ds->latitude = pic->latitude;
|
||||||
|
ds->longitude = pic->longitude;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue