summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-12-23 12:46:45 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-09 20:58:04 -0800
commit1593f2ebad25244fefabe606b32ee505d4d6087d (patch)
treea47251b4247cbe0c2b5b2fa568179f8abc4c25f9 /desktop-widgets
parentf542dc4030dda5dac1da1cc928f7a40a50919c4d (diff)
downloadsubsurface-1593f2ebad25244fefabe606b32ee505d4d6087d.tar.gz
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>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/divelogimportdialog.cpp13
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp3
-rw-r--r--desktop-widgets/mainwindow.cpp5
-rw-r--r--desktop-widgets/subsurfacewebservices.cpp5
4 files changed, 15 insertions, 11 deletions
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp
index 09bb6c535..251f87587 100644
--- a/desktop-widgets/divelogimportdialog.cpp
+++ b/desktop-widgets/divelogimportdialog.cpp
@@ -900,14 +900,15 @@ int DiveLogImportDialog::parseTxtHeader(QString fileName, char **params, int pnr
void DiveLogImportDialog::on_buttonBox_accepted()
{
struct dive_table table = { 0 };
+ struct trip_table trips = { 0 };
QStringList r = resultModel->result();
if (ui->knownImports->currentText() != "Manual import") {
for (int i = 0; i < fileNames.size(); ++i) {
if (ui->knownImports->currentText() == "Seabear CSV") {
- parse_seabear_log(qPrintable(fileNames[i]), &table, &trip_table);
+ parse_seabear_log(qPrintable(fileNames[i]), &table, &trips);
} else if (ui->knownImports->currentText() == "Poseidon MkVI") {
QPair<QString, QString> pair = poseidonFileNames(fileNames[i]);
- parse_txt_file(qPrintable(pair.second), qPrintable(pair.first), &table, &trip_table);
+ parse_txt_file(qPrintable(pair.second), qPrintable(pair.first), &table, &trips);
} else {
char *params[49];
int pnr = 0;
@@ -924,7 +925,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
pnr = setup_csv_params(r, params, pnr);
parse_csv_file(qPrintable(fileNames[i]), params, pnr - 1,
specialCSV.contains(ui->knownImports->currentIndex()) ? qPrintable(CSVApps[ui->knownImports->currentIndex()].name) : "csv",
- &table, &trip_table);
+ &table, &trips);
}
}
} else {
@@ -988,7 +989,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
params[pnr++] = intdup(r.indexOf(tr("Rating")));
params[pnr++] = NULL;
- parse_manual_file(qPrintable(fileNames[i]), params, pnr - 1, &table, &trip_table);
+ parse_manual_file(qPrintable(fileNames[i]), params, pnr - 1, &table, &trips);
} else {
char *params[51];
int pnr = 0;
@@ -1005,12 +1006,12 @@ void DiveLogImportDialog::on_buttonBox_accepted()
pnr = setup_csv_params(r, params, pnr);
parse_csv_file(qPrintable(fileNames[i]), params, pnr - 1,
specialCSV.contains(ui->knownImports->currentIndex()) ? qPrintable(CSVApps[ui->knownImports->currentIndex()].name) : "csv",
- &table, &trip_table);
+ &table, &trips);
}
}
}
- process_imported_dives(&table, false, false);
+ process_imported_dives(&table, &trips, false, false);
Command::clear();
MainWindow::instance()->refreshDisplay();
}
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index 4e4c6a43c..601c0d0d4 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -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
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index d195eb5ad..107590de4 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -1708,12 +1708,13 @@ void MainWindow::importFiles(const QStringList fileNames)
QByteArray fileNamePtr;
struct dive_table table = { 0 };
+ struct trip_table trips = { 0 };
for (int i = 0; i < fileNames.size(); ++i) {
fileNamePtr = QFile::encodeName(fileNames.at(i));
- parse_file(fileNamePtr.data(), &table, &trip_table);
+ parse_file(fileNamePtr.data(), &table, &trips);
}
- process_imported_dives(&table, false, false);
+ process_imported_dives(&table, &trips, false, false);
Command::clear();
refreshDisplay();
}
diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp
index ecc664364..3e366db58 100644
--- a/desktop-widgets/subsurfacewebservices.cpp
+++ b/desktop-widgets/subsurfacewebservices.cpp
@@ -769,8 +769,9 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton *button)
}
/* parse file and import dives */
struct dive_table table = { 0 };
- parse_file(QFile::encodeName(zipFile.fileName()), &table, &trip_table);
- process_imported_dives(&table, false, false);
+ struct trip_table trips = { 0 };
+ parse_file(QFile::encodeName(zipFile.fileName()), &table, &trips);
+ process_imported_dives(&table, &trips, false, false);
MainWindow::instance()->refreshDisplay();
/* store last entered user/pass in config */