summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2016-01-31 14:37:57 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-26 09:23:10 +0100
commit3c83b2218b1e6806427f06585ed3fab2f5ee3641 (patch)
tree31357efa356cc618d7f8e82ada405edb50185a88 /qt-ui
parent9bd9850688cda49fdda8850060091ff4ed2a7a4b (diff)
downloadsubsurface-3c83b2218b1e6806427f06585ed3fab2f5ee3641.tar.gz
Attempt to detect date format on CSV import
This tries to detect the date format when initially reading a CSV file for importing. 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.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 025d181d1..e6b3b9a5c 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -493,8 +493,14 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
}
}
if (triggeredBy == INITIAL || (triggeredBy == KNOWNTYPES && value == MANUAL) || triggeredBy == SEPARATOR) {
+ int count = -1;
+ QString line = f.readLine().trimmed();
+ QStringList columns;
+ if (line.length() > 0)
+ columns = line.split(separator);
// now try and guess the columns
Q_FOREACH (QString columnText, currColumns) {
+ count++;
/*
* We have to skip the conversion of 2 to ₂ for APD Log
* viewer as that would mess up the sensor numbering. We
@@ -513,6 +519,15 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
provider->removeRow(idx);
headers.append(foundHeading);
matchedSome = true;
+ if (foundHeading == QString::fromLatin1("Date") && columns.count() >= count) {
+ QString date = columns.at(count);
+ if (date.contains('-')) {
+ ui->DateFormat->setCurrentText("yyyy-mm-dd");
+
+ } else if (date.contains('/')) {
+ ui->DateFormat->setCurrentText("mm/dd/yyyy");
+ }
+ }
} else {
headers.append("");
}