Mercurial > hg > sonic-visualiser
comparison 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 |
comparison
equal
deleted
inserted
replaced
84:41c491657587 | 85:4eae5b521a34 |
---|---|
45 #include "data/fileio/AudioFileReaderFactory.h" | 45 #include "data/fileio/AudioFileReaderFactory.h" |
46 #include "data/fileio/DataFileReaderFactory.h" | 46 #include "data/fileio/DataFileReaderFactory.h" |
47 #include "data/fileio/WavFileWriter.h" | 47 #include "data/fileio/WavFileWriter.h" |
48 #include "data/fileio/CSVFileWriter.h" | 48 #include "data/fileio/CSVFileWriter.h" |
49 #include "data/fileio/BZipFileDevice.h" | 49 #include "data/fileio/BZipFileDevice.h" |
50 #include "data/fileio/RemoteFile.h" | |
50 #include "base/RecentFiles.h" | 51 #include "base/RecentFiles.h" |
51 #include "transform/TransformFactory.h" | 52 #include "transform/TransformFactory.h" |
52 #include "base/PlayParameterRepository.h" | 53 #include "base/PlayParameterRepository.h" |
53 #include "base/XmlExportable.h" | 54 #include "base/XmlExportable.h" |
54 #include "base/CommandHistory.h" | 55 #include "base/CommandHistory.h" |
2665 } | 2666 } |
2666 } | 2667 } |
2667 } | 2668 } |
2668 | 2669 |
2669 MainWindow::FileOpenStatus | 2670 MainWindow::FileOpenStatus |
2671 MainWindow::openURL(QUrl url) | |
2672 { | |
2673 if (url.scheme().toLower() == "file") { | |
2674 return openSomeFile(url.toLocalFile()); | |
2675 } else if (url.scheme().toLower() != "http" && | |
2676 url.scheme().toLower() != "ftp") { | |
2677 QMessageBox::critical(this, tr("Unsupported scheme in URL"), | |
2678 tr("The URL scheme \"%1\" is not supported") | |
2679 .arg(url.scheme())); | |
2680 return FileOpenFailed; | |
2681 } else { | |
2682 RemoteFile rf(url); | |
2683 rf.wait(); | |
2684 if (!rf.isOK()) { | |
2685 //!!! need to clean up any partially downloaded file! | |
2686 QMessageBox::critical(this, tr("File download failed"), | |
2687 tr("Failed to download URL \"%1\": %2") | |
2688 .arg(url.toString()).arg(rf.getErrorString())); | |
2689 return FileOpenFailed; | |
2690 } | |
2691 //!!! and delete the file if we fail to open it here? | |
2692 return openSomeFile(rf.getLocalFilename()); | |
2693 } | |
2694 } | |
2695 | |
2696 MainWindow::FileOpenStatus | |
2670 MainWindow::openSomeFile(QString path, AudioFileOpenMode mode) | 2697 MainWindow::openSomeFile(QString path, AudioFileOpenMode mode) |
2671 { | 2698 { |
2672 FileOpenStatus status; | 2699 FileOpenStatus status; |
2700 | |
2701 bool canImportLayer = (getMainModel() != 0 && | |
2702 m_paneStack != 0 && | |
2703 m_paneStack->getCurrentPane() != 0); | |
2673 | 2704 |
2674 if ((status = openAudioFile(path, mode)) != FileOpenFailed) { | 2705 if ((status = openAudioFile(path, mode)) != FileOpenFailed) { |
2675 return status; | 2706 return status; |
2676 } else if ((status = openSessionFile(path)) != FileOpenFailed) { | 2707 } else if ((status = openSessionFile(path)) != FileOpenFailed) { |
2677 return status; | 2708 return status; |
2709 } else if (!canImportLayer) { | |
2710 return FileOpenFailed; | |
2711 } else if ((status = openLayerFile(path)) != FileOpenFailed) { | |
2712 return status; | |
2678 } else { | 2713 } else { |
2679 return FileOpenFailed; | 2714 return FileOpenFailed; |
2680 } | 2715 } |
2681 } | 2716 } |
2682 | 2717 |