aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-01-25 09:49:22 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-25 06:52:06 -0800
commit47ad50d6de231809fd04d27c053c79b2bbb3ab1a (patch)
treee9fa0dc9b7685728af15d4505d341774f435ed6e
parentd010b6a2167141f56a2393aa683d6c3516e68586 (diff)
downloadsubsurface-47ad50d6de231809fd04d27c053c79b2bbb3ab1a.tar.gz
C++ code to call parsing functions for manual CSV
This code sets up the C++ part for importing manually kept CSV log. That includes setting up the field separator selection and calling C-code for parsing the log file. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/divelogimportdialog.cpp53
1 files changed, 39 insertions, 14 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 52f95a785..0a513de62 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -30,6 +30,10 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) :
ui->CSVSeparator->addItem(",");
ui->CSVSeparator->addItem(";");
ui->knownImports->setCurrentIndex(1);
+ ui->ManualSeparator->addItem("Tab");
+ ui->ManualSeparator->addItem(",");
+ ui->ManualSeparator->addItem(";");
+ ui->knownImports->setCurrentIndex(1);
connect(ui->CSVDepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
connect(ui->CSVTime, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
@@ -41,7 +45,6 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) :
connect(ui->cnsCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
connect(ui->CSVstopdepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
- connect(ui->CSVSeparator, SIGNAL(currentIndexChanged(int)), this, SLOT(unknownImports()));
}
DiveLogImportDialog::~DiveLogImportDialog()
@@ -53,19 +56,41 @@ DiveLogImportDialog::~DiveLogImportDialog()
void DiveLogImportDialog::on_buttonBox_accepted()
{
char *error = NULL;
- for (int i = 0; i < fileNames.size(); ++i) {
- parse_csv_file(fileNames[i].toUtf8().data(), ui->CSVTime->value() - 1,
- ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature),
- VALUE_IF_CHECKED(CSVpo2),
- VALUE_IF_CHECKED(CSVcns),
- VALUE_IF_CHECKED(CSVstopdepth),
- ui->CSVSeparator->currentIndex(),
- specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
- &error);
- if (error != NULL) {
- mainWindow()->showError(error);
- free(error);
- error = NULL;
+
+ if (ui->tabWidget->currentIndex() == 0) {
+ for (int i = 0; i < fileNames.size(); ++i) {
+ parse_csv_file(fileNames[i].toUtf8().data(), ui->CSVTime->value() - 1,
+ ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature),
+ VALUE_IF_CHECKED(CSVpo2),
+ VALUE_IF_CHECKED(CSVcns),
+ VALUE_IF_CHECKED(CSVstopdepth),
+ ui->CSVSeparator->currentIndex(),
+ specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
+ &error);
+ if (error != NULL) {
+ mainWindow()->showError(error);
+ free(error);
+ error = NULL;
+ }
+ }
+ } else {
+ for (int i = 0; i < fileNames.size(); ++i) {
+ parse_manual_file(fileNames[i].toUtf8().data(),
+ ui->ManualSeparator->currentIndex(),
+ ui->Units->currentIndex(),
+ VALUE_IF_CHECKED(DiveNumber),
+ VALUE_IF_CHECKED(Date), VALUE_IF_CHECKED(Time),
+ VALUE_IF_CHECKED(Duration), VALUE_IF_CHECKED(Location),
+ VALUE_IF_CHECKED(Gps), VALUE_IF_CHECKED(MaxDepth),
+ VALUE_IF_CHECKED(MeanDepth), VALUE_IF_CHECKED(Buddy),
+ VALUE_IF_CHECKED(Notes), VALUE_IF_CHECKED(Weight),
+ VALUE_IF_CHECKED(Tags),
+ &error);
+ if (error != NULL) {
+ mainWindow()->showError(error);
+ free(error);
+ error = NULL;
+ }
}
}
process_dives(true, false);