core: remove autogroup global

Use the flag in the divelog structure, since this will be saved
in the dive log.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-11-12 09:14:00 +01:00 committed by bstoeger
parent aa34afc3f7
commit b61732da42
10 changed files with 23 additions and 29 deletions

View file

@ -110,8 +110,6 @@ extern int mbar_to_depth(int mbar, const struct dive *dive);
extern depth_t gas_mod(struct gasmix mix, pressure_t po2_limit, const struct dive *dive, int roundto);
extern depth_t gas_mnd(struct gasmix mix, depth_t end, const struct dive *dive, int roundto);
extern bool autogroup;
extern struct dive displayed_dive;
extern unsigned int dc_number;
extern struct dive *current_dive;
@ -208,7 +206,6 @@ extern bool cylinder_with_sensor_sample(const struct dive *dive, int cylinder_id
extern void invalidate_dive_cache(struct dive *dc);
extern void set_autogroup(bool value);
extern int total_weight(const struct dive *);
extern const char *existing_filename;

View file

@ -22,15 +22,6 @@
#include "table.h"
#include "trip.h"
bool autogroup = false;
void set_autogroup(bool value)
{
/* if we keep the UI paradigm, this needs to toggle
* the checkbox on the autogroup menu item */
autogroup = value;
}
/*
* Get "maximal" dive gas for a dive.
* Rules:
@ -724,7 +715,7 @@ static void autogroup_dives(struct dive_table *table, struct trip_table *trip_ta
int i, j;
bool alloc;
if (!autogroup)
if (!divelog.autogroup)
return;
for (i = 0; (trip = get_dives_to_autogroup(table, i, &from, &to, &alloc)) != NULL; i = to) {

View file

@ -901,12 +901,11 @@ static void parse_trip_location(char *line, struct membuffer *str, struct git_pa
static void parse_trip_notes(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_trip->notes = detach_cstring(str); }
static void parse_settings_autogroup(char *line, struct membuffer *str, struct git_parser_state *_unused)
static void parse_settings_autogroup(char *line, struct membuffer *str, struct git_parser_state *state)
{
UNUSED(line);
UNUSED(str);
UNUSED(_unused);
set_autogroup(true);
state->log->autogroup = true;
}
static void parse_settings_units(char *line, struct membuffer *str, struct git_parser_state *unused)

View file

@ -690,13 +690,13 @@ static void eventtime(char *buffer, duration_t *duration, struct parser_state *s
duration->seconds += state->cur_sample->time.seconds;
}
static void try_to_match_autogroup(const char *name, char *buf)
static void try_to_match_autogroup(const char *name, char *buf, struct parser_state *state)
{
bool autogroupvalue;
bool autogroup;
start_match("autogroup", name, buf);
if (MATCH("state.autogroup", get_bool, &autogroupvalue)) {
set_autogroup(autogroupvalue);
if (MATCH("state.autogroup", get_bool, &autogroup)) {
state->log->autogroup = autogroup;
return;
}
nonmatch("autogroup", name, buf);
@ -1503,7 +1503,7 @@ static bool entry(const char *name, char *buf, struct parser_state *state)
if (state->in_settings) {
try_to_fill_fingerprint(name, buf, state);
try_to_fill_dc_settings(name, buf, state);
try_to_match_autogroup(name, buf);
try_to_match_autogroup(name, buf, state);
return true;
}
if (state->cur_dive_site) {

View file

@ -890,7 +890,7 @@ static void save_settings(git_repository *repo, struct dir *tree)
for (unsigned int i = 0; i < nr_fingerprints(&fingerprint_table); i++)
save_one_fingerprint(&b, i);
cond_put_format(autogroup, &b, "autogroup\n");
cond_put_format(divelog.autogroup, &b, "autogroup\n");
save_units(&b);
if (prefs.tankbar)
put_string(&b, "prefs TANKBAR\n");

View file

@ -692,7 +692,7 @@ static void save_dives_buffer(struct membuffer *b, bool select_only, bool anonym
for (int i = 0; i < nr_fingerprints(&fingerprint_table); i++)
save_one_fingerprint(b, i);
if (autogroup)
if (divelog.autogroup)
put_format(b, " <autogroup state='1' />\n");
put_format(b, "</settings>\n");