aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-01-22 11:33:09 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-22 21:48:44 +1200
commitc1f716614f92ad078e3e0cac60eb86627d2033ab (patch)
treeac7cefd9ff9145be8e81e6c0a950700c056d2760 /qt-ui
parentcbab6cc9c80cb51bd11043d0ab210a0d2b4744f6 (diff)
downloadsubsurface-c1f716614f92ad078e3e0cac60eb86627d2033ab.tar.gz
Special handling of Seaber CSV files
These files contain a bit of extra data before the actual CSV part, so we need to skip there to show sensible information to users. 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.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 681241a72..f275f2f79 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -359,6 +359,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
QStringList currColumns;
QStringList headers;
bool matchedSome = false;
+ bool seabear = false;
// reset everything
ColumnNameProvider *provider = new ColumnNameProvider(this);
@@ -369,6 +370,10 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
f.open(QFile::ReadOnly);
QString firstLine = f.readLine();
+ if (firstLine.contains("SEABEAR")) {
+ seabear = true;
+ firstLine = "Time;Depth;NDT;TTS;Ceiling;Temperature;Pressure";
+ }
QString separator = ui->CSVSeparator->currentText() == tr("Tab") ? "\t" : ui->CSVSeparator->currentText();
currColumns = firstLine.split(separator);
if (triggeredBy == INITIAL) {
@@ -449,6 +454,23 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
f.reset();
int rows = 0;
+
+ /* Skipping the header of Seabear CSV file. */
+ if (seabear) {
+ /*
+ * First set of data on Seabear CSV file is metadata
+ * that is separated by an empty line (windows line
+ * termination might be encountered.
+ */
+ while (strlen(f.readLine()) > 2 && !f.atEnd());
+ /*
+ * Next we have description of the fields and two dummy
+ * lines. Separated again with an empty line from the
+ * actual data.
+ */
+ while (strlen(f.readLine()) > 2 && !f.atEnd());
+ }
+
while (rows < 10 || !f.atEnd()) {
QString currLine = f.readLine();
currColumns = currLine.split(separator);