comparison main/MainWindow.cpp @ 1911:2160976df436 import-audio-data

Use progress dialog when importing audio data
author Chris Cannam
date Fri, 29 Jun 2018 13:57:29 +0100
parents dc275d7d9aa6
children a28cab68eac6
comparison
equal deleted inserted replaced
1904:05c53d02bf7e 1911:2160976df436
2899 format.setSampleRate(rate); 2899 format.setSampleRate(rate);
2900 format.setTimingType(CSVFormat::ImplicitTiming); 2900 format.setTimingType(CSVFormat::ImplicitTiming);
2901 format.setTimeUnits(CSVFormat::TimeAudioFrames); 2901 format.setTimeUnits(CSVFormat::TimeAudioFrames);
2902 2902
2903 FileOpenStatus status = FileOpenSucceeded; 2903 FileOpenStatus status = FileOpenSucceeded;
2904
2905 ProgressDialog *dialog = new ProgressDialog(tr("Importing audio data..."),
2906 true, 0, this,
2907 Qt::ApplicationModal);
2904 2908
2905 WaveFileModel *model = qobject_cast<WaveFileModel *> 2909 WaveFileModel *model = qobject_cast<WaveFileModel *>
2906 (DataFileReaderFactory::loadCSV 2910 (DataFileReaderFactory::loadCSV
2907 (path, format, 2911 (path, format,
2908 getMainModel() ? getMainModel()->getSampleRate() : rate)); 2912 getMainModel() ? getMainModel()->getSampleRate() : rate,
2909 2913 dialog));
2910 if (!model || !model->isOK()) { 2914
2915 if (dialog->wasCancelled()) {
2916
2917 delete model;
2918 status = FileOpenCancelled;
2919
2920 } else if (!model || !model->isOK()) {
2911 2921
2912 delete model; 2922 delete model;
2913 status = FileOpenFailed; 2923 status = FileOpenFailed;
2914 2924
2915 } else { 2925 } else {
2919 CreateAdditionalModel, 2929 CreateAdditionalModel,
2920 getDefaultSessionTemplate(), 2930 getDefaultSessionTemplate(),
2921 false); 2931 false);
2922 } 2932 }
2923 2933
2934 delete dialog;
2935
2924 if (status == FileOpenFailed) { 2936 if (status == FileOpenFailed) {
2925 emit hideSplash(); 2937 emit hideSplash();
2926 QMessageBox::critical(this, tr("Failed to open file"), 2938 QMessageBox::critical(this, tr("Failed to open file"),
2927 tr("<b>File open failed</b><p>Audio data file %1 could not be opened.").arg(path)); 2939 tr("<b>File open failed</b><p>Audio data file %1 could not be opened.").arg(path));
2928 } 2940 }