FileFinder.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2009 QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_FILE_FINDER_H
17 #define SV_FILE_FINDER_H
18 
19 #include <QString>
20 
21 class FileFinder
22 {
23 public:
24  enum FileType {
36  };
37 
38  virtual QString getOpenFileName(FileType type,
39  QString fallbackLocation = "") = 0;
40 
41  virtual QStringList getOpenFileNames(FileType type,
42  QString fallbackLocation = "") = 0;
43 
44  virtual QString getSaveFileName(FileType type,
45  QString fallbackLocation = "") = 0;
46 
47  virtual void registerLastOpenedFilePath(FileType type,
48  QString path) = 0;
49 
50  virtual QString find(FileType type,
51  QString location,
52  QString lastKnownLocation = "") = 0;
53 
54  static FileFinder *getInstance() {
56  return container->getFileFinder();
57  }
58 
59 protected:
60  class FFContainer {
61  public:
63  static FFContainer instance;
64  return &instance;
65  }
66  void setFileFinder(FileFinder *ff) { m_ff = ff; }
67  FileFinder *getFileFinder() const { return m_ff; }
68  private:
70  };
71 
72  static void registerFileFinder(FileFinder *ff) {
74  container->setFileFinder(ff);
75  }
76 };
77 
78 #endif
79 
80 
virtual QString getSaveFileName(FileType type, QString fallbackLocation="")=0
static FileFinder * getInstance()
Definition: FileFinder.h:54
virtual QStringList getOpenFileNames(FileType type, QString fallbackLocation="")=0
void setFileFinder(FileFinder *ff)
Definition: FileFinder.h:66
virtual QString find(FileType type, QString location, QString lastKnownLocation="")=0
virtual QString getOpenFileName(FileType type, QString fallbackLocation="")=0
static FFContainer * getInstance()
Definition: FileFinder.h:62
static void registerFileFinder(FileFinder *ff)
Definition: FileFinder.h:72
FileFinder * getFileFinder() const
Definition: FileFinder.h:67
virtual void registerLastOpenedFilePath(FileType type, QString path)=0