comparison document/SVFileReader.cpp @ 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 41c491657587
children 51be0daa1386
comparison
equal deleted inserted replaced
86:6113fdda2737 87:8944f3005a15
19 #include "view/View.h" 19 #include "view/View.h"
20 #include "base/PlayParameters.h" 20 #include "base/PlayParameters.h"
21 #include "base/PlayParameterRepository.h" 21 #include "base/PlayParameterRepository.h"
22 22
23 #include "data/fileio/AudioFileReaderFactory.h" 23 #include "data/fileio/AudioFileReaderFactory.h"
24 #include "data/fileio/FileFinder.h"
25 #include "data/fileio/RemoteFile.h"
24 26
25 #include "data/model/WaveFileModel.h" 27 #include "data/model/WaveFileModel.h"
26 #include "data/model/EditableDenseThreeDimensionalModel.h" 28 #include "data/model/EditableDenseThreeDimensionalModel.h"
27 #include "data/model/SparseOneDimensionalModel.h" 29 #include "data/model/SparseOneDimensionalModel.h"
28 #include "data/model/SparseTimeValueModel.h" 30 #include "data/model/SparseTimeValueModel.h"
145 147
146 */ 148 */
147 149
148 150
149 SVFileReader::SVFileReader(Document *document, 151 SVFileReader::SVFileReader(Document *document,
150 SVFileReaderPaneCallback &callback) : 152 SVFileReaderPaneCallback &callback,
153 QString location) :
151 m_document(document), 154 m_document(document),
152 m_paneCallback(callback), 155 m_paneCallback(callback),
156 m_location(location),
153 m_currentPane(0), 157 m_currentPane(0),
154 m_currentDataset(0), 158 m_currentDataset(0),
155 m_currentDerivedModel(0), 159 m_currentDerivedModel(0),
156 m_currentDerivedModelId(-1), 160 m_currentDerivedModelId(-1),
157 m_currentPlayParameters(0), 161 m_currentPlayParameters(0),
492 QString type = attributes.value("type").trimmed(); 496 QString type = attributes.value("type").trimmed();
493 bool mainModel = (attributes.value("mainModel").trimmed() == "true"); 497 bool mainModel = (attributes.value("mainModel").trimmed() == "true");
494 498
495 if (type == "wavefile") { 499 if (type == "wavefile") {
496 500
501 WaveFileModel *model = 0;
502 FileFinder finder(attributes.value("file"), m_location);
503 QString path = finder.getLocation();
504 QUrl url(path);
505
506 if (RemoteFile::canHandleScheme(url)) {
507
508 RemoteFile rf(url);
509 rf.wait();
510
511 if (rf.isOK()) {
512 model = new WaveFileModel(rf.getLocalFilename());
513 if (!model->isOK()) {
514 delete model;
515 model = 0;
516 //!!! and delete local file?
517 }
518 }
519 } else {
520
521 model = new WaveFileModel(path);
522 if (!model->isOK()) {
523 delete model;
524 model = 0;
525 }
526 }
527
528 if (!model) return false;
529
530 /*
497 QString file = attributes.value("file"); 531 QString file = attributes.value("file");
498 WaveFileModel *model = new WaveFileModel(file); 532 WaveFileModel *model = new WaveFileModel(file);
499 533
500 while (!model->isOK()) { 534 while (!model->isOK()) {
501 535
520 } 554 }
521 } else { 555 } else {
522 return false; 556 return false;
523 } 557 }
524 } 558 }
559 */
525 560
526 m_models[id] = model; 561 m_models[id] = model;
527 if (mainModel) { 562 if (mainModel) {
528 m_document->setMainModel(model); 563 m_document->setMainModel(model);
529 m_addedModels.insert(model); 564 m_addedModels.insert(model);