comparison framework/MainWindowBase.cpp @ 722:b06b18c15fd4 spectrogram-export

Permit exporting spectrogram; also provide progress dialog
author Chris Cannam
date Tue, 07 Jan 2020 11:20:11 +0000
parents 453029d6e9bf
children cd1e8c731095
comparison
equal deleted inserted replaced
721:453029d6e9bf 722:b06b18c15fd4
35 #include "layer/SliceableLayer.h" 35 #include "layer/SliceableLayer.h"
36 #include "layer/ImageLayer.h" 36 #include "layer/ImageLayer.h"
37 #include "layer/NoteLayer.h" 37 #include "layer/NoteLayer.h"
38 #include "layer/FlexiNoteLayer.h" 38 #include "layer/FlexiNoteLayer.h"
39 #include "layer/RegionLayer.h" 39 #include "layer/RegionLayer.h"
40 #include "layer/SpectrogramLayer.h"
40 41
41 #include "widgets/ListInputDialog.h" 42 #include "widgets/ListInputDialog.h"
42 #include "widgets/CommandHistory.h" 43 #include "widgets/CommandHistory.h"
43 #include "widgets/ProgressDialog.h" 44 #include "widgets/ProgressDialog.h"
44 #include "widgets/MIDIFileImportDialog.h" 45 #include "widgets/MIDIFileImportDialog.h"
684 dynamic_cast<FlexiNoteLayer *>(currentLayer) || 685 dynamic_cast<FlexiNoteLayer *>(currentLayer) ||
685 dynamic_cast<RegionLayer *>(currentLayer))); 686 dynamic_cast<RegionLayer *>(currentLayer)));
686 bool haveCurrentColour3DPlot = 687 bool haveCurrentColour3DPlot =
687 (haveCurrentLayer && 688 (haveCurrentLayer &&
688 dynamic_cast<Colour3DPlotLayer *>(currentLayer)); 689 dynamic_cast<Colour3DPlotLayer *>(currentLayer));
690 bool haveCurrentSpectrogram =
691 (haveCurrentLayer &&
692 dynamic_cast<SpectrogramLayer *>(currentLayer));
689 bool haveClipboardContents = 693 bool haveClipboardContents =
690 (m_viewManager && 694 (m_viewManager &&
691 !m_viewManager->getClipboard().empty()); 695 !m_viewManager->getClipboard().empty());
692 bool haveTabularLayer = 696 bool haveTabularLayer =
693 (haveCurrentLayer && 697 (haveCurrentLayer &&
702 emit canReplaceMainAudio(haveMainModel); 706 emit canReplaceMainAudio(haveMainModel);
703 emit canImportLayer(haveMainModel && haveCurrentPane); 707 emit canImportLayer(haveMainModel && haveCurrentPane);
704 emit canExportAudio(haveMainModel); 708 emit canExportAudio(haveMainModel);
705 emit canChangeSessionTemplate(haveMainModel); 709 emit canChangeSessionTemplate(haveMainModel);
706 emit canExportLayer(haveMainModel && 710 emit canExportLayer(haveMainModel &&
707 (haveCurrentEditableLayer || haveCurrentColour3DPlot)); 711 (haveCurrentEditableLayer ||
712 haveCurrentColour3DPlot ||
713 haveCurrentSpectrogram));
708 emit canExportImage(haveMainModel && haveCurrentPane); 714 emit canExportImage(haveMainModel && haveCurrentPane);
709 emit canDeleteCurrentLayer(haveCurrentLayer); 715 emit canDeleteCurrentLayer(haveCurrentLayer);
710 emit canRenameLayer(haveCurrentLayer); 716 emit canRenameLayer(haveCurrentLayer);
711 emit canEditLayer(haveCurrentEditableLayer); 717 emit canEditLayer(haveCurrentEditableLayer);
712 emit canEditLayerTabular(haveCurrentEditableLayer || haveTabularLayer); 718 emit canEditLayerTabular(haveCurrentEditableLayer || haveTabularLayer);
2860 } 2866 }
2861 } 2867 }
2862 2868
2863 } else { 2869 } else {
2864 2870
2865 CSVFileWriter writer(path, model.get(), 2871 ProgressDialog dialog {
2872 QObject::tr("Exporting layer..."), true, 500, this,
2873 Qt::ApplicationModal
2874 };
2875
2876 CSVFileWriter writer(path, model.get(), &dialog,
2866 ((suffix == "csv") ? "," : "\t")); 2877 ((suffix == "csv") ? "," : "\t"));
2867 writer.write(); 2878 writer.write();
2868 2879
2869 if (!writer.isOK()) { 2880 if (!writer.isOK()) {
2870 error = writer.getError(); 2881 error = writer.getError();
2882 if (error == "") {
2883 error = tr("Failed to export layer for an unknown reason");
2884 }
2871 } 2885 }
2872 } 2886 }
2873 2887
2874 return (error == ""); 2888 return (error == "");
2875 } 2889 }