Known import fix for XP5

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2015-01-23 20:06:32 +02:00 committed by Dirk Hohndel
parent d501445bea
commit b772beda71

View file

@ -360,6 +360,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
QStringList headers; QStringList headers;
bool matchedSome = false; bool matchedSome = false;
bool seabear = false; bool seabear = false;
bool xp5 = false;
// reset everything // reset everything
ColumnNameProvider *provider = new ColumnNameProvider(this); ColumnNameProvider *provider = new ColumnNameProvider(this);
@ -376,6 +377,13 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
blockSignals(true); blockSignals(true);
ui->knownImports->setCurrentText("Seabear CSV"); ui->knownImports->setCurrentText("Seabear CSV");
blockSignals(false); blockSignals(false);
} else if (firstLine.contains("Tauchgangs-Nr.:")) {
xp5 = true;
//"Abgelaufene Tauchzeit (Std:Min.)\tTiefe\tStickstoff Balkenanzeige\tSauerstoff Balkenanzeige\tAufstiegsgeschwindigkeit\tRestluftzeit\tRestliche Tauchzeit\tDekompressionszeit (Std:Min)\tDekostopp-Tiefe\tTemperatur\tPO2\tPressluftflasche\tLesen des Druckes\tStatus der Verbindung\tTauchstatus";
firstLine = "Sample time\tSample depth\t\t\t\t\t\t\t\tSample temperature\t";
blockSignals(true);
ui->knownImports->setCurrentText("XP5");
blockSignals(false);
} }
QString separator = ui->CSVSeparator->currentText() == tr("Tab") ? "\t" : ui->CSVSeparator->currentText(); QString separator = ui->CSVSeparator->currentText() == tr("Tab") ? "\t" : ui->CSVSeparator->currentText();
currColumns = firstLine.split(separator); currColumns = firstLine.split(separator);
@ -414,7 +422,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
} }
if (matchedSome) { 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.")); 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) { if (triggeredBy != KNOWNTYPES && !seabear && !xp5) {
blockSignals(true); blockSignals(true);
ui->knownImports->setCurrentIndex(0); // <- that's "Manual import" ui->knownImports->setCurrentIndex(0); // <- that's "Manual import"
blockSignals(false); blockSignals(false);
@ -458,20 +466,20 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
f.reset(); f.reset();
int rows = 0; int rows = 0;
/* Skipping the header of Seabear CSV file. */ /* Skipping the header of Seabear and XP5 CSV files. */
if (seabear) { if (seabear || xp5) {
/* /*
* First set of data on Seabear CSV file is metadata * First set of data on Seabear CSV file is metadata
* that is separated by an empty line (windows line * that is separated by an empty line (windows line
* termination might be encountered. * termination might be encountered.
*/ */
while (strlen(f.readLine()) > 2 && !f.atEnd()); while (strlen(f.readLine()) > 3 && !f.atEnd());
/* /*
* Next we have description of the fields and two dummy * Next we have description of the fields and two dummy
* lines. Separated again with an empty line from the * lines. Separated again with an empty line from the
* actual data. * actual data.
*/ */
while (strlen(f.readLine()) > 2 && !f.atEnd()); while (strlen(f.readLine()) > 3 && !f.atEnd());
} }
while (rows < 10 || !f.atEnd()) { while (rows < 10 || !f.atEnd()) {