Audacity 3.2.0
ProjectHistory.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectHistory.h
6
7Paul Licameli split from ProjectManager.h
8
9**********************************************************************/
10
11#ifndef __AUDACITY_PROJECT_HISTORY__
12#define __AUDACITY_PROJECT_HISTORY__
13
14#include "ClientData.h"
15#include "GlobalVariable.h"
16
17class AudacityProject;
18struct UndoState;
19enum class UndoPush : unsigned char;
20
21class PROJECT_HISTORY_API ProjectHistory final
22 : public ClientData::Base
23{
24public:
27
31 struct PROJECT_HISTORY_API AutoSave : GlobalHook<AutoSave,
32 void(AudacityProject &)
33 > {};
34
35 static ProjectHistory &Get( AudacityProject &project );
36 static const ProjectHistory &Get( const AudacityProject &project );
37
38 explicit ProjectHistory( AudacityProject &project )
39 : mProject{ project }
40 {}
41 ProjectHistory( const ProjectHistory & ) = delete;
43 ~ProjectHistory() override;
44
45 void InitialState();
46 void SetStateTo(unsigned int n, bool doAutosave = true);
47 bool UndoAvailable() const;
48 bool RedoAvailable() const;
49 void PushState(
51 const TranslatableString &shortDesc); // use UndoPush::AUTOSAVE
52 void PushState(
54 const TranslatableString &shortDesc, UndoPush flags);
55 void RollbackState();
56 void ModifyState(bool bWantsAutoSave); // if true, writes auto-save file.
57 // Should set only if you really want the state change restored after
58 // a crash, as it can take many seconds for large (eg. 10 track-hours)
59 // projects
60 void PopState(const UndoState &state, bool doAutosave = true);
61
62 bool GetDirty() const { return mDirty; }
63 void SetDirty( bool value ) { mDirty = value; }
64
65private:
67
68 bool mDirty{ false };
69};
70
71#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
const TranslatableString desc
Definition: ExportPCM.cpp:58
UndoPush
Definition: UndoManager.h:150
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
Global function-valued variable, adding a convenient Call()
~ProjectHistory() override
bool GetDirty() const
ProjectHistory(AudacityProject &project)
ProjectHistory(const ProjectHistory &)=delete
void SetDirty(bool value)
ProjectHistory & operator=(const ProjectHistory &)=delete
AudacityProject & mProject
Holds a msgid for the translation catalog; may also bind format arguments.
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