Audacity 3.2.0
FileHistory.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 FileHistory.h
6
7 Leland Lucius
8
9**********************************************************************/
10
11#ifndef __AUDACITY_WIDGETS_FILEHISTORY__
12#define __AUDACITY_WIDGETS_FILEHISTORY__
13
14#include <vector>
15#include <algorithm>
16#include <wx/defs.h>
17#include <wx/weakref.h> // member variable
18
19#include "Identifier.h"
20#include "wxArrayStringEx.h"
21
22namespace audacity
23{
24 class BasicSettings;
25}
26
27class wxMenu;
28
29class AUDACITY_DLL_API FileHistory
30{
31 public:
32 FileHistory(size_t maxfiles = 12, wxWindowID idbase = wxID_FILE);
33 virtual ~FileHistory();
34 FileHistory( const FileHistory& ) = delete;
35 FileHistory &operator =( const FileHistory & ) = delete;
36
37 // These constants define the range of IDs reserved by the global file history
38 enum {
39 ID_RECENT_CLEAR = 6100,
40 ID_RECENT_FIRST = 6101,
41 ID_RECENT_LAST = 6112
42 };
43
44 static FileHistory &Global();
45
46 void Append( const FilePath &file )
47 { AddFileToHistory( file, true ); }
48 void Remove( size_t i );
49 void Clear();
50
51 // Causes this menu to reflect the contents of this FileHistory, now and
52 // also whenever the history changes.
53 void UseMenu(wxMenu *menu);
54
55 void Load(audacity::BasicSettings& config, const wxString & group = wxEmptyString);
56 void Save(audacity::BasicSettings& config);
57
58 // stl-style accessors
59 using const_iterator = FilePaths::const_iterator;
60 const_iterator begin() const { return mHistory.begin(); }
61 const_iterator end() const { return mHistory.end(); }
62 const FilePath &operator[] ( size_t ii ) const { return mHistory[ ii ]; }
63 bool empty() const { return mHistory.empty(); }
64
65 private:
66 void AddFileToHistory(const FilePath & file, bool update);
67 void NotifyMenus();
68 void NotifyMenu(wxMenu *menu);
69
70 void Compress();
71
72 size_t mMaxFiles;
73 wxWindowID mIDBase;
74
75 std::vector< wxWeakRef< wxMenu > > mMenus;
77
78 wxString mGroup;
79};
80
81#endif
wxString FilePath
Definition: Project.h:21
Similar to wxFileHistory, but customized to our needs.
Definition: FileHistory.h:30
const_iterator begin() const
Definition: FileHistory.h:60
FileHistory(const FileHistory &)=delete
wxString mGroup
Definition: FileHistory.h:78
FilePaths mHistory
Definition: FileHistory.h:76
bool empty() const
Definition: FileHistory.h:63
wxWindowID mIDBase
Definition: FileHistory.h:73
FilePaths::const_iterator const_iterator
Definition: FileHistory.h:59
void Append(const FilePath &file)
Definition: FileHistory.h:46
size_t mMaxFiles
Definition: FileHistory.h:72
const_iterator end() const
Definition: FileHistory.h:61
std::vector< wxWeakRef< wxMenu > > mMenus
Definition: FileHistory.h:75
Base class for objects that provide facility to store data persistently, and access it with string ke...
Definition: BasicSettings.h:31
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
PROJECT_FILE_IO_API void Remove(const FilePath &path)
THEME_RESOURCES_API void Load()