annotate 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
rev   line source
Chris@210 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@210 2
Chris@210 3 /*
Chris@210 4 Sonic Visualiser
Chris@210 5 An audio file viewer and annotation editor.
Chris@210 6 Centre for Digital Music, Queen Mary, University of London.
Chris@210 7 This file copyright 2007 QMUL.
Chris@210 8
Chris@210 9 This program is free software; you can redistribute it and/or
Chris@210 10 modify it under the terms of the GNU General Public License as
Chris@210 11 published by the Free Software Foundation; either version 2 of the
Chris@210 12 License, or (at your option) any later version. See the file
Chris@210 13 COPYING included with this distribution for more information.
Chris@210 14 */
Chris@210 15
Chris@210 16 #ifndef _FILE_FINDER_H_
Chris@210 17 #define _FILE_FINDER_H_
Chris@210 18
Chris@210 19 #include <QString>
Chris@211 20 #include <QObject>
Chris@210 21
Chris@211 22 class FileFinder : public QObject
Chris@210 23 {
Chris@211 24 Q_OBJECT
Chris@211 25
Chris@210 26 public:
Chris@210 27 virtual ~FileFinder();
Chris@210 28
Chris@211 29 enum FileType {
Chris@211 30 SessionFile,
Chris@211 31 AudioFile,
Chris@211 32 LayerFile,
Chris@211 33 SessionOrAudioFile,
Chris@211 34 AnyFile
Chris@211 35 };
Chris@211 36
Chris@211 37 QString getOpenFileName(FileType type, QString fallbackLocation = "");
Chris@211 38 QString getSaveFileName(FileType type, QString fallbackLocation = "");
Chris@211 39 void registerLastOpenedFilePath(FileType type, QString path);
Chris@211 40
Chris@211 41 QString find(FileType type, QString location, QString lastKnownLocation = "");
Chris@211 42
Chris@211 43 static FileFinder *getInstance();
Chris@210 44
Chris@210 45 protected:
Chris@211 46 FileFinder();
Chris@211 47 static FileFinder *m_instance;
Chris@211 48
Chris@211 49 QString findRelative(QString location, QString relativeTo);
Chris@211 50 QString locateInteractive(FileType type, QString thing);
Chris@211 51
Chris@210 52 QString m_lastLocatedLocation;
Chris@210 53 };
Chris@210 54
Chris@210 55 #endif
Chris@210 56