mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
GUI for CSV import
This patch implements GUI for importing CSV log files. One is able to configure what columns contain time, depth and temperature fields. Pre-configured log applications currently included are ADP log viewer and XP5. (Both of these use actually tab as separator, so the field separator currently hard-coded.) [Dirk Hohndel: minor fixes] Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
80bced4f56
commit
4c49670cdb
11 changed files with 494 additions and 32 deletions
102
qt-ui/csvimportdialog.cpp
Normal file
102
qt-ui/csvimportdialog.cpp
Normal file
|
@ -0,0 +1,102 @@
|
|||
#include <QtDebug>
|
||||
#include <QFileDialog>
|
||||
#include "csvimportdialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ui_csvimportdialog.h"
|
||||
|
||||
const CSVImportDialog::CSVAppConfig CSVImportDialog::CSVApps[CSVAPPS] = {
|
||||
{"", },
|
||||
{"APD Log Viewer", 0, 1, 15, "Tab"},
|
||||
{"XP5", 0, 1, 9, "Tab"},
|
||||
{NULL,}
|
||||
};
|
||||
|
||||
CSVImportDialog::CSVImportDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
selector(true),
|
||||
ui(new Ui::CSVImportDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
for (int i = 0; !CSVApps[i].name.isNull(); ++i)
|
||||
ui->knownImports->addItem(CSVApps[i].name);
|
||||
|
||||
ui->CSVSeparator->addItem("Tab");
|
||||
ui->knownImports->setCurrentIndex(1);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
}
|
||||
|
||||
CSVImportDialog::~CSVImportDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_buttonBox_accepted()
|
||||
{
|
||||
char *error = NULL;
|
||||
|
||||
parse_csv_file(ui->CSVFile->text().toUtf8().data(), ui->CSVTime->value(), ui->CSVDepth->value(), ui->CSVTemperature->value(), &error);
|
||||
if (error != NULL) {
|
||||
|
||||
mainWindow()->showError(error);
|
||||
free(error);
|
||||
error = NULL;
|
||||
}
|
||||
process_dives(TRUE, FALSE);
|
||||
|
||||
mainWindow()->refreshDisplay();
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_CSVFileSelector_clicked()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open CSV Log File"), ".", tr("CSV Files (*.csv)"));
|
||||
ui->CSVFile->setText(filename);
|
||||
if (filename.isEmpty())
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
else
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
|
||||
{
|
||||
if (index == 0)
|
||||
return;
|
||||
|
||||
ui->CSVTime->blockSignals(true);
|
||||
ui->CSVDepth->blockSignals(true);
|
||||
ui->CSVTemperature->blockSignals(true);
|
||||
ui->CSVTime->setValue(CSVApps[index].time);
|
||||
ui->CSVDepth->setValue(CSVApps[index].depth);
|
||||
ui->CSVTemperature->setValue(CSVApps[index].temperature);
|
||||
ui->CSVTime->blockSignals(false);
|
||||
ui->CSVDepth->blockSignals(false);
|
||||
ui->CSVTemperature->blockSignals(false);
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_CSVTime_valueChanged(int arg1)
|
||||
{
|
||||
unknownImports();
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_CSVDepth_valueChanged(int arg1)
|
||||
{
|
||||
unknownImports();
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_CSVTemperature_valueChanged(int arg1)
|
||||
{
|
||||
unknownImports();
|
||||
}
|
||||
|
||||
void CSVImportDialog::unknownImports()
|
||||
{
|
||||
ui->knownImports->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_CSVFile_textEdited()
|
||||
{
|
||||
if (ui->CSVFile->text().isEmpty())
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
else
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue