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;
29
30using TrackHolders = std::vector<std::shared_ptr<Track>>;
31
32class AUDACITY_DLL_API ProjectFileManager final
33 : public ClientData::Base
34{
35public:
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
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
99 Import(const std::vector<FilePath>& fileNames, bool addToHistory = true);
100 bool Import(const FilePath& fileName, bool addToHistory = true);
101
102 void Compact();
103
104 void AddImportedTracks(const FilePath &fileName,
105 TrackHolders &&newTracks);
106
107 bool GetMenuClose() const { return mMenuClose; }
108 void SetMenuClose(bool value) { mMenuClose = value; }
109
116 static void FixTracks(TrackList& tracks,
117 const std::function<void(const TranslatableString&/*errorMessage*/)>& onError,
118 const std::function<void(const TranslatableString&/*unlinkReason*/)>& onUnlink);
119
120private:
121 bool Import(
122 const FilePath& fileName, bool addToHistory,
123 std::shared_ptr<ClipMirAudioReader>& resultingReader);
124
130 AudacityProject *OpenProjectFile(
131 const FilePath &fileName, bool addtohistory);
132
134 {
138 wxString helpUrl;
139 };
140 ReadProjectResults ReadProjectFile(
141 const FilePath &fileName, bool discardAutosave = false );
142
143 bool DoSave(const FilePath & fileName, bool fromSaveAs);
144
146
147 std::shared_ptr<TrackList> mLastSavedTracks;
148
149 // Are we currently closing as the result of a menu command?
150 bool mMenuClose{ false };
151};
152
153class wxTopLevelWindow;
154
158public:
159 TitleRestorer( wxTopLevelWindow &window, AudacityProject &project );
161 wxString sProjNumber;
162 wxString sProjName;
164};
165
166#endif
wxT("CloseDown"))
Utility ClientData::Site to register hooks into a host class that attach client data.
std::vector< std::shared_ptr< Track > > TrackHolders
Definition: ImportRaw.h:24
wxString FilePath
Definition: Project.h:21
const auto tracks
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
std::shared_ptr< TrackList > mLastSavedTracks
AudacityProject & mProject
ProjectFileManager(const ProjectFileManager &)=delete
ProjectFileManager & operator=(const ProjectFileManager &)=delete
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)
TitleRestorer(wxTopLevelWindow &window, AudacityProject &project)
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
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:201
A convenient default parameter for class template Site.
Definition: ClientData.h:29