summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-01-24 17:03:15 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-24 14:50:51 -0800
commitfb367b22b09b9b1a4bf82fd2fd7b36c0fffa95ee (patch)
tree195898560c10369fee65b06b6b02699209daba0b /qt-ui
parentb8d02b4b27a6225aaacb1a9cf43f162053185290 (diff)
downloadsubsurface-fb367b22b09b9b1a4bf82fd2fd7b36c0fffa95ee.tar.gz
Switch Subsurface CSV import to use tab separator
As changing the export to use tabs, we need to switch the import to do that as well. However, we also need to support comma separation as older exports use that. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelogimportdialog.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 0f060b3ee..ecd09bc57 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -16,7 +16,7 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
{ "XP5", 0, 1, 9, -1, -1, -1, -1, -1, -1, "Tab" },
{ "SensusCSV", 9, 10, -1, -1, -1, -1, -1, -1, -1, "," },
{ "Seabear CSV", 0, 1, 5, -1, -1, 2, 3, 4, 6, ";" },
- { "SubsurfaceCSV", -1, -1, -1, -1, -1, -1, -1, -1, -1, "," },
+ { "SubsurfaceCSV", -1, -1, -1, -1, -1, -1, -1, -1, -1, "Tab" },
{ NULL, }
};
@@ -440,7 +440,21 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
}
if (triggeredBy == KNOWNTYPES && value != 0) {
// an actual known type
- separator = CSVApps[value].separator;
+ if (value == 5) {
+ /*
+ * Subsurface CSV file needs separator detection
+ * as we used to default to comma but switched
+ * to tab.
+ */
+ int tabs = firstLine.count('\t');
+ int commas = firstLine.count(',');
+ if (tabs > commas)
+ separator = "Tab";
+ else
+ separator = ",";
+ } else {
+ separator = CSVApps[value].separator;
+ }
if (ui->CSVSeparator->currentText() != separator || separator == "Tab") {
ui->CSVSeparator->blockSignals(true);