Allow parsing of .txt files on import

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2016-05-05 09:26:10 +03:00 committed by Dirk Hohndel
parent b2d2d13650
commit 74065ad8aa
2 changed files with 14 additions and 2 deletions

View file

@ -884,7 +884,7 @@ int parse_txt_file(const char *filename, const char *csv)
record_dive(dive);
return 1;
} else {
return report_error(translate("gettextFromC", "No matching DC found for file '%s'"), csv);
return 0;
}
return 0;

View file

@ -1723,6 +1723,8 @@ void MainWindow::importFiles(const QStringList fileNames)
void MainWindow::importTxtFiles(const QStringList fileNames)
{
QStringList csvFiles;
if (fileNames.isEmpty())
return;
@ -1732,7 +1734,17 @@ void MainWindow::importTxtFiles(const QStringList fileNames)
fileNamePtr = QFile::encodeName(fileNames.at(i));
csv = fileNamePtr.data();
csv.replace(strlen(csv.data()) - 3, 3, "csv");
parse_txt_file(fileNamePtr.data(), csv);
QFileInfo check_file(csv);
if (check_file.exists() && check_file.isFile())
if (parse_txt_file(fileNamePtr.data(), csv) == 0)
csvFiles += fileNames.at(i);
else
csvFiles += fileNames.at(i);
}
if (csvFiles.size()) {
DiveLogImportDialog *diveLogImport = new DiveLogImportDialog(csvFiles, this);
diveLogImport->show();
}
process_dives(true, false);
refreshDisplay();