diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2016-04-24 21:11:15 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-25 09:07:34 -0700 |
commit | 375f698c78aae5001a21eb0c19807b2aa2d62f2c (patch) | |
tree | dae69ca4db3951ea234b28468cbea3f84812d8f0 /desktop-widgets/divelogimportdialog.cpp | |
parent | 7a4fa510e9280c881cca27eb4dfafa11ea050130 (diff) | |
download | subsurface-375f698c78aae5001a21eb0c19807b2aa2d62f2c.tar.gz |
Detect pipe as field separator in CSV import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/divelogimportdialog.cpp')
-rw-r--r-- | desktop-widgets/divelogimportdialog.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp index 757cad59e..f53d734f2 100644 --- a/desktop-widgets/divelogimportdialog.cpp +++ b/desktop-widgets/divelogimportdialog.cpp @@ -347,7 +347,7 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia for (int i = 0; !CSVApps[i].name.isNull(); ++i) ui->knownImports->addItem(CSVApps[i].name); - ui->CSVSeparator->addItems( QStringList() << tr("Tab") << "," << ";"); + ui->CSVSeparator->addItems( QStringList() << tr("Tab") << "," << ";" << "|"); loadFileContents(-1, INITIAL); @@ -487,11 +487,14 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) int tabs = firstLine.count('\t'); int commas = firstLine.count(','); int semis = firstLine.count(';'); - if (tabs > commas && tabs > semis) + int pipes = firstLine.count('|'); + if (tabs > commas && tabs > semis && tabs > pipes) separator = "\t"; - else if (commas > tabs && commas > semis) + else if (commas > tabs && commas > semis && commas > pipes) separator = ","; - else if (semis > tabs && semis > commas) + else if (pipes > tabs && pipes > commas && pipes > semis) + separator = "|"; + else if (semis > tabs && semis > commas && semis > pipes) separator = ";"; if (ui->CSVSeparator->currentText() != separator) { blockSignals(true); |