svcore
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2009 QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _FILE_FINDER_H_ 00017 #define _FILE_FINDER_H_ 00018 00019 #include <QString> 00020 00021 class FileFinder 00022 { 00023 public: 00024 enum FileType { 00025 SessionFile, 00026 AudioFile, 00027 LayerFile, 00028 LayerFileNoMidi, 00029 SessionOrAudioFile, 00030 ImageFile, 00031 AnyFile, 00032 CSVFile, 00033 LayerFileNonSV, 00034 LayerFileNoMidiNonSV, 00035 }; 00036 00037 virtual QString getOpenFileName(FileType type, QString fallbackLocation = "") = 0; 00038 virtual QString getSaveFileName(FileType type, QString fallbackLocation = "") = 0; 00039 virtual void registerLastOpenedFilePath(FileType type, QString path) = 0; 00040 00041 virtual QString find(FileType type, QString location, QString lastKnownLocation = "") = 0; 00042 00043 static FileFinder *getInstance() { 00044 FFContainer *container = FFContainer::getInstance(); 00045 return container->getFileFinder(); 00046 } 00047 00048 protected: 00049 class FFContainer { 00050 public: 00051 static FFContainer *getInstance() { 00052 static FFContainer instance; 00053 return &instance; 00054 } 00055 void setFileFinder(FileFinder *ff) { m_ff = ff; } 00056 FileFinder *getFileFinder() const { return m_ff; } 00057 private: 00058 FileFinder *m_ff; 00059 }; 00060 00061 static void registerFileFinder(FileFinder *ff) { 00062 FFContainer *container = FFContainer::getInstance(); 00063 container->setFileFinder(ff); 00064 } 00065 }; 00066 00067 #endif 00068 00069