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 Import(const FilePath& fileName, bool addToHistory = true);
99 bool Import(wxArrayString fileNames, 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
115 static void FixTracks(TrackList& tracks,
116 const std::function<void(const TranslatableString&/*errorMessage*/)>& onError,
117 const std::function<void(const TranslatableString&/*unlinkReason*/)>& onUnlink);
118
119private:
120 bool ImportAndRunTempoDetection(
121 const std::vector<FilePath>& fileNames, bool addToHistory);
122
123 bool DoImport(
124 const FilePath& fileName, bool addToHistory,
125 std::shared_ptr<ClipMirAudioReader>& resultingReader);
126
132 AudacityProject *OpenProjectFile(
133 const FilePath &fileName, bool addtohistory);
134
136 {
140 wxString helpUrl;
141 };
142 ReadProjectResults ReadProjectFile(
143 const FilePath &fileName, bool discardAutosave = false );
144
145 bool DoSave(const FilePath & fileName, bool fromSaveAs);
146
148
149 std::shared_ptr<TrackList> mLastSavedTracks;
150
151 // Are we currently closing as the result of a menu command?
152 bool mMenuClose{ false };
153};
154
155class wxTopLevelWindow;
156
160public:
161 TitleRestorer( wxTopLevelWindow &window, AudacityProject &project );
163 wxString sProjNumber;
164 wxString sProjName;
166};
167
168#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
void DoImport(const CommandContext &context, bool isRaw)
Definition: FileMenus.cpp:138
A convenient default parameter for class template Site.
Definition: ClientData.h:29