[PATCH 06/12] Basic GUI part for DL7 import

Miika Turkia miika.turkia at gmail.com
Sun Apr 24 11:11:19 PDT 2016


This sets the basic properties properly but is still missing the parsing
of meta-data, especially used units.

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 desktop-widgets/divelogimportdialog.cpp | 18 +++++++++++++++++-
 desktop-widgets/divelogimportdialog.h   |  2 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp
index f53d734..e70a752 100644
--- a/desktop-widgets/divelogimportdialog.cpp
+++ b/desktop-widgets/divelogimportdialog.cpp
@@ -17,6 +17,7 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
 	{ "Manual import", SILENCE_WARNING },
 	{ "APD Log Viewer - DC1", 0, 1, 15, 6, 3, 4, 5, 17, -1, -1, 18, -1, 2, "Tab" },
 	{ "APD Log Viewer - DC2", 0, 1, 15, 6, 7, 8, 9, 17, -1, -1, 18, -1, 2, "Tab" },
+	{ "DAN DL7", 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "|" },
 	{ "XP5", 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Tab" },
 	{ "SensusCSV", 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "," },
 	{ "Seabear CSV", 0, 1, 5, -1, -1, -1, -1, -1, 2, 3, 4, 6, -1, ";" },
@@ -28,6 +29,7 @@ enum Known {
 	MANUAL,
 	APD,
 	APD2,
+	DL7,
 	XP5,
 	SENSUS,
 	SEABEAR,
@@ -386,6 +388,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 	bool seabear = false;
 	bool xp5 = false;
 	bool apd = false;
+	bool dl7 = false;
 
 	// reset everything
 	ColumnNameProvider *provider = new ColumnNameProvider(this);
@@ -467,6 +470,12 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 		blockSignals(true);
 		ui->knownImports->setCurrentText("XP5");
 		blockSignals(false);
+	} else if (firstLine.contains("FSH")) {
+		dl7 = true;
+		firstLine = "|Sample time|Sample depth||||||||";
+		blockSignals(true);
+		ui->knownImports->setCurrentText("DAN DL7");
+		blockSignals(false);
 	}
 
 	// Special handling for APD Log Viewer
@@ -551,7 +560,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 		}
 		if (matchedSome) {
 			ui->dragInstructions->setText(tr("Some column headers were pre-populated; please drag and drop the headers so they match the column they are in."));
-			if (triggeredBy != KNOWNTYPES && !seabear && !xp5 && !apd) {
+			if (triggeredBy != KNOWNTYPES && !seabear && !xp5 && !apd && !dl7) {
 				blockSignals(true);
 				ui->knownImports->setCurrentIndex(0); // <- that's "Manual import"
 				blockSignals(false);
@@ -665,6 +674,13 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
 		 * actual data.
 		 */
 		while (strlen(f.readLine()) > 3 && !f.atEnd());
+	} else if (dl7) {
+		while ((firstLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
+			if (firstLine.contains("ZDP")) {
+				firstLine = f.readLine().trimmed();
+				break;
+			}
+		}
 	}
 
 	while (rows < 10 && !f.atEnd()) {
diff --git a/desktop-widgets/divelogimportdialog.h b/desktop-widgets/divelogimportdialog.h
index 8117753..750bc10 100644
--- a/desktop-widgets/divelogimportdialog.h
+++ b/desktop-widgets/divelogimportdialog.h
@@ -116,7 +116,7 @@ private:
 		QString separator;
 	};
 
-#define CSVAPPS 8
+#define CSVAPPS 9
 	static const CSVAppConfig CSVApps[CSVAPPS];
 };
 
-- 
2.5.0



More information about the subsurface mailing list