summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/divelogimportdialog.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-03 15:12:22 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit82af1b2377cec03a989f86b8009d4ac226c6541e (patch)
treea875f194f7174c8673b2f7bd5cc43aa8ca3c51c6 /desktop-widgets/divelogimportdialog.cpp
parent37146c5742503becf75468fb07aab56011cb9101 (diff)
downloadsubsurface-82af1b2377cec03a989f86b8009d4ac226c6541e.tar.gz
Undo: make undo-system dive site-aware
As opposed to dive trips, dive sites were always directly added to the global table, even on import. Instead, parse the divesites into a distinct table and merge them on import. Currently, this does not do any merging of dive sites, i.e. dive sites are considered as either equal or different. Nevertheless, merging of data should be rather easy to implement and simply follow the code of the dive merging. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divelogimportdialog.cpp')
-rw-r--r--desktop-widgets/divelogimportdialog.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp
index f1e616514..0bbb0dcb5 100644
--- a/desktop-widgets/divelogimportdialog.cpp
+++ b/desktop-widgets/divelogimportdialog.cpp
@@ -901,14 +901,15 @@ void DiveLogImportDialog::on_buttonBox_accepted()
{
struct dive_table table = { 0 };
struct trip_table trips = { 0 };
+ struct dive_site_table sites = { 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, &trips, &dive_site_table);
+ parse_seabear_log(qPrintable(fileNames[i]), &table, &trips, &sites);
} else if (ui->knownImports->currentText() == "Poseidon MkVI") {
QPair<QString, QString> pair = poseidonFileNames(fileNames[i]);
- parse_txt_file(qPrintable(pair.second), qPrintable(pair.first), &table, &trips, &dive_site_table);
+ parse_txt_file(qPrintable(pair.second), qPrintable(pair.first), &table, &trips, &sites);
} else {
char *params[49];
int pnr = 0;
@@ -925,7 +926,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, &trips, &dive_site_table);
+ &table, &trips, &sites);
}
}
} else {
@@ -989,7 +990,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, &trips, &dive_site_table);
+ parse_manual_file(qPrintable(fileNames[i]), params, pnr - 1, &table, &trips, &sites);
} else {
char *params[51];
int pnr = 0;
@@ -1006,13 +1007,13 @@ 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, &trips, &dive_site_table);
+ &table, &trips, &sites);
}
}
}
QString source = fileNames.size() == 1 ? fileNames[0] : tr("multiple files");
- Command::importDives(&table, &trips, IMPORT_MERGE_ALL_TRIPS, source);
+ Command::importDives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS, source);
}
TagDragDelegate::TagDragDelegate(QObject *parent) : QStyledItemDelegate(parent)