summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-05-28 09:55:46 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-26 20:33:50 -0700
commit8fcc074b493970fe45c7592d65bf216bc8bd8c42 (patch)
treeecc7fb237305a9c33e8dfee802c67b6413360268 /qt-ui
parentbb020ae918593b5241e64582847e8d54ede7243d (diff)
downloadsubsurface-8fcc074b493970fe45c7592d65bf216bc8bd8c42.tar.gz
Support for importing Poseidon MK6 logs
This patch adds support for importing the logs from a Poseidon MK6 rebreather. This DC produces logs that contain of a .txt file that has all the meta data and a .csv file that contains the sample readings. The CSV file is different from the others in that it has a line per each sample reading at given time. Thus we have to merge all the lines from one point in time into one sample reading of ours. [Dirk Hohndel: addressed some compiler warnings] Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp26
-rw-r--r--qt-ui/mainwindow.h1
2 files changed, 25 insertions, 2 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index dfe8a2380..cb1ffea2d 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1174,6 +1174,23 @@ void MainWindow::importFiles(const QStringList fileNames)
refreshDisplay();
}
+void MainWindow::importTxtFiles(const QStringList fileNames)
+{
+ if (fileNames.isEmpty())
+ return;
+
+ QByteArray fileNamePtr, csv;
+
+ for (int i = 0; i < fileNames.size(); ++i) {
+ fileNamePtr = QFile::encodeName(fileNames.at(i));
+ csv = fileNamePtr.data();
+ csv.replace(strlen(csv.data()) - 3, 3, "csv");
+ parse_txt_file(fileNamePtr.data(), csv);
+ }
+ process_dives(true, false);
+ refreshDisplay();
+}
+
void MainWindow::loadFiles(const QStringList fileNames)
{
if (fileNames.isEmpty())
@@ -1208,14 +1225,15 @@ void MainWindow::on_actionImportDiveLog_triggered()
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open dive log file"), lastUsedDir(),
tr("Dive log files (*.xml *.uddf *.udcf *.csv *.jlb *.dld *.sde *.db);;"
"XML files (*.xml);;UDDF/UDCF files(*.uddf *.udcf);;JDiveLog files(*.jlb);;"
- "Suunto Files(*.sde *.db);;CSV Files(*.csv);;All Files(*)"));
+ "Suunto Files(*.sde *.db);;CSV Files(*.csv);;MkVI Files(*.txt);;All Files(*)"));
if (fileNames.isEmpty())
return;
updateLastUsedDir(QFileInfo(fileNames[0]).dir().path());
- QStringList logFiles = fileNames.filter(QRegExp("^.*\\.(?!csv)", Qt::CaseInsensitive));
+ QStringList logFiles = fileNames.filter(QRegExp("^.*\\.(?!csv|?!txt)", Qt::CaseInsensitive));
QStringList csvFiles = fileNames.filter(".csv", Qt::CaseInsensitive);
+ QStringList txtFiles = fileNames.filter(".txt", Qt::CaseInsensitive);
if (logFiles.size()) {
importFiles(logFiles);
}
@@ -1226,6 +1244,10 @@ void MainWindow::on_actionImportDiveLog_triggered()
process_dives(true, false);
refreshDisplay();
}
+
+ if (txtFiles.size()) {
+ importTxtFiles(txtFiles);
+ }
}
void MainWindow::editCurrentDive()
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index edf33a500..26f4176ac 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -73,6 +73,7 @@ public:
void enableDcShortcuts();
void loadFiles(const QStringList files);
void importFiles(const QStringList importFiles);
+ void importTxtFiles(const QStringList fileNames);
void cleanUpEmpty();
void setToolButtonsEnabled(bool enabled);
ProfileWidget2 *graphics() const;