mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
aa34afc3f7
commit
b61732da42
10 changed files with 23 additions and 29 deletions
|
@ -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_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 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 struct dive displayed_dive;
|
||||||
extern unsigned int dc_number;
|
extern unsigned int dc_number;
|
||||||
extern struct dive *current_dive;
|
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 invalidate_dive_cache(struct dive *dc);
|
||||||
|
|
||||||
extern void set_autogroup(bool value);
|
|
||||||
extern int total_weight(const struct dive *);
|
extern int total_weight(const struct dive *);
|
||||||
|
|
||||||
extern const char *existing_filename;
|
extern const char *existing_filename;
|
||||||
|
|
|
@ -22,15 +22,6 @@
|
||||||
#include "table.h"
|
#include "table.h"
|
||||||
#include "trip.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.
|
* Get "maximal" dive gas for a dive.
|
||||||
* Rules:
|
* Rules:
|
||||||
|
@ -724,7 +715,7 @@ static void autogroup_dives(struct dive_table *table, struct trip_table *trip_ta
|
||||||
int i, j;
|
int i, j;
|
||||||
bool alloc;
|
bool alloc;
|
||||||
|
|
||||||
if (!autogroup)
|
if (!divelog.autogroup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; (trip = get_dives_to_autogroup(table, i, &from, &to, &alloc)) != NULL; i = to) {
|
for (i = 0; (trip = get_dives_to_autogroup(table, i, &from, &to, &alloc)) != NULL; i = to) {
|
||||||
|
|
|
@ -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)
|
static void parse_trip_notes(char *line, struct membuffer *str, struct git_parser_state *state)
|
||||||
{ UNUSED(line); state->active_trip->notes = detach_cstring(str); }
|
{ 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(line);
|
||||||
UNUSED(str);
|
UNUSED(str);
|
||||||
UNUSED(_unused);
|
state->log->autogroup = true;
|
||||||
set_autogroup(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_settings_units(char *line, struct membuffer *str, struct git_parser_state *unused)
|
static void parse_settings_units(char *line, struct membuffer *str, struct git_parser_state *unused)
|
||||||
|
|
|
@ -690,13 +690,13 @@ static void eventtime(char *buffer, duration_t *duration, struct parser_state *s
|
||||||
duration->seconds += state->cur_sample->time.seconds;
|
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);
|
start_match("autogroup", name, buf);
|
||||||
if (MATCH("state.autogroup", get_bool, &autogroupvalue)) {
|
if (MATCH("state.autogroup", get_bool, &autogroup)) {
|
||||||
set_autogroup(autogroupvalue);
|
state->log->autogroup = autogroup;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nonmatch("autogroup", name, buf);
|
nonmatch("autogroup", name, buf);
|
||||||
|
@ -1503,7 +1503,7 @@ static bool entry(const char *name, char *buf, struct parser_state *state)
|
||||||
if (state->in_settings) {
|
if (state->in_settings) {
|
||||||
try_to_fill_fingerprint(name, buf, state);
|
try_to_fill_fingerprint(name, buf, state);
|
||||||
try_to_fill_dc_settings(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;
|
return true;
|
||||||
}
|
}
|
||||||
if (state->cur_dive_site) {
|
if (state->cur_dive_site) {
|
||||||
|
|
|
@ -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++)
|
for (unsigned int i = 0; i < nr_fingerprints(&fingerprint_table); i++)
|
||||||
save_one_fingerprint(&b, i);
|
save_one_fingerprint(&b, i);
|
||||||
|
|
||||||
cond_put_format(autogroup, &b, "autogroup\n");
|
cond_put_format(divelog.autogroup, &b, "autogroup\n");
|
||||||
save_units(&b);
|
save_units(&b);
|
||||||
if (prefs.tankbar)
|
if (prefs.tankbar)
|
||||||
put_string(&b, "prefs TANKBAR\n");
|
put_string(&b, "prefs TANKBAR\n");
|
||||||
|
|
|
@ -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++)
|
for (int i = 0; i < nr_fingerprints(&fingerprint_table); i++)
|
||||||
save_one_fingerprint(b, i);
|
save_one_fingerprint(b, i);
|
||||||
|
|
||||||
if (autogroup)
|
if (divelog.autogroup)
|
||||||
put_format(b, " <autogroup state='1' />\n");
|
put_format(b, " <autogroup state='1' />\n");
|
||||||
put_format(b, "</settings>\n");
|
put_format(b, "</settings>\n");
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,11 @@ void MainWindow::refreshDisplay()
|
||||||
setApplicationState(ApplicationState::Default);
|
setApplicationState(ApplicationState::Default);
|
||||||
diveList->setEnabled(true);
|
diveList->setEnabled(true);
|
||||||
diveList->setFocus();
|
diveList->setFocus();
|
||||||
ui.actionAutoGroup->setChecked(autogroup);
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateAutogroup()
|
||||||
|
{
|
||||||
|
ui.actionAutoGroup->setChecked(divelog.autogroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::selectionChanged()
|
void MainWindow::selectionChanged()
|
||||||
|
@ -419,6 +423,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
|
||||||
process_loaded_dives();
|
process_loaded_dives();
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
refreshDisplay();
|
refreshDisplay();
|
||||||
|
updateAutogroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return whether saving to cloud is OK. If it isn't, show an error return false.
|
// Return whether saving to cloud is OK. If it isn't, show an error return false.
|
||||||
|
@ -695,7 +700,7 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
fake_dc(&d.dc);
|
fake_dc(&d.dc);
|
||||||
fixup_dive(&d);
|
fixup_dive(&d);
|
||||||
|
|
||||||
Command::addDive(&d, autogroup, true);
|
Command::addDive(&d, divelog.autogroup, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionRenumber_triggered()
|
void MainWindow::on_actionRenumber_triggered()
|
||||||
|
@ -706,8 +711,8 @@ void MainWindow::on_actionRenumber_triggered()
|
||||||
|
|
||||||
void MainWindow::on_actionAutoGroup_triggered()
|
void MainWindow::on_actionAutoGroup_triggered()
|
||||||
{
|
{
|
||||||
set_autogroup(ui.actionAutoGroup->isChecked());
|
divelog.autogroup = ui.actionAutoGroup->isChecked();
|
||||||
if (autogroup)
|
if (divelog.autogroup)
|
||||||
Command::autogroupDives();
|
Command::autogroupDives();
|
||||||
else
|
else
|
||||||
Command::removeAutogenTrips();
|
Command::removeAutogenTrips();
|
||||||
|
@ -1308,6 +1313,7 @@ void MainWindow::loadFiles(const QStringList fileNames)
|
||||||
process_loaded_dives();
|
process_loaded_dives();
|
||||||
|
|
||||||
refreshDisplay();
|
refreshDisplay();
|
||||||
|
updateAutogroup();
|
||||||
|
|
||||||
int min_datafile_version = get_min_datafile_version();
|
int min_datafile_version = get_min_datafile_version();
|
||||||
if (min_datafile_version >0 && min_datafile_version < DATAFORMAT_VERSION) {
|
if (min_datafile_version >0 && min_datafile_version < DATAFORMAT_VERSION) {
|
||||||
|
|
|
@ -189,6 +189,7 @@ private:
|
||||||
void hideProgressBar();
|
void hideProgressBar();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void refreshDisplay();
|
void refreshDisplay();
|
||||||
|
void updateAutogroup();
|
||||||
void showProfile();
|
void showProfile();
|
||||||
int file_save();
|
int file_save();
|
||||||
int file_save_as();
|
int file_save_as();
|
||||||
|
|
|
@ -1720,7 +1720,7 @@ int QMLManager::addDive()
|
||||||
// addDive takes over the dive and clears out the structure passed in
|
// addDive takes over the dive and clears out the structure passed in
|
||||||
// we do NOT save the modified data at this stage because of the UI flow here... this will
|
// we do NOT save the modified data at this stage because of the UI flow here... this will
|
||||||
// be saved once the user finishes editing the newly added dive
|
// be saved once the user finishes editing the newly added dive
|
||||||
Command::addDive(&d, autogroup, true);
|
Command::addDive(&d, divelog.autogroup, true);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
appendTextToLog(QString("Adding new dive with id '%1'").arg(diveId));
|
appendTextToLog(QString("Adding new dive with id '%1'").arg(diveId));
|
||||||
|
|
|
@ -1338,7 +1338,7 @@ void DivePlannerPointsModel::createPlan(bool replanCopy)
|
||||||
// we were planning a new dive, not re-planning an existing one
|
// we were planning a new dive, not re-planning an existing one
|
||||||
d->divetrip = nullptr; // Should not be necessary, just in case!
|
d->divetrip = nullptr; // Should not be necessary, just in case!
|
||||||
#if !defined(SUBSURFACE_TESTING)
|
#if !defined(SUBSURFACE_TESTING)
|
||||||
Command::addDive(d, autogroup, true);
|
Command::addDive(d, divelog.autogroup, true);
|
||||||
#endif // !SUBSURFACE_TESTING
|
#endif // !SUBSURFACE_TESTING
|
||||||
} else {
|
} else {
|
||||||
copy_events_until(current_dive, d, preserved_until.seconds);
|
copy_events_until(current_dive, d, preserved_until.seconds);
|
||||||
|
|
Loading…
Add table
Reference in a new issue