mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add special download modes to force updates from the divecomputer
This will hopefully not be something we need often, but if we improve support for a divecomputer (either in libdivecomputer or in our native Uemis code or even in the way we handle (and potentially discard) events), then it is extremely useful to be able to say "re-download things from the divecomputer and for things that were not edited in Subsurface, don't try to merge the data (which gives BAD results if for example you fixed a bug in the depth calculation in libdivecomputer) but instead simply take the samples, the events and some of the other unedited data straight from the download". This commit implements just that - a "force download" checkbox in the download dialog that makes us reimport all dives from the dive computer, even the ones we already have, and an "always prefer downloaded dive" checkbox that then tells Subsurface not to merge but simply to take the data from the downloaded dive - without overwriting the things we have already edited in Subsurface (like location, buddy, equipment, etc). This, as a precaution, refuses to merge dives that don't have identical start times. So if you have edited the date / time of a dive or if you have previously merged your dive with a different dive computer (and therefore modified samples and events) you are out of luck. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
78ad07c72e
commit
fe4f13f184
9 changed files with 90 additions and 35 deletions
11
main.c
11
main.c
|
@ -111,7 +111,7 @@ static gboolean imported = FALSE;
|
|||
* This doesn't really report anything at all. We just sort the
|
||||
* dives, the GUI does the reporting
|
||||
*/
|
||||
void report_dives(gboolean is_imported)
|
||||
void report_dives(gboolean is_imported, gboolean prefer_imported)
|
||||
{
|
||||
int i;
|
||||
int preexisting = dive_table.preexisting;
|
||||
|
@ -131,7 +131,7 @@ void report_dives(gboolean is_imported)
|
|||
if (prev->when + prev->duration.seconds < dive->when)
|
||||
continue;
|
||||
|
||||
merged = try_to_merge(prev, dive);
|
||||
merged = try_to_merge(prev, dive, prefer_imported);
|
||||
if (!merged)
|
||||
continue;
|
||||
|
||||
|
@ -145,6 +145,9 @@ void report_dives(gboolean is_imported)
|
|||
delete_single_dive(i+1);
|
||||
delete_single_dive(i+1);
|
||||
}
|
||||
/* make sure no dives are still marked as downloaded */
|
||||
for (i = 1; i < dive_table.nr; i++)
|
||||
dive_table.dives[i]->downloaded = FALSE;
|
||||
|
||||
if (is_imported) {
|
||||
/* Was the previous dive table state numbered? */
|
||||
|
@ -173,7 +176,7 @@ static void parse_argument(const char *arg)
|
|||
if (strcmp(arg,"--import") == 0) {
|
||||
/* mark the dives so far as the base,
|
||||
* everything after is imported */
|
||||
report_dives(FALSE);
|
||||
report_dives(FALSE, FALSE);
|
||||
imported = TRUE;
|
||||
return;
|
||||
}
|
||||
|
@ -276,7 +279,7 @@ int main(int argc, char **argv)
|
|||
set_filename(filename, FALSE);
|
||||
free((void *)filename);
|
||||
}
|
||||
report_dives(imported);
|
||||
report_dives(imported, FALSE);
|
||||
if (dive_table.nr == 0)
|
||||
show_dive_info(NULL);
|
||||
run_ui();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue