mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add helper function that checks if a dive site is in use
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
542e04266d
commit
1dbb6071bd
3 changed files with 17 additions and 10 deletions
14
divesite.c
14
divesite.c
|
@ -108,6 +108,20 @@ struct dive_site *alloc_dive_site()
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_dive_site_used(uint32_t uuid, bool select_only)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
bool found = false;
|
||||||
|
struct dive *d;
|
||||||
|
for_each_dive(j, d) {
|
||||||
|
if (d->dive_site_uuid == uuid && (!select_only || d->selected)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
void delete_dive_site(uint32_t id)
|
void delete_dive_site(uint32_t id)
|
||||||
{
|
{
|
||||||
int nr = dive_site_table.nr;
|
int nr = dive_site_table.nr;
|
||||||
|
|
|
@ -50,6 +50,7 @@ static inline struct dive_site *get_dive_site_by_uuid(uint32_t uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dive_site *alloc_dive_site();
|
struct dive_site *alloc_dive_site();
|
||||||
|
bool is_dive_site_used(uint32_t uuid, bool select_only);
|
||||||
void delete_dive_site(uint32_t id);
|
void delete_dive_site(uint32_t id);
|
||||||
uint32_t create_dive_site(const char *name);
|
uint32_t create_dive_site(const char *name);
|
||||||
uint32_t create_dive_site_with_gps(const char *name, degrees_t latitude, degrees_t longitude);
|
uint32_t create_dive_site_with_gps(const char *name, degrees_t latitude, degrees_t longitude);
|
||||||
|
|
12
save-xml.c
12
save-xml.c
|
@ -520,17 +520,9 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
|
||||||
i--; // since we just deleted that one
|
i--; // since we just deleted that one
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (select_only) {
|
if (select_only && !is_dive_site_used(ds->uuid, true))
|
||||||
bool found = false;
|
|
||||||
for_each_dive(j, d) {
|
|
||||||
if (d->selected && d->dive_site_uuid == ds->uuid) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
put_format(b, "<site uuid='%8x'", ds->uuid);
|
put_format(b, "<site uuid='%8x'", ds->uuid);
|
||||||
show_utf8(b, ds->name, " name='", "'", 1);
|
show_utf8(b, ds->name, " name='", "'", 1);
|
||||||
if (ds->latitude.udeg || ds->longitude.udeg) {
|
if (ds->latitude.udeg || ds->longitude.udeg) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue