comparison framework/MainWindowBase.cpp @ 109:2dd30a7cd21a

* More work to abstract out interactive components used in the data library, so that it does not need to depend on QtGui.
author Chris Cannam
date Fri, 14 Mar 2008 17:14:21 +0000
parents e25e8f5d785b
children 0c1ea5ff6518
comparison
equal deleted inserted replaced
108:e25e8f5d785b 109:2dd30a7cd21a
34 #include "layer/SliceableLayer.h" 34 #include "layer/SliceableLayer.h"
35 #include "layer/ImageLayer.h" 35 #include "layer/ImageLayer.h"
36 36
37 #include "widgets/ListInputDialog.h" 37 #include "widgets/ListInputDialog.h"
38 #include "widgets/CommandHistory.h" 38 #include "widgets/CommandHistory.h"
39 #include "widgets/ProgressDialog.h"
40 #include "widgets/MIDIFileImportDialog.h"
41 #include "widgets/CSVFormatDialog.h"
39 42
40 #include "audioio/AudioCallbackPlaySource.h" 43 #include "audioio/AudioCallbackPlaySource.h"
41 #include "audioio/AudioCallbackPlayTarget.h" 44 #include "audioio/AudioCallbackPlayTarget.h"
42 #include "audioio/AudioTargetFactory.h" 45 #include "audioio/AudioTargetFactory.h"
43 #include "audioio/PlaySpeedRangeMapper.h" 46 #include "audioio/PlaySpeedRangeMapper.h"
813 } 816 }
814 817
815 MainWindowBase::FileOpenStatus 818 MainWindowBase::FileOpenStatus
816 MainWindowBase::open(QString fileOrUrl, AudioFileOpenMode mode) 819 MainWindowBase::open(QString fileOrUrl, AudioFileOpenMode mode)
817 { 820 {
818 return open(FileSource(fileOrUrl, FileSource::ProgressDialog), mode); 821 ProgressDialog dialog(tr("Opening file or URL..."), true, 2000);
822 return open(FileSource(fileOrUrl, &dialog), mode);
819 } 823 }
820 824
821 MainWindowBase::FileOpenStatus 825 MainWindowBase::FileOpenStatus
822 MainWindowBase::open(FileSource source, AudioFileOpenMode mode) 826 MainWindowBase::open(FileSource source, AudioFileOpenMode mode)
823 { 827 {
1055 bool someSuccess = false; 1059 bool someSuccess = false;
1056 1060
1057 for (PlaylistFileReader::Playlist::const_iterator i = playlist.begin(); 1061 for (PlaylistFileReader::Playlist::const_iterator i = playlist.begin();
1058 i != playlist.end(); ++i) { 1062 i != playlist.end(); ++i) {
1059 1063
1060 FileOpenStatus status = openAudio 1064 ProgressDialog dialog(tr("Opening playlist..."), true, 2000);
1061 (FileSource(*i, FileSource::ProgressDialog), mode); 1065 FileOpenStatus status = openAudio(FileSource(*i, &dialog), mode);
1062 1066
1063 if (status == FileOpenCancelled) { 1067 if (status == FileOpenCancelled) {
1064 return FileOpenCancelled; 1068 return FileOpenCancelled;
1065 } 1069 }
1066 1070
1138 1142
1139 } else { 1143 } else {
1140 1144
1141 try { 1145 try {
1142 1146
1143 Model *model = DataFileReaderFactory::load 1147 MIDIFileImportDialog midiDlg(this);
1144 (path, getMainModel()->getSampleRate()); 1148
1149 Model *model = DataFileReaderFactory::loadNonCSV
1150 (path, &midiDlg, getMainModel()->getSampleRate());
1145 1151
1152 if (!model) {
1153 CSVFormatDialog *dialog = new CSVFormatDialog
1154 (this, CSVFormat(path), getMainModel()->getSampleRate());
1155 if (dialog->exec() == QDialog::Accepted) {
1156 model = DataFileReaderFactory::loadCSV
1157 (path, dialog->getFormat(),
1158 getMainModel()->getSampleRate());
1159 }
1160 }
1161
1146 if (model) { 1162 if (model) {
1147 1163
1148 std::cerr << "MainWindowBase::openLayer: Have model" << std::endl; 1164 std::cerr << "MainWindowBase::openLayer: Have model" << std::endl;
1149 1165
1150 Layer *newLayer = m_document->createImportedLayer(model); 1166 Layer *newLayer = m_document->createImportedLayer(model);
1226 } 1242 }
1227 1243
1228 MainWindowBase::FileOpenStatus 1244 MainWindowBase::FileOpenStatus
1229 MainWindowBase::openSessionFile(QString fileOrUrl) 1245 MainWindowBase::openSessionFile(QString fileOrUrl)
1230 { 1246 {
1231 return openSession(FileSource(fileOrUrl, FileSource::ProgressDialog)); 1247 ProgressDialog dialog(tr("Opening session..."), true, 2000);
1248 return openSession(FileSource(fileOrUrl, &dialog));
1232 } 1249 }
1233 1250
1234 MainWindowBase::FileOpenStatus 1251 MainWindowBase::FileOpenStatus
1235 MainWindowBase::openSession(FileSource source) 1252 MainWindowBase::openSession(FileSource source)
1236 { 1253 {