diff 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
line wrap: on
line diff
--- a/data/fileio/FileFinder.h	Wed Jan 10 17:26:39 2007 +0000
+++ b/data/fileio/FileFinder.h	Thu Jan 11 13:29:58 2007 +0000
@@ -17,30 +17,38 @@
 #define _FILE_FINDER_H_
 
 #include <QString>
+#include <QObject>
 
-class FileFinder
+class FileFinder : public QObject
 {
+    Q_OBJECT
+
 public:
-    /**
-     * Find a file.
-     *
-     * "location" is what we know about where the file is supposed to
-     * be: it may be a relative path, an absolute path, a URL, or just
-     * a filename.
-     *
-     * "lastKnownLocation", if provided, is a path or URL of something
-     * that can be used as a reference point to locate it -- for
-     * example, the location of the session file that is referring to
-     * the file we're looking for.
-     */
-    FileFinder(QString location, QString lastKnownLocation = "");
     virtual ~FileFinder();
 
-    QString getLocation();
+    enum FileType {
+        SessionFile,
+        AudioFile,
+        LayerFile,
+        SessionOrAudioFile,
+        AnyFile
+    };
+
+    QString getOpenFileName(FileType type, QString fallbackLocation = "");
+    QString getSaveFileName(FileType type, QString fallbackLocation = "");
+    void registerLastOpenedFilePath(FileType type, QString path);
+
+    QString find(FileType type, QString location, QString lastKnownLocation = "");
+
+    static FileFinder *getInstance();
 
 protected:
-    QString m_location;
-    QString m_lastKnownLocation;
+    FileFinder();
+    static FileFinder *m_instance;
+
+    QString findRelative(QString location, QString relativeTo);
+    QString locateInteractive(FileType type, QString thing);
+
     QString m_lastLocatedLocation;
 };