From 3ef5dbaacb6be129f3d4e7b72fcf86b95e5c8fa4 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Mon, 27 Jul 2015 16:13:29 +0300 Subject: Add hw info to Seabear import Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- qt-ui/divelogimportdialog.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'qt-ui/divelogimportdialog.cpp') diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index d799bf17f..24cb805bb 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -330,6 +330,7 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia fileNames = fn; column = 0; delta = "0"; + hw = ""; /* Add indexes of XSLTs requiring special handling to the list */ specialCSV << 3; @@ -392,8 +393,19 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) /* * Parse header - currently only interested in sample - * interval, or if we have old format (if interval value - * is missing from the header). + * interval and hardware version. If we have old format + * the interval value is missing from the header. + */ + + while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) { + if (firstLine.contains("//Hardware Version: ")) { + hw = firstLine.replace(QString::fromLatin1("//Hardware Version: "), QString::fromLatin1("\"Seabear ")).trimmed().append("\""); + break; + } + } + + /* + * Note that we scan over the "Log interval" on purpose */ while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) { @@ -624,7 +636,8 @@ void DiveLogImportDialog::on_buttonBox_accepted() ui->CSVSeparator->currentIndex(), "csv", ui->CSVUnits->currentIndex(), - delta.toUtf8().data() + delta.toUtf8().data(), + hw.toUtf8().data() ) < 0) { return; } -- cgit v1.2.3-70-g09d2