summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-12-12 22:58:53 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-20 15:20:44 -0700
commit329641fdcdf7759d430aea2d2a115550bc5caf62 (patch)
tree45e4e272f86c2f1429b3c9fff4e9f435bf9392a7
parentef821d7d94bbc69337c36f26a25d819e340b14f5 (diff)
downloadsubsurface-329641fdcdf7759d430aea2d2a115550bc5caf62.tar.gz
Core: introduce invalid flag for dives
Implement reading/writing the flag from/to XML/git. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--core/dive.h1
-rw-r--r--core/load-git.c9
-rw-r--r--core/parse-xml.c2
-rw-r--r--core/save-git.c1
-rw-r--r--core/save-xml.c2
5 files changed, 14 insertions, 1 deletions
diff --git a/core/dive.h b/core/dive.h
index 95623d653..1e5ca873d 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -172,6 +172,7 @@ struct dive {
bool selected;
bool hidden_by_filter;
struct full_text_cache *full_text; /* word cache for full text search */
+ bool invalid;
};
/* For the top-level list: an entry is either a dive or a trip */
diff --git a/core/load-git.c b/core/load-git.c
index a9e9107f7..f01fe72a0 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -283,6 +283,13 @@ static void parse_dive_notrip(char *line, struct membuffer *str, struct git_pars
state->active_dive->notrip = true;
}
+static void parse_dive_invalid(char *line, struct membuffer *str, struct git_parser_state *state)
+{
+ UNUSED(str);
+ UNUSED(line);
+ state->active_dive->invalid = true;
+}
+
static void parse_site_description(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_site->description = detach_cstring(str); }
@@ -1039,7 +1046,7 @@ struct keyword_action dive_action[] = {
#undef D
#define D(x) { #x, parse_dive_ ## x }
D(airpressure), D(airtemp), D(buddy), D(chill), D(current), D(cylinder), D(divemaster), D(divesiteid), D(duration),
- D(gps), D(location), D(notes), D(notrip), D(rating), D(suit), D(surge),
+ D(gps), D(invalid), D(location), D(notes), D(notrip), D(rating), D(suit), D(surge),
D(tags), D(visibility), D(watersalinity), D(watertemp), D(wavesize), D(weightsystem)
};
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 4058603d3..6218fc74d 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -1381,6 +1381,8 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf, str
return;
if (MATCH_STATE("water.divetemperature", temperature, &dive->watertemp))
return;
+ if (MATCH("invalid", get_bool, &dive->invalid))
+ return;
nonmatch("dive", name, buf);
}
diff --git a/core/save-git.c b/core/save-git.c
index daeae23a3..a304e0d94 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -442,6 +442,7 @@ static void create_dive_buffer(struct dive *dive, struct membuffer *b)
if (surface_pressure.mbar)
SAVE("airpressure", surface_pressure.mbar);
cond_put_format(dive->notrip, b, "notrip\n");
+ cond_put_format(dive->invalid, b, "invalid\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 53d7a3af6..3570861e4 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -498,6 +498,8 @@ void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize)
put_format(b, " surge='%d'", dive->surge);
if (dive->chill)
put_format(b, " chill='%d'", dive->chill);
+ if (dive->invalid)
+ put_format(b, " invalid");
save_tags(b, dive->tag_list);
if (dive->dive_site)
put_format(b, " divesiteid='%8x'", dive->dive_site->uuid);