Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 152:6f1e64670451
* Fix crash in SimpleSPARQLQuery
* Fix failure to add images from local files
| author | Chris Cannam | 
|---|---|
| date | Thu, 15 Jan 2009 18:20:40 +0000 | 
| parents | 6e8bce502be3 | 
| children | 6a24c797c157 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 151:f8110d1a3a37 | 152:6f1e64670451 | 
|---|---|
| 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 "data/fileio/AudioFileReaderFactory.h" | |
| 56 #include "rdf/RDFImporter.h" | 57 #include "rdf/RDFImporter.h" | 
| 57 | 58 | 
| 58 #include "data/fft/FFTDataServer.h" | 59 #include "data/fft/FFTDataServer.h" | 
| 59 | 60 | 
| 60 #include "base/RecentFiles.h" | 61 #include "base/RecentFiles.h" | 
| 857 | 858 | 
| 858 bool canImportLayer = (getMainModel() != 0 && | 859 bool canImportLayer = (getMainModel() != 0 && | 
| 859 m_paneStack != 0 && | 860 m_paneStack != 0 && | 
| 860 m_paneStack->getCurrentPane() != 0); | 861 m_paneStack->getCurrentPane() != 0); | 
| 861 | 862 | 
| 862 bool rdf = (source.getExtension() == "rdf" || | 863 bool rdf = (source.getExtension().toLower() == "rdf" || | 
| 863 source.getExtension() == "n3" || | 864 source.getExtension().toLower() == "n3" || | 
| 864 source.getExtension() == "ttl"); | 865 source.getExtension().toLower() == "ttl"); | 
| 866 | |
| 867 bool audio = AudioFileReaderFactory::getKnownExtensions().contains | |
| 868 (source.getExtension().toLower()); | |
| 865 | 869 | 
| 866 bool rdfSession = false; | 870 bool rdfSession = false; | 
| 867 if (rdf) { | 871 if (rdf) { | 
| 868 RDFImporter::RDFDocumentType rdfType = | 872 RDFImporter::RDFDocumentType rdfType = | 
| 869 RDFImporter::identifyDocumentType | 873 RDFImporter::identifyDocumentType | 
| 898 return FileOpenFailed; | 902 return FileOpenFailed; | 
| 899 } | 903 } | 
| 900 } | 904 } | 
| 901 } | 905 } | 
| 902 | 906 | 
| 903 if ((status = openAudio(source, mode)) != FileOpenFailed) { | 907 if (audio && (status = openAudio(source, mode)) != FileOpenFailed) { | 
| 904 return status; | 908 return status; | 
| 905 } else if ((status = openSession(source)) != FileOpenFailed) { | 909 } else if ((status = openSession(source)) != FileOpenFailed) { | 
| 906 return status; | 910 return status; | 
| 907 } else if ((status = openPlaylist(source, mode)) != FileOpenFailed) { | 911 } else if ((status = openPlaylist(source, mode)) != FileOpenFailed) { | 
| 908 return status; | 912 return status; | 
| 1116 { | 1120 { | 
| 1117 std::cerr << "MainWindowBase::openPlaylist(" << source.getLocation().toStdString() << ")" << std::endl; | 1121 std::cerr << "MainWindowBase::openPlaylist(" << source.getLocation().toStdString() << ")" << std::endl; | 
| 1118 | 1122 | 
| 1119 std::set<QString> extensions; | 1123 std::set<QString> extensions; | 
| 1120 PlaylistFileReader::getSupportedExtensions(extensions); | 1124 PlaylistFileReader::getSupportedExtensions(extensions); | 
| 1121 QString extension = source.getExtension(); | 1125 QString extension = source.getExtension().toLower(); | 
| 1122 if (extensions.find(extension) == extensions.end()) return FileOpenFailed; | 1126 if (extensions.find(extension) == extensions.end()) return FileOpenFailed; | 
| 1123 | 1127 | 
| 1124 if (!source.isAvailable()) return FileOpenFailed; | 1128 if (!source.isAvailable()) return FileOpenFailed; | 
| 1125 source.waitForData(); | 1129 source.waitForData(); | 
| 1126 | 1130 | 
| 1183 | 1187 | 
| 1184 if (rdfType != RDFImporter::NotRDF) { | 1188 if (rdfType != RDFImporter::NotRDF) { | 
| 1185 | 1189 | 
| 1186 return openLayersFromRDF(source); | 1190 return openLayersFromRDF(source); | 
| 1187 | 1191 | 
| 1188 } else if (source.getExtension() == "svl" || | 1192 } else if (source.getExtension().toLower() == "svl" || | 
| 1189 (source.getExtension() == "xml" && | 1193 (source.getExtension().toLower() == "xml" && | 
| 1190 (SVFileReader::identifyXmlFile(source.getLocalFilename()) | 1194 (SVFileReader::identifyXmlFile(source.getLocalFilename()) | 
| 1191 == SVFileReader::SVLayerFile))) { | 1195 == SVFileReader::SVLayerFile))) { | 
| 1192 | 1196 | 
| 1193 PaneCallback callback(this); | 1197 PaneCallback callback(this); | 
| 1194 QFile file(path); | 1198 QFile file(path); | 
| 1345 std::cerr << "MainWindowBase::openSession(" << source.getLocation().toStdString() << ")" << std::endl; | 1349 std::cerr << "MainWindowBase::openSession(" << source.getLocation().toStdString() << ")" << std::endl; | 
| 1346 | 1350 | 
| 1347 if (!source.isAvailable()) return FileOpenFailed; | 1351 if (!source.isAvailable()) return FileOpenFailed; | 
| 1348 source.waitForData(); | 1352 source.waitForData(); | 
| 1349 | 1353 | 
| 1350 if (source.getExtension() != "sv") { | 1354 if (source.getExtension().toLower() != "sv") { | 
| 1351 | 1355 | 
| 1352 RDFImporter::RDFDocumentType rdfType = | 1356 RDFImporter::RDFDocumentType rdfType = | 
| 1353 RDFImporter::identifyDocumentType | 1357 RDFImporter::identifyDocumentType | 
| 1354 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); | 1358 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); | 
| 1355 | 1359 | 
| 1360 return openSessionFromRDF(source); | 1364 return openSessionFromRDF(source); | 
| 1361 } else if (rdfType != RDFImporter::NotRDF) { | 1365 } else if (rdfType != RDFImporter::NotRDF) { | 
| 1362 return FileOpenFailed; | 1366 return FileOpenFailed; | 
| 1363 } | 1367 } | 
| 1364 | 1368 | 
| 1365 if (source.getExtension() == "xml") { | 1369 if (source.getExtension().toLower() == "xml") { | 
| 1366 if (SVFileReader::identifyXmlFile(source.getLocalFilename()) == | 1370 if (SVFileReader::identifyXmlFile(source.getLocalFilename()) == | 
| 1367 SVFileReader::SVSessionFile) { | 1371 SVFileReader::SVSessionFile) { | 
| 1368 std::cerr << "This XML file looks like a session file, attempting to open it as a session" << std::endl; | 1372 std::cerr << "This XML file looks like a session file, attempting to open it as a session" << std::endl; | 
| 1369 } else { | 1373 } else { | 
| 1370 return FileOpenFailed; | 1374 return FileOpenFailed; | 
| 1376 | 1380 | 
| 1377 QXmlInputSource *inputSource = 0; | 1381 QXmlInputSource *inputSource = 0; | 
| 1378 BZipFileDevice *bzFile = 0; | 1382 BZipFileDevice *bzFile = 0; | 
| 1379 QFile *rawFile = 0; | 1383 QFile *rawFile = 0; | 
| 1380 | 1384 | 
| 1381 if (source.getExtension() == "sv") { | 1385 if (source.getExtension().toLower() == "sv") { | 
| 1382 bzFile = new BZipFileDevice(source.getLocalFilename()); | 1386 bzFile = new BZipFileDevice(source.getLocalFilename()); | 
| 1383 if (!bzFile->open(QIODevice::ReadOnly)) { | 1387 if (!bzFile->open(QIODevice::ReadOnly)) { | 
| 1384 delete bzFile; | 1388 delete bzFile; | 
| 1385 return FileOpenFailed; | 1389 return FileOpenFailed; | 
| 1386 } | 1390 } | 
