# HG changeset patch # User Chris Cannam # Date 1536233711 -3600 # Node ID fbf8ce45fcad0bd17d11bbf2df6d59f2c2e570c1 # Parent bb9cf19e0b676db384715cb5490c08cde33a3de3 Use CSV format dialog for importing audio data, + some text changes diff -r bb9cf19e0b67 -r fbf8ce45fcad main/MainWindow.cpp --- a/main/MainWindow.cpp Wed Sep 05 11:57:10 2018 +0100 +++ b/main/MainWindow.cpp Thu Sep 06 12:35:11 2018 +0100 @@ -59,6 +59,7 @@ #include "widgets/ActivityLog.h" #include "widgets/UnitConverter.h" #include "widgets/ProgressDialog.h" +#include "widgets/CSVFormatDialog.h" #include "audio/AudioCallbackPlaySource.h" #include "audio/AudioCallbackRecordTarget.h" #include "audio/PlaySpeedRangeMapper.h" @@ -606,12 +607,12 @@ menu->addSeparator(); - action = new QAction(tr("Import Audio Data from CSV..."), this); + action = new QAction(tr("Import Audio from Data File..."), this); action->setStatusTip(tr("Import audio sample values from a CSV data file")); connect(action, SIGNAL(triggered()), this, SLOT(importAudioData())); menu->addAction(action); - action = new QAction(tr("Export Audio Data to CSV..."), this); + action = new QAction(tr("Export Audio to Data File..."), this); action->setStatusTip(tr("Export audio from selection into a CSV data file")); connect(action, SIGNAL(triggered()), this, SLOT(exportAudioData())); connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); @@ -2898,24 +2899,33 @@ format.setTimingType(CSVFormat::ImplicitTiming); format.setTimeUnits(CSVFormat::TimeAudioFrames); for (int i = 0; i < format.getColumnCount(); ++i) { - if (format.getColumnQualities()[i] & CSVFormat::ColumnNumeric) { + if (format.isColumnNumeric(CSVFormat::ColumnNumeric)) { format.setColumnPurpose(i, CSVFormat::ColumnValue); } } + { + CSVFormatDialog *dialog = new CSVFormatDialog(this, format); + if (dialog->exec() != QDialog::Accepted) { + delete dialog; + return; + } + format = dialog->getFormat(); + delete dialog; + } + FileOpenStatus status = FileOpenSucceeded; - ProgressDialog *dialog = new ProgressDialog(tr("Importing audio data..."), - true, 0, this, - Qt::ApplicationModal); + ProgressDialog *progress = new ProgressDialog + (tr("Importing audio data..."), true, 0, this, Qt::ApplicationModal); WaveFileModel *model = qobject_cast (DataFileReaderFactory::loadCSV (path, format, getMainModel() ? getMainModel()->getSampleRate() : rate, - dialog)); - - if (dialog->wasCancelled()) { + progress)); + + if (progress->wasCancelled()) { delete model; status = FileOpenCancelled; @@ -2934,7 +2944,7 @@ false); } - delete dialog; + delete progress; if (status == FileOpenFailed) { emit hideSplash();