Import: merge dives trip-wise

The old way of merging log-files was not well defined: Trips
were recognized as the same if and only if the first dives
started at the same instant. Later dives did not matter.

Change this to merge dives if they are overlapping.
Moreover, on parsing and download generate trips in a separate
trip-table.

This will be fundamental for undo of dive-import: Firstly, we
don't want to mix trips of imported and not-yet imported dives.
Secondly, by merging trip-wise, we can autogroup the dives
in the import-data to trips and merge these at once. This will
simplify the code to decide to which trip dives should be
autogrouped.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-12-23 12:46:45 +01:00 committed by Dirk Hohndel
parent f542dc4030
commit 1593f2ebad
13 changed files with 251 additions and 129 deletions

View file

@ -508,6 +508,7 @@ void DownloadFromDCWidget::on_ok_clicked()
if (currentState != DONE && currentState != ERROR)
return;
struct dive_table *table = thread.table();
struct trip_table *trips = thread.trips();
// delete non-selected dives
int total = table->nr;
@ -524,7 +525,7 @@ void DownloadFromDCWidget::on_ok_clicked()
// remember the last downloaded dive (on most dive computers this will be the chronologically
// first new dive) and select it again after processing all the dives
int uniqId = table->dives[table->nr - 1]->id;
process_imported_dives(table, preferDownloaded(), true);
process_imported_dives(table, trips, preferDownloaded(), true);
Command::clear();
// after process_imported_dives does any merging or resorting needed, we need
// to recreate the model for the dive list so we can select the newest dive