comparison framework/MainWindowBase.cpp @ 134:b6dfdd99bd60

* Merge revisions 1041 to 1130 from sv-rdf-import branch
author Chris Cannam
date Thu, 18 Sep 2008 12:09:32 +0000
parents 3b61a975b47e
children b742f579ced0
comparison
equal deleted inserted replaced
133:f2cbe0e89d0f 134:b6dfdd99bd60
51 #include "data/fileio/WavFileWriter.h" 51 #include "data/fileio/WavFileWriter.h"
52 #include "data/fileio/CSVFileWriter.h" 52 #include "data/fileio/CSVFileWriter.h"
53 #include "data/fileio/MIDIFileWriter.h" 53 #include "data/fileio/MIDIFileWriter.h"
54 #include "data/fileio/BZipFileDevice.h" 54 #include "data/fileio/BZipFileDevice.h"
55 #include "data/fileio/FileSource.h" 55 #include "data/fileio/FileSource.h"
56 #include "rdf/RDFImporter.h"
56 57
57 #include "data/fft/FFTDataServer.h" 58 #include "data/fft/FFTDataServer.h"
58 59
59 #include "base/RecentFiles.h" 60 #include "base/RecentFiles.h"
60 61
835 } 836 }
836 837
837 MainWindowBase::FileOpenStatus 838 MainWindowBase::FileOpenStatus
838 MainWindowBase::open(QString fileOrUrl, AudioFileOpenMode mode) 839 MainWindowBase::open(QString fileOrUrl, AudioFileOpenMode mode)
839 { 840 {
840 ProgressDialog dialog(tr("Opening file or URL..."), true, 2000); 841 ProgressDialog dialog(tr("Opening file or URL..."), true, 2000, this);
842 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
841 return open(FileSource(fileOrUrl, &dialog), mode); 843 return open(FileSource(fileOrUrl, &dialog), mode);
842 } 844 }
843 845
844 MainWindowBase::FileOpenStatus 846 MainWindowBase::FileOpenStatus
845 MainWindowBase::open(FileSource source, AudioFileOpenMode mode) 847 MainWindowBase::open(FileSource source, AudioFileOpenMode mode)
1078 bool someSuccess = false; 1080 bool someSuccess = false;
1079 1081
1080 for (PlaylistFileReader::Playlist::const_iterator i = playlist.begin(); 1082 for (PlaylistFileReader::Playlist::const_iterator i = playlist.begin();
1081 i != playlist.end(); ++i) { 1083 i != playlist.end(); ++i) {
1082 1084
1083 ProgressDialog dialog(tr("Opening playlist..."), true, 2000); 1085 ProgressDialog dialog(tr("Opening playlist..."), true, 2000, this);
1086 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
1084 FileOpenStatus status = openAudio(FileSource(*i, &dialog), mode); 1087 FileOpenStatus status = openAudio(FileSource(*i, &dialog), mode);
1085 1088
1086 if (status == FileOpenCancelled) { 1089 if (status == FileOpenCancelled) {
1087 return FileOpenCancelled; 1090 return FileOpenCancelled;
1088 } 1091 }
1117 if (!source.isAvailable()) return FileOpenFailed; 1120 if (!source.isAvailable()) return FileOpenFailed;
1118 source.waitForData(); 1121 source.waitForData();
1119 1122
1120 QString path = source.getLocalFilename(); 1123 QString path = source.getLocalFilename();
1121 1124
1122 if (source.getExtension() == "svl" || source.getExtension() == "xml") { 1125 if (source.getExtension() == "rdf" || source.getExtension() == "n3" ||
1126 source.getExtension() == "ttl") {
1127
1128 RDFImporter importer("file://" + path, getMainModel()->getSampleRate());
1129 if (importer.isOK()) {
1130
1131 ProgressDialog dialog(tr("Importing from RDF..."), true, 2000, this);
1132 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
1133 std::vector<Model *> models = importer.getDataModels(&dialog);
1134
1135 for (int i = 0; i < models.size(); ++i) {
1136 Layer *newLayer = m_document->createImportedLayer(models[i]);
1137 if (newLayer) {
1138 m_document->addLayerToView(pane, newLayer);
1139 }
1140 }
1141
1142 m_recentFiles.addFile(source.getLocation());
1143 return FileOpenSucceeded;
1144 }
1145
1146 return FileOpenFailed;
1147
1148 } else if (source.getExtension() == "svl" || source.getExtension() == "xml") {
1123 1149
1124 PaneCallback callback(this); 1150 PaneCallback callback(this);
1125 QFile file(path); 1151 QFile file(path);
1126 1152
1127 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { 1153 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
1261 } 1287 }
1262 1288
1263 MainWindowBase::FileOpenStatus 1289 MainWindowBase::FileOpenStatus
1264 MainWindowBase::openSessionFile(QString fileOrUrl) 1290 MainWindowBase::openSessionFile(QString fileOrUrl)
1265 { 1291 {
1266 ProgressDialog dialog(tr("Opening session..."), true, 2000); 1292 ProgressDialog dialog(tr("Opening session..."), true, 2000, this);
1293 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
1267 return openSession(FileSource(fileOrUrl, &dialog)); 1294 return openSession(FileSource(fileOrUrl, &dialog));
1268 } 1295 }
1269 1296
1270 MainWindowBase::FileOpenStatus 1297 MainWindowBase::FileOpenStatus
1271 MainWindowBase::openSession(FileSource source) 1298 MainWindowBase::openSession(FileSource source)