Mercurial > hg > sonic-visualiser
diff main/MainWindow.cpp @ 85:4eae5b521a34
* Framework for retrieving files from remote locations
author | Chris Cannam |
---|---|
date | Mon, 08 Jan 2007 17:04:35 +0000 |
parents | 41c491657587 |
children | 6113fdda2737 |
line wrap: on
line diff
--- a/main/MainWindow.cpp Fri Jan 05 15:49:10 2007 +0000 +++ b/main/MainWindow.cpp Mon Jan 08 17:04:35 2007 +0000 @@ -47,6 +47,7 @@ #include "data/fileio/WavFileWriter.h" #include "data/fileio/CSVFileWriter.h" #include "data/fileio/BZipFileDevice.h" +#include "data/fileio/RemoteFile.h" #include "base/RecentFiles.h" #include "transform/TransformFactory.h" #include "base/PlayParameterRepository.h" @@ -2667,14 +2668,48 @@ } MainWindow::FileOpenStatus +MainWindow::openURL(QUrl url) +{ + if (url.scheme().toLower() == "file") { + return openSomeFile(url.toLocalFile()); + } else if (url.scheme().toLower() != "http" && + url.scheme().toLower() != "ftp") { + QMessageBox::critical(this, tr("Unsupported scheme in URL"), + tr("The URL scheme \"%1\" is not supported") + .arg(url.scheme())); + return FileOpenFailed; + } else { + RemoteFile rf(url); + rf.wait(); + if (!rf.isOK()) { + //!!! need to clean up any partially downloaded file! + QMessageBox::critical(this, tr("File download failed"), + tr("Failed to download URL \"%1\": %2") + .arg(url.toString()).arg(rf.getErrorString())); + return FileOpenFailed; + } + //!!! and delete the file if we fail to open it here? + return openSomeFile(rf.getLocalFilename()); + } +} + +MainWindow::FileOpenStatus MainWindow::openSomeFile(QString path, AudioFileOpenMode mode) { FileOpenStatus status; + bool canImportLayer = (getMainModel() != 0 && + m_paneStack != 0 && + m_paneStack->getCurrentPane() != 0); + if ((status = openAudioFile(path, mode)) != FileOpenFailed) { return status; } else if ((status = openSessionFile(path)) != FileOpenFailed) { return status; + } else if (!canImportLayer) { + return FileOpenFailed; + } else if ((status = openLayerFile(path)) != FileOpenFailed) { + return status; } else { return FileOpenFailed; }