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