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 bool ImportAndArrange(
102 // wxArrayString because that's the readily available type where this
103 // method is used, no other reason
104 wxArrayString fileNames);
105
106 void Compact();
107
108 void AddImportedTracks(const FilePath &fileName,
109 TrackHolders &&newTracks);
110
111 bool GetMenuClose() const { return mMenuClose; }
112 void SetMenuClose(bool value) { mMenuClose = value; }
113
120 static void FixTracks(TrackList& tracks,
121 const std::function<void(const TranslatableString&/*errorMessage*/)>& onError,
122 const std::function<void(const TranslatableString&/*unlinkReason*/)>& onUnlink);
123
124private:
125 bool Import(
126 const FilePath& fileName, bool addToHistory,
127 std::shared_ptr<ClipMirAudioReader>& resultingReader);
128
134 AudacityProject *OpenProjectFile(
135 const FilePath &fileName, bool addtohistory);
136
138 {
142 wxString helpUrl;
143 };
144 ReadProjectResults ReadProjectFile(
145 const FilePath &fileName, bool discardAutosave = false );
146
147 bool DoSave(const FilePath & fileName, bool fromSaveAs);
148
150
151 std::shared_ptr<TrackList> mLastSavedTracks;
152
153 // Are we currently closing as the result of a menu command?
154 bool mMenuClose{ false };
155};
156
157class wxTopLevelWindow;
158
162public:
163 TitleRestorer( wxTopLevelWindow &window, AudacityProject &project );
165 wxString sProjNumber;
166 wxString sProjName;
168};
169
170#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:202
A convenient default parameter for class template Site.
Definition: ClientData.h:29