mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Store the tag names instead of an opaque number
And as we need the names for that, simplify the way we show the tags in the Dive Info tab (and mark them for translation while we are at it). In the process I renamed the constants to DTAG_ from DTYPE_ (and made their nature as being just bits more obvious). Also mark the box on the Info tab "Dive Tags", not "Dive Type". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ed3f67bc33
commit
9e4f9fad19
6 changed files with 100 additions and 68 deletions
25
parse-xml.c
25
parse-xml.c
|
@ -200,6 +200,29 @@ static void divedatetime(char *buffer, void *_when)
|
|||
}
|
||||
}
|
||||
|
||||
static void divetags(char *buffer, void *_tags)
|
||||
{
|
||||
int *tags = _tags;
|
||||
int i;
|
||||
|
||||
*tags = 0;
|
||||
for (i = 0; i < DTAG_NR; i++) {
|
||||
if (strstr(buffer, dtag_names[i])) {
|
||||
/* stupidly we have 'cave' and 'cavern' */
|
||||
if (1 << i == DTAG_CAVE) {
|
||||
char *cave = strstr(buffer, "cave");
|
||||
while (cave && !strncmp(cave, "cavern", strlen("cavern"))) {
|
||||
cave++;
|
||||
cave = strstr(cave, "cave");
|
||||
}
|
||||
if (!cave)
|
||||
continue;
|
||||
}
|
||||
*tags |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum number_type {
|
||||
NEITHER,
|
||||
FLOAT
|
||||
|
@ -1033,7 +1056,7 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
|
|||
|
||||
if (MATCH(".number", get_index, &dive->number))
|
||||
return;
|
||||
if (MATCH(".tags", get_index, &dive->dive_tags))
|
||||
if (MATCH(".tags", divetags, &dive->dive_tags))
|
||||
return;
|
||||
if (MATCH(".tripflag", get_tripflag, &dive->tripflag))
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue