summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelogimportdialog.cpp
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-03-22 17:13:47 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-03-23 05:44:06 -0700
commit86ac7fdf47142d8ad26a27a36daa64a5ea435bdc (patch)
treef125a3b3e154e68c869422f48503b1a8fb5abced /qt-ui/divelogimportdialog.cpp
parentcb49c37b31fcebb3a1ba97b0a804d398ae0df22d (diff)
downloadsubsurface-86ac7fdf47142d8ad26a27a36daa64a5ea435bdc.tar.gz
Import support for new Seabear format
This add support for Seabear's new import format that is used by H3 and T1. In the future also the Hudc should switch to the new format. The main difference to the old one is that time stamps are no longer recorded in the samples, but intervali is specified in the header. The header contains other useful information as well that we should build support for. E.g. surface pressure, gas mixes, GF, and mode might be useful additions later on. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelogimportdialog.cpp')
-rw-r--r--qt-ui/divelogimportdialog.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 9697cbf46..cccafdabf 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -316,6 +316,7 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
ui->setupUi(this);
fileNames = fn;
column = 0;
+ delta = "0";
/* Add indexes of XSLTs requiring special handling to the list */
specialCSV << 3;
@@ -375,7 +376,53 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
QString firstLine = f.readLine();
if (firstLine.contains("SEABEAR")) {
seabear = true;
- firstLine = "Sample time;Sample depth;Sample NDL;Sample TTS;Sample stopdepth;Sample temperature;Sample pressure";
+
+ /*
+ * Parse header - currently only interested in sample
+ * interval, or if we have old format (if interval value
+ * is missing from the header).
+ */
+
+ while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) {
+ if (firstLine.contains("//Log interval: "))
+ delta = firstLine.remove(QString::fromLatin1("//Log interval: ")).trimmed();
+ }
+
+ /*
+ * Parse CSV fields
+ * The pO2 values from CCR diving are ignored later on.
+ */
+
+ firstLine = f.readLine().trimmed();
+
+ currColumns = firstLine.split(';');
+ Q_FOREACH (QString columnText, currColumns) {
+ if (columnText == "Time") {
+ headers.append("Sample time");
+ } else if (columnText == "Depth") {
+ headers.append("Sample depth");
+ } else if (columnText == "Temperature") {
+ headers.append("Sample temperature");
+ } else if (columnText == "NDT") {
+ headers.append("Sample NDL");
+ } else if (columnText == "TTS") {
+ headers.append("Sample TTS");
+ } else if (columnText == "pO2_1") {
+ headers.append("Sample pO2_1");
+ } else if (columnText == "pO2_2") {
+ headers.append("Sample pO2_2");
+ } else if (columnText == "pO2_3") {
+ headers.append("Sample pO2_3");
+ } else if (columnText == "Ceiling") {
+ headers.append("Sample ceiling");
+ } else {
+ // We do not know about this value
+ qDebug() << "Seabear import found an un-handled field: " << columnText;
+ headers.append("");
+ }
+ }
+
+ firstLine = headers.join(";");
blockSignals(true);
ui->knownImports->setCurrentText("Seabear CSV");
blockSignals(false);
@@ -543,7 +590,8 @@ void DiveLogImportDialog::on_buttonBox_accepted()
r.indexOf(tr("Sample pressure")),
ui->CSVSeparator->currentIndex(),
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
- ui->CSVUnits->currentIndex()
+ ui->CSVUnits->currentIndex(),
+ delta.toUtf8().data()
) < 0)
return;