summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelogimportdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/divelogimportdialog.cpp')
-rw-r--r--qt-ui/divelogimportdialog.cpp53
1 files changed, 37 insertions, 16 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index ea783b093..d799bf17f 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -13,7 +13,8 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
// time, depth, temperature, po2, sensor1, sensor2, sensor3, cns, ndl, tts, stopdepth, pressure, setpoint
// indices are 0 based, -1 means the column doesn't exist
{ "Manual import", },
- { "APD Log Viewer", 0, 1, 15, 6, 3, 4, 5, 17, -1, -1, 18, -1, 2, "Tab" },
+ { "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" },
{ "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, ";" },
@@ -21,6 +22,16 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
{ NULL, }
};
+static enum {
+ MANUAL,
+ APD,
+ APD2,
+ XP5,
+ SENSUS,
+ SEABEAR,
+ SUBSURFACE
+} known;
+
ColumnNameProvider::ColumnNameProvider(QObject *parent) : QAbstractListModel(parent)
{
columnNames << tr("Dive #") << tr("Date") << tr("Time") << tr("Duration") << tr("Location") << tr("GPS") << tr("Weight") << tr("Cyl. size") << tr("Start pressure") <<
@@ -387,7 +398,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) {
if (firstLine.contains("//Log interval: "))
- delta = firstLine.remove(QString::fromLatin1("//Log interval: ")).trimmed();
+ delta = firstLine.remove(QString::fromLatin1("//Log interval: ")).trimmed().remove(QString::fromLatin1(" s"));
}
/*
@@ -416,6 +427,8 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
headers.append("Sample sensor3 pO₂");
} else if (columnText == "Ceiling") {
headers.append("Sample ceiling");
+ } else if (columnText == "Tank pressure") {
+ headers.append("Sample pressure");
} else {
// We do not know about this value
qDebug() << "Seabear import found an un-handled field: " << columnText;
@@ -437,13 +450,13 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
}
// Special handling for APD Log Viewer
- if ((triggeredBy == KNOWNTYPES && value == 1) || (triggeredBy == INITIAL && fileNames.first().endsWith(".apd", Qt::CaseInsensitive))) {
+ if ((triggeredBy == KNOWNTYPES && (value == APD || value == APD2)) || (triggeredBy == INITIAL && fileNames.first().endsWith(".apd", Qt::CaseInsensitive))) {
apd=true;
- firstLine = "Sample time\tSample depth\tSample setpoint\t\t\t\tSample pO₂\t\t\t\t\t\t\t\t\tSample temperature\t\tSample CNS\tSample stopdepth";
+ firstLine = "Sample time\tSample depth\tSample setpoint\tSample sensor1 pO₂\tSample sensor2 pO₂\tSample sensor3 pO₂\tSample pO₂\t\t\t\t\t\t\t\t\tSample temperature\t\tSample CNS\tSample stopdepth";
blockSignals(true);
ui->CSVSeparator->setCurrentText(tr("Tab"));
if (triggeredBy == INITIAL && fileNames.first().contains(".apd", Qt::CaseInsensitive))
- ui->knownImports->setCurrentText("APD Log Viewer");
+ ui->knownImports->setCurrentText("APD Log Viewer - DC1");
blockSignals(false);
}
@@ -467,13 +480,21 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
currColumns = firstLine.split(separator);
}
}
- if (triggeredBy == INITIAL || (triggeredBy == KNOWNTYPES && value == 0) || triggeredBy == SEPARATOR) {
+ if (triggeredBy == INITIAL || (triggeredBy == KNOWNTYPES && value == MANUAL) || triggeredBy == SEPARATOR) {
// now try and guess the columns
Q_FOREACH (QString columnText, currColumns) {
- columnText.replace("\"", "");
- columnText.replace("number", "#", Qt::CaseInsensitive);
- columnText.replace("2", "₂", Qt::CaseInsensitive);
- columnText.replace("cylinder", "cyl.", Qt::CaseInsensitive);
+ /*
+ * We have to skip the conversion of 2 to ₂ for APD Log
+ * viewer as that would mess up the sensor numbering. We
+ * also know that the column headers do not need this
+ * conversion.
+ */
+ if (triggeredBy == KNOWNTYPES && value != APD) {
+ columnText.replace("\"", "");
+ columnText.replace("number", "#", Qt::CaseInsensitive);
+ columnText.replace("2", "₂", Qt::CaseInsensitive);
+ columnText.replace("cylinder", "cyl.", Qt::CaseInsensitive);
+ }
int idx = provider->mymatch(columnText);
if (idx >= 0) {
QString foundHeading = provider->data(provider->index(idx, 0), Qt::DisplayRole).toString();
@@ -493,9 +514,9 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
}
}
}
- if (triggeredBy == KNOWNTYPES && value != 0) {
+ if (triggeredBy == KNOWNTYPES && value != MANUAL) {
// an actual known type
- if (value == 5) {
+ if (value == SUBSURFACE) {
/*
* Subsurface CSV file needs separator detection
* as we used to default to comma but switched
@@ -530,11 +551,11 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
headers.replace(CSVApps[value].temperature, tr("Sample temperature"));
if (CSVApps[value].po2 > -1 && CSVApps[value].po2 < currColumns.count())
headers.replace(CSVApps[value].po2, tr("Sample pO₂"));
- if (CSVApps[value].po2 > -1 && CSVApps[value].po2 < currColumns.count())
+ if (CSVApps[value].sensor1 > -1 && CSVApps[value].sensor1 < currColumns.count())
headers.replace(CSVApps[value].sensor1, tr("Sample sensor1 pO₂"));
- if (CSVApps[value].po2 > -1 && CSVApps[value].po2 < currColumns.count())
+ if (CSVApps[value].sensor2 > -1 && CSVApps[value].sensor2 < currColumns.count())
headers.replace(CSVApps[value].sensor2, tr("Sample sensor2 pO₂"));
- if (CSVApps[value].po2 > -1 && CSVApps[value].po2 < currColumns.count())
+ if (CSVApps[value].sensor3 > -1 && CSVApps[value].sensor3 < currColumns.count())
headers.replace(CSVApps[value].sensor3, tr("Sample sensor3 pO₂"));
if (CSVApps[value].cns > -1 && CSVApps[value].cns < currColumns.count())
headers.replace(CSVApps[value].cns, tr("Sample CNS"));
@@ -601,7 +622,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
r.indexOf(tr("Sample stopdepth")),
r.indexOf(tr("Sample pressure")),
ui->CSVSeparator->currentIndex(),
- specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
+ "csv",
ui->CSVUnits->currentIndex(),
delta.toUtf8().data()
) < 0) {