mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Show import dialog only when needed for CSV config
We do not need any import dialog when importing normal XML based divelogs. With this they are imported directly after file selection dialog. However, when CSV files are detected in the import list, the configuration dialog is displayed and applied for them. (CSV files are detected by file extension.) Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
58f6a01a22
commit
88fdf1b138
4 changed files with 46 additions and 155 deletions
|
@ -11,12 +11,13 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
|
|||
{NULL,}
|
||||
};
|
||||
|
||||
DiveLogImportDialog::DiveLogImportDialog(QWidget *parent) :
|
||||
DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
selector(true),
|
||||
ui(new Ui::DiveLogImportDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
fileNames = *fn;
|
||||
|
||||
for (int i = 0; !CSVApps[i].name.isNull(); ++i)
|
||||
ui->knownImports->addItem(CSVApps[i].name);
|
||||
|
@ -24,7 +25,6 @@ DiveLogImportDialog::DiveLogImportDialog(QWidget *parent) :
|
|||
ui->CSVSeparator->addItem("Tab");
|
||||
ui->CSVSeparator->addItem(",");
|
||||
ui->knownImports->setCurrentIndex(1);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
connect(ui->CSVDepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
|
||||
connect(ui->CSVTime, SIGNAL(valueChanged(int)), this, SLOT(unknownImports(int)));
|
||||
|
@ -48,30 +48,8 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
|||
{
|
||||
char *error = NULL;
|
||||
|
||||
if (ui->tabWidget->currentIndex() == 0) {
|
||||
QStringList fileNames = ui->DiveLogFile->text().split(";");
|
||||
|
||||
/*
|
||||
if (ui->ImportAdvanced->isChecked()) {
|
||||
for (int i = 0; i < fileNames.size(); ++i) {
|
||||
parse_xml_file_units(fileNames.at(i).toUtf8().data(),
|
||||
ui->XMLImportFormat->currentIndex(), ui->XMLImportUnits->currentIndex(),
|
||||
&error);
|
||||
}
|
||||
if (error != NULL) {
|
||||
|
||||
mainWindow()->showError(error);
|
||||
free(error);
|
||||
error = NULL;
|
||||
}
|
||||
} else {
|
||||
*/
|
||||
mainWindow()->importFiles(fileNames);
|
||||
return;
|
||||
//}
|
||||
|
||||
} else {
|
||||
parse_csv_file(ui->CSVFile->text().toUtf8().data(), ui->CSVTime->value() - 1,
|
||||
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),
|
||||
|
@ -89,13 +67,6 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
|||
mainWindow()->refreshDisplay();
|
||||
}
|
||||
|
||||
void DiveLogImportDialog::on_CSVFileSelector_clicked()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open CSV Log File"), ".", tr("CSV Files (*.csv);;All Files(*)"));
|
||||
ui->CSVFile->setText(filename);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!filename.isEmpty());
|
||||
}
|
||||
|
||||
#define SET_VALUE_AND_CHECKBOX(CSV, BOX, VAL) ({\
|
||||
ui->CSV->blockSignals(true);\
|
||||
ui->CSV->setValue(VAL);\
|
||||
|
@ -134,26 +105,3 @@ void DiveLogImportDialog::unknownImports()
|
|||
{
|
||||
ui->knownImports->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void DiveLogImportDialog::on_CSVFile_textEdited()
|
||||
{
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->CSVFile->text().isEmpty());
|
||||
}
|
||||
|
||||
void DiveLogImportDialog::on_DiveLogFileSelector_clicked()
|
||||
{
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Dive Log File"), ".", tr("XML Files (*.xml);;UDDF/UDCF Files(*.uddf *.udcf);;All Files(*)"));
|
||||
ui->DiveLogFile->setText(fileNames.join(";"));
|
||||
if (fileNames.size())
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
else
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
}
|
||||
|
||||
void DiveLogImportDialog::on_DiveLogFile_editingFinished()
|
||||
{
|
||||
if (ui->DiveLogFile->text().size())
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
else
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue