From c1f716614f92ad078e3e0cac60eb86627d2033ab Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Thu, 22 Jan 2015 11:33:09 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/divelogimportdialog.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'qt-ui') 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); -- cgit v1.2.3-70-g09d2