diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2016-09-24 08:52:39 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-09-24 08:29:34 -0700 |
commit | 2b14a9c95d6179fb4cff352dc20036594c8a5aff (patch) | |
tree | c76751063f2df39bcbba9492c567539fd791e085 /desktop-widgets | |
parent | 71273945c69b8c19f2ef298148d74ed70358c52e (diff) | |
download | subsurface-2b14a9c95d6179fb4cff352dc20036594c8a5aff.tar.gz |
Support for comma as field separator for ADP
This adds support for comma as field separator for ADP import.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/divelogimportdialog.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp index 0a964b003..79a01e25f 100644 --- a/desktop-widgets/divelogimportdialog.cpp +++ b/desktop-widgets/divelogimportdialog.cpp @@ -507,10 +507,19 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) // Special handling for APD Log Viewer if ((triggeredBy == KNOWNTYPES && (value == APD || value == APD2)) || (triggeredBy == INITIAL && fileNames.first().endsWith(".apd", Qt::CaseInsensitive))) { + QString apdseparator; + int tabs = firstLine.count('\t'); + int commas = firstLine.count(','); + if (tabs > commas) + apdseparator = "\t"; + else + apdseparator = ","; + apd=true; - firstLine = "Sample time\tSample depth\tSample setpoint\tSample sensor1 pO₂\tSample sensor2 pO₂\tSample sensor3 pO₂\tSample pO₂\t\t\t\t\t\t\t\t\tSample temperature\t\tSample CNS\tSample stopdepth"; + + firstLine = "Sample time" + apdseparator + "Sample depth" + apdseparator + "Sample setpoint" + apdseparator + "Sample sensor1 pO₂" + apdseparator + "Sample sensor2 pO₂" + apdseparator + "Sample sensor3 pO₂" + apdseparator + "Sample pO₂" + apdseparator + "" + apdseparator + "" + apdseparator + "" + apdseparator + "" + apdseparator + "" + apdseparator + "" + apdseparator + "" + apdseparator + "" + apdseparator + "Sample temperature" + apdseparator + "" + apdseparator + "Sample CNS" + apdseparator + "Sample stopdepth"; blockSignals(true); - ui->CSVSeparator->setCurrentText(tr("Tab")); + ui->CSVSeparator->setCurrentText(apdseparator); if (triggeredBy == INITIAL && fileNames.first().contains(".apd", Qt::CaseInsensitive)) ui->knownImports->setCurrentText("APD Log Viewer - DC1"); blockSignals(false); @@ -596,7 +605,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) } if (triggeredBy == KNOWNTYPES && value != MANUAL) { // an actual known type - if (value == SUBSURFACE) { + if (value == SUBSURFACE || value == APD || value == APD2) { /* * Subsurface CSV file needs separator detection * as we used to default to comma but switched |