Chris@582: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@582: 
Chris@582: /*
Chris@582:     Sonic Visualiser
Chris@582:     An audio file viewer and annotation editor.
Chris@582:     Centre for Digital Music, Queen Mary, University of London.
Chris@582:     This file copyright 2009 QMUL.
Chris@582:     
Chris@582:     This program is free software; you can redistribute it and/or
Chris@582:     modify it under the terms of the GNU General Public License as
Chris@582:     published by the Free Software Foundation; either version 2 of the
Chris@582:     License, or (at your option) any later version.  See the file
Chris@582:     COPYING included with this distribution for more information.
Chris@582: */
Chris@582: 
Chris@1332: #ifndef SV_FILE_FINDER_H
Chris@1332: #define SV_FILE_FINDER_H
Chris@582: 
Chris@582: #include <QString>
Chris@582: 
Chris@582: class FileFinder 
Chris@582: {
Chris@582: public:
Chris@582:     enum FileType {
Chris@582:         SessionFile,
Chris@582:         AudioFile,
Chris@582:         LayerFile,
Chris@582:         LayerFileNoMidi,
Chris@582:         SessionOrAudioFile,
Chris@582:         ImageFile,
Chris@1332:         SVGFile,
Chris@837:         AnyFile,
Chris@837:         CSVFile,
Chris@858:         LayerFileNonSV,
Chris@858:         LayerFileNoMidiNonSV,
Chris@582:     };
Chris@582: 
Chris@1690:     virtual QString getOpenFileName(FileType type,
Chris@1690:                                     QString fallbackLocation = "") = 0;
Chris@582: 
Chris@1690:     virtual QStringList getOpenFileNames(FileType type,
Chris@1690:                                          QString fallbackLocation = "") = 0;
Chris@1690: 
Chris@1690:     virtual QString getSaveFileName(FileType type,
Chris@1690:                                     QString fallbackLocation = "") = 0;
Chris@1690: 
Chris@1690:     virtual void registerLastOpenedFilePath(FileType type,
Chris@1690:                                             QString path) = 0;
Chris@1690: 
Chris@1690:     virtual QString find(FileType type,
Chris@1690:                          QString location,
Chris@1690:                          QString lastKnownLocation = "") = 0;
Chris@582: 
Chris@622:     static FileFinder *getInstance() {
Chris@622:         FFContainer *container = FFContainer::getInstance();
Chris@622:         return container->getFileFinder();
Chris@622:     }
Chris@582: 
Chris@582: protected:
Chris@622:     class FFContainer {
Chris@622:     public:
Chris@622:         static FFContainer *getInstance() {
Chris@622:             static FFContainer instance;
Chris@622:             return &instance;
Chris@622:         }
Chris@622:         void setFileFinder(FileFinder *ff) { m_ff = ff; }
Chris@622:         FileFinder *getFileFinder() const { return m_ff; }
Chris@622:     private:
Chris@622:         FileFinder *m_ff;
Chris@622:     };
Chris@622: 
Chris@622:     static void registerFileFinder(FileFinder *ff) {
Chris@622:         FFContainer *container = FFContainer::getInstance();
Chris@622:         container->setFileFinder(ff);
Chris@622:     }
Chris@582: };
Chris@582: 
Chris@582: #endif
Chris@582: 
Chris@582: