comparison data/fileio/FileFinder.h @ 211:e2bbb58e6df6

Several changes related to referring to remote URLs for sessions and files: * Pull file dialog wrapper functions out from MainWindow into FileFinder * If a file referred to in a session is not found at its expected location, try a few other alternatives (same location as the session file or same location as the last audio file) before asking the user to locate it * Allow user to give a URL when locating an audio file, not just locate on the filesystem * Make wave file models remember the "original" location (e.g. URL) of the audio file, not just the actual location from which the data was loaded (e.g. local copy of that URL) -- when saving a session, use the original location so as not to refer to a temporary file * Clean up incompletely-downloaded local copies of files
author Chris Cannam
date Thu, 11 Jan 2007 13:29:58 +0000
parents a06afefe45ee
children 40db5491bcf8
comparison
equal deleted inserted replaced
210:a06afefe45ee 211:e2bbb58e6df6
15 15
16 #ifndef _FILE_FINDER_H_ 16 #ifndef _FILE_FINDER_H_
17 #define _FILE_FINDER_H_ 17 #define _FILE_FINDER_H_
18 18
19 #include <QString> 19 #include <QString>
20 #include <QObject>
20 21
21 class FileFinder 22 class FileFinder : public QObject
22 { 23 {
24 Q_OBJECT
25
23 public: 26 public:
24 /**
25 * Find a file.
26 *
27 * "location" is what we know about where the file is supposed to
28 * be: it may be a relative path, an absolute path, a URL, or just
29 * a filename.
30 *
31 * "lastKnownLocation", if provided, is a path or URL of something
32 * that can be used as a reference point to locate it -- for
33 * example, the location of the session file that is referring to
34 * the file we're looking for.
35 */
36 FileFinder(QString location, QString lastKnownLocation = "");
37 virtual ~FileFinder(); 27 virtual ~FileFinder();
38 28
39 QString getLocation(); 29 enum FileType {
30 SessionFile,
31 AudioFile,
32 LayerFile,
33 SessionOrAudioFile,
34 AnyFile
35 };
36
37 QString getOpenFileName(FileType type, QString fallbackLocation = "");
38 QString getSaveFileName(FileType type, QString fallbackLocation = "");
39 void registerLastOpenedFilePath(FileType type, QString path);
40
41 QString find(FileType type, QString location, QString lastKnownLocation = "");
42
43 static FileFinder *getInstance();
40 44
41 protected: 45 protected:
42 QString m_location; 46 FileFinder();
43 QString m_lastKnownLocation; 47 static FileFinder *m_instance;
48
49 QString findRelative(QString location, QString relativeTo);
50 QString locateInteractive(FileType type, QString thing);
51
44 QString m_lastLocatedLocation; 52 QString m_lastLocatedLocation;
45 }; 53 };
46 54
47 #endif 55 #endif
48 56