# HG changeset patch # User Chris Cannam # Date 1168449999 0 # Node ID 8944f3005a15c2b6cfbe27e12750125884df2a66 # Parent 6113fdda27378c6a59b96fe6b0837abb03d4754c * Cancel when downloading file * Handle status codes (404 etc) * Add RemoteFile::isAvailable * Start on FileFinder for looking up files referred to in distant sessions diff -r 6113fdda2737 -r 8944f3005a15 document/SVFileReader.cpp --- 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) { diff -r 6113fdda2737 -r 8944f3005a15 document/SVFileReader.h --- 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 m_layers; std::map m_models; diff -r 6113fdda2737 -r 8944f3005a15 main/MainWindow.cpp --- 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);