summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/divelogimportdialog.cpp45
-rw-r--r--desktop-widgets/divelogimportdialog.h2
-rw-r--r--desktop-widgets/maintab.cpp6
-rw-r--r--desktop-widgets/mainwindow.cpp9
4 files changed, 48 insertions, 14 deletions
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp
index 757cad59e..ecc2d24fb 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" },
+ { "DL7", 1, 2, -1, -1, -1, -1, -1, -1, -1, 8, -1, 10, -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,
@@ -343,11 +345,12 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
/* Add indexes of XSLTs requiring special handling to the list */
specialCSV << SENSUS;
specialCSV << SUBSURFACE;
+ specialCSV << DL7;
for (int i = 0; !CSVApps[i].name.isNull(); ++i)
ui->knownImports->addItem(CSVApps[i].name);
- ui->CSVSeparator->addItems( QStringList() << tr("Tab") << "," << ";");
+ ui->CSVSeparator->addItems( QStringList() << tr("Tab") << "," << ";" << "|");
loadFileContents(-1, INITIAL);
@@ -386,6 +389,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 +471,23 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
blockSignals(true);
ui->knownImports->setCurrentText("XP5");
blockSignals(false);
+ } else if (firstLine.contains("FSH")) {
+ QString units = "Metric";
+ dl7 = true;
+ while ((firstLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
+ /* DL7 actually defines individual units (e.g. depth, temp, pressure, etc.)
+ * and there are quite a few other options as well, but let's use metric
+ * unless depth unit is clearly Imperial. */
+
+ if (firstLine.contains("ThFt")) {
+ units = "Imperial";
+ }
+ }
+ firstLine = "|Sample time|Sample depth||||||Sample temperature||Sample pressure";
+ blockSignals(true);
+ ui->knownImports->setCurrentText("DL7");
+ ui->CSVUnits->setCurrentText(units);
+ blockSignals(false);
}
// Special handling for APD Log Viewer
@@ -487,11 +508,14 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
int tabs = firstLine.count('\t');
int commas = firstLine.count(',');
int semis = firstLine.count(';');
- if (tabs > commas && tabs > semis)
+ int pipes = firstLine.count('|');
+ if (tabs > commas && tabs > semis && tabs > pipes)
separator = "\t";
- else if (commas > tabs && commas > semis)
+ else if (commas > tabs && commas > semis && commas > pipes)
separator = ",";
- else if (semis > tabs && semis > commas)
+ else if (pipes > tabs && pipes > commas && pipes > semis)
+ separator = "|";
+ else if (semis > tabs && semis > commas && semis > pipes)
separator = ";";
if (ui->CSVSeparator->currentText() != separator) {
blockSignals(true);
@@ -548,7 +572,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);
@@ -662,6 +686,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()) {
@@ -788,7 +819,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
sample->tts.seconds *= 60;
}
} else {
- char *params[37];
+ char *params[39];
int pnr = 0;
pnr = setup_csv_params(r, params, pnr);
@@ -855,7 +886,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
parse_manual_file(fileNames[i].toUtf8().data(), params, pnr - 1);
} else {
- char *params[37];
+ char *params[39];
int pnr = 0;
pnr = setup_csv_params(r, params, pnr);
diff --git a/desktop-widgets/divelogimportdialog.h b/desktop-widgets/divelogimportdialog.h
index 811775379..750bc10fa 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];
};
diff --git a/desktop-widgets/maintab.cpp b/desktop-widgets/maintab.cpp
index a3cc151ef..f6e5b7dc6 100644
--- a/desktop-widgets/maintab.cpp
+++ b/desktop-widgets/maintab.cpp
@@ -493,7 +493,7 @@ void MainTab::updateDiveInfo(bool clear)
// Subsurface always uses "local time" as in "whatever was the local time at the location"
// so all time stamps have no time zone information and are in UTC
- QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
+ QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000*displayed_dive.when, Qt::UTC);
localTime.setTimeSpec(Qt::UTC);
ui.dateEdit->setDate(localTime.date());
ui.timeEdit->setTime(localTime.time());
@@ -1284,7 +1284,7 @@ void MainTab::on_dateEdit_dateChanged(const QDate &date)
if (editMode == IGNORE || acceptingEdit == true)
return;
markChangedWidget(ui.dateEdit);
- QDateTime dateTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
+ QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*displayed_dive.when, Qt::UTC);
dateTime.setTimeSpec(Qt::UTC);
dateTime.setDate(date);
DivePlannerPointsModel::instance()->getDiveplan().when = displayed_dive.when = dateTime.toTime_t();
@@ -1296,7 +1296,7 @@ void MainTab::on_timeEdit_timeChanged(const QTime &time)
if (editMode == IGNORE || acceptingEdit == true)
return;
markChangedWidget(ui.timeEdit);
- QDateTime dateTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
+ QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*displayed_dive.when, Qt::UTC);
dateTime.setTimeSpec(Qt::UTC);
dateTime.setTime(time);
DivePlannerPointsModel::instance()->getDiveplan().when = displayed_dive.when = dateTime.toTime_t();
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index a86901f98..c6624df5a 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -1792,8 +1792,8 @@ void MainWindow::loadFiles(const QStringList fileNames)
void MainWindow::on_actionImportDiveLog_triggered()
{
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open dive log file"), lastUsedDir(),
- tr("Dive log files (*.ssrf *.can *.csv *.db *.sql *.dld *.jlb *.lvd *.sde *.udcf *.uddf *.xml *.txt *.dlf *.apd"
- "*.SSRF *.CAN *.CSV *.DB *.SQL *.DLD *.JLB *.LVD *.SDE *.UDCF *.UDDF *.xml *.TXT *.DLF *.APD);;"
+ tr("Dive log files (*.ssrf *.can *.csv *.db *.sql *.dld *.jlb *.lvd *.sde *.udcf *.uddf *.xml *.txt *.dlf *.apd *.zxu *.zxl"
+ "*.SSRF *.CAN *.CSV *.DB *.SQL *.DLD *.JLB *.LVD *.SDE *.UDCF *.UDDF *.xml *.TXT *.DLF *.APD *.ZXU *.ZXL);;"
"Cochran files (*.can *.CAN);;"
"CSV files (*.csv *.CSV);;"
"DiveLog.de files (*.dld *.DLD);;"
@@ -1807,15 +1807,18 @@ void MainWindow::on_actionImportDiveLog_triggered()
"APD log viewer (*.apd *.APD);;"
"Datatrak/WLog Files (*.log *.LOG);;"
"OSTCtools Files (*.dive *.DIVE);;"
+ "DAN DL7 (*.zxu *.zxl *.ZXU *.ZXL);;"
"All files (*)"));
if (fileNames.isEmpty())
return;
updateLastUsedDir(QFileInfo(fileNames[0]).dir().path());
- QStringList logFiles = fileNames.filter(QRegExp("^.*\\.(?!(csv|txt|apd))", Qt::CaseInsensitive));
+ QStringList logFiles = fileNames.filter(QRegExp("^(?!.*\\.(csv|txt|apd|zxu|zxl))", Qt::CaseInsensitive));
QStringList csvFiles = fileNames.filter(".csv", Qt::CaseInsensitive);
csvFiles += fileNames.filter(".apd", Qt::CaseInsensitive);
+ csvFiles += fileNames.filter(".zxu", Qt::CaseInsensitive);
+ csvFiles += fileNames.filter(".zxl", Qt::CaseInsensitive);
QStringList txtFiles = fileNames.filter(".txt", Qt::CaseInsensitive);
if (logFiles.size()) {