Audacity 3.2.0
ProjectFileManager.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectFileManager.h
6
7Paul Licameli split from AudacityProject.h
8
9**********************************************************************/
10
11#ifndef __AUDACITY_PROJECT_FILE_MANAGER__
12#define __AUDACITY_PROJECT_FILE_MANAGER__
13
14#include <functional>
15#include <memory>
16#include <vector>
17
18#include "ClientData.h" // to inherit
19#include "FileNames.h" // for FileType
20
21class wxString;
22class wxFileName;
23class AudacityProject;
24class Track;
25class TrackList;
26class WaveTrack;
27class XMLTagHandler;
28
29using WaveTrackArray = std::vector < std::shared_ptr < WaveTrack > >;
30using TrackHolders = std::vector< WaveTrackArray >;
31
32class AUDACITY_DLL_API ProjectFileManager final
33 : public ClientData::Base
34{
35public:
36 static ProjectFileManager &Get( AudacityProject &project );
37 static const ProjectFileManager &Get( const AudacityProject &project );
38
39 // Open and close a file, invisibly, removing its Autosave blob
40 static void DiscardAutosave(const FilePath &filename);
41
42 explicit ProjectFileManager( AudacityProject &project );
46
47 bool OpenProject();
48 void CloseProject();
49 bool OpenNewProject();
50
51 void CompactProjectOnClose();
52
53 bool Save();
54 bool SaveAs(bool allowOverwrite = false);
55 bool SaveAs(const FilePath &newFileName, bool addToHistory = true);
56 // strProjectPathName is full path for aup except extension
57 bool SaveFromTimerRecording( wxFileName fnFile );
58 bool SaveCopy(const FilePath &fileName = wxT(""));
59
80 static wxArrayString ShowOpenDialog(FileNames::Operation op,
81 const FileNames::FileType &extraType = {});
82
83 static bool IsAlreadyOpen(const FilePath &projPathName);
84
86 using ProjectChooserFn = std::function<AudacityProject&(bool)>;
87
95 static AudacityProject *OpenFile( const ProjectChooserFn &chooser,
96 const FilePath &fileName, bool addtohistory = true);
97
98 bool Import(const FilePath &fileName,
99 bool addToHistory = true);
100
101 void Compact();
102
103 void AddImportedTracks(const FilePath &fileName,
104 TrackHolders &&newTracks);
105
106 bool GetMenuClose() const { return mMenuClose; }
107 void SetMenuClose(bool value) { mMenuClose = value; }
108
109private:
115 AudacityProject *OpenProjectFile(
116 const FilePath &fileName, bool addtohistory);
117
119 {
123 wxString helpUrl;
124 };
125 ReadProjectResults ReadProjectFile(
126 const FilePath &fileName, bool discardAutosave = false );
127
128 bool DoSave(const FilePath & fileName, bool fromSaveAs);
129
131
132 std::shared_ptr<TrackList> mLastSavedTracks;
133
134 // Are we currently closing as the result of a menu command?
135 bool mMenuClose{ false };
136};
137
138#endif
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:49
Utility ClientData::Site to register hooks into a host class that attach client data.
std::vector< std::vector< std::shared_ptr< WaveTrack > > > TrackHolders
Definition: Import.h:39
wxString FilePath
Definition: Project.h:20
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
std::shared_ptr< TrackList > mLastSavedTracks
AudacityProject & mProject
ProjectFileManager(const ProjectFileManager &) PROHIBITED
std::function< AudacityProject &(bool)> ProjectChooserFn
A function that returns a project to use for opening a file; argument is true if opening a project fi...
void SetMenuClose(bool value)
ProjectFileManager & operator=(const ProjectFileManager &) PROHIBITED
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1330
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
A convenient default parameter for class template Site.
Definition: ClientData.h:28