Mercurial > hg > sonic-visualiser
changeset 87:8944f3005a15
* Cancel when downloading file
* Handle status codes (404 etc)
* Add RemoteFile::isAvailable
* Start on FileFinder for looking up files referred to in distant sessions
author | Chris Cannam |
---|---|
date | Wed, 10 Jan 2007 17:26:39 +0000 |
parents | 6113fdda2737 |
children | 51be0daa1386 |
files | document/SVFileReader.cpp document/SVFileReader.h main/MainWindow.cpp |
diffstat | 3 files changed, 41 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/document/SVFileReader.cpp Wed Jan 10 12:27:55 2007 +0000 +++ b/document/SVFileReader.cpp Wed Jan 10 17:26:39 2007 +0000 @@ -21,6 +21,8 @@ #include "base/PlayParameterRepository.h" #include "data/fileio/AudioFileReaderFactory.h" +#include "data/fileio/FileFinder.h" +#include "data/fileio/RemoteFile.h" #include "data/model/WaveFileModel.h" #include "data/model/EditableDenseThreeDimensionalModel.h" @@ -147,9 +149,11 @@ SVFileReader::SVFileReader(Document *document, - SVFileReaderPaneCallback &callback) : + SVFileReaderPaneCallback &callback, + QString location) : m_document(document), m_paneCallback(callback), + m_location(location), m_currentPane(0), m_currentDataset(0), m_currentDerivedModel(0), @@ -494,6 +498,36 @@ if (type == "wavefile") { + WaveFileModel *model = 0; + FileFinder finder(attributes.value("file"), m_location); + QString path = finder.getLocation(); + QUrl url(path); + + if (RemoteFile::canHandleScheme(url)) { + + RemoteFile rf(url); + rf.wait(); + + if (rf.isOK()) { + model = new WaveFileModel(rf.getLocalFilename()); + if (!model->isOK()) { + delete model; + model = 0; + //!!! and delete local file? + } + } + } else { + + model = new WaveFileModel(path); + if (!model->isOK()) { + delete model; + model = 0; + } + } + + if (!model) return false; + +/* QString file = attributes.value("file"); WaveFileModel *model = new WaveFileModel(file); @@ -522,6 +556,7 @@ return false; } } +*/ m_models[id] = model; if (mainModel) {
--- a/document/SVFileReader.h Wed Jan 10 12:27:55 2007 +0000 +++ b/document/SVFileReader.h Wed Jan 10 17:26:39 2007 +0000 @@ -41,7 +41,8 @@ { public: SVFileReader(Document *document, - SVFileReaderPaneCallback &callback); + SVFileReaderPaneCallback &callback, + QString location = ""); // for audio file locate mechanism virtual ~SVFileReader(); void parse(const QString &xmlData); @@ -85,6 +86,7 @@ Document *m_document; SVFileReaderPaneCallback &m_paneCallback; + QString m_location; Pane *m_currentPane; std::map<int, Layer *> m_layers; std::map<int, Model *> m_models;
--- a/main/MainWindow.cpp Wed Jan 10 12:27:55 2007 +0000 +++ b/main/MainWindow.cpp Wed Jan 10 17:26:39 2007 +0000 @@ -2253,7 +2253,7 @@ return FileOpenFailed; } - SVFileReader reader(m_document, callback); + SVFileReader reader(m_document, callback, location); reader.setCurrentPane(pane); QXmlInputSource inputSource(&file); @@ -2805,7 +2805,7 @@ PaneCallback callback(this); m_viewManager->clearSelections(); - SVFileReader reader(m_document, callback); + SVFileReader reader(m_document, callback, location); QXmlInputSource inputSource(&bzFile); reader.parse(inputSource);