1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 00:20:06 +02:00

Fix for bug #992 and add total space used to History

This commit is contained in:
Leland Lucius 2015-05-30 15:56:46 -05:00
parent 9987ac2020
commit 4b9d81f228
4 changed files with 21 additions and 10 deletions

View File

@ -38,6 +38,7 @@ undo memory so as to free up space.
enum {
ID_AVAIL = 1000,
ID_TOTAL,
ID_LEVELS,
ID_DISCARD
};
@ -71,7 +72,7 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
S.SetBorder(5);
S.StartVerticalLay(true);
{
S.StartStatic(_("Manage History"), 1);
S.StartStatic(_("&Manage History"), 1);
{
mList = S.AddListControlReportMode();
// Do this BEFORE inserting the columns. On the Mac at least, the
@ -85,13 +86,15 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
S.StartMultiColumn(3, wxCENTRE);
{
mTotal = S.Id(ID_TOTAL).AddTextBox(_("&Total space used"), wxT("0"), 10);
mTotal->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
S.AddVariableText(wxT(""))->Hide();
mAvail = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10);
mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
S.AddVariableText(wxT(""))->Hide();
}
{
S.AddPrompt(_("Levels To Discard"));
S.AddPrompt(_("&Levels To Discard"));
mLevels = new wxSpinCtrl(this,
ID_LEVELS,
wxT("1"),
@ -146,15 +149,18 @@ void HistoryWindow::DoUpdate()
mList->DeleteAllItems();
wxLongLong_t total = 0;
mSelected = mManager->GetCurrentState() - 1;
for (i = 0; i < (int)mManager->GetNumStates(); i++) {
wxString desc, size;
mManager->GetLongDescription(i + 1, &desc, &size);
total += mManager->GetLongDescription(i + 1, &desc, &size);
mList->InsertItem(i, desc, i == mSelected ? 1 : 0);
mList->SetItem(i, 1, size);
}
mTotal->SetValue(Internat::FormatSize(total));
mList->EnsureVisible(mSelected);
mList->SetItemState(mSelected,

View File

@ -44,6 +44,7 @@ class HistoryWindow :public wxDialog {
AudacityProject *mProject;
UndoManager *mManager;
wxListCtrl *mList;
wxTextCtrl *mTotal;
wxTextCtrl *mAvail;
wxSpinCtrl *mLevels;
wxButton *mDiscard;

View File

@ -87,7 +87,7 @@ void UndoManager::CalculateSpaceUsage()
// Accumulate space used by the file if the file didn't exist
// in the previous level
if (!prev->count(file))
if (prev->count(file) == 0 && cur->count(file) == 0)
{
space[i] += file->GetSpaceUsage().GetValue();
}
@ -108,8 +108,8 @@ void UndoManager::CalculateSpaceUsage()
TIMER_STOP( space_calc );
}
void UndoManager::GetLongDescription(unsigned int n, wxString *desc,
wxString *size)
wxLongLong_t UndoManager::GetLongDescription(unsigned int n, wxString *desc,
wxString *size)
{
n -= 1; // 1 based to zero based
@ -119,6 +119,8 @@ void UndoManager::GetLongDescription(unsigned int n, wxString *desc,
*desc = stack[n]->description;
*size = Internat::FormatSize(space[n]);
return space[n];
}
void UndoManager::GetShortDescription(unsigned int n, wxString *desc)

View File

@ -64,7 +64,9 @@ struct UndoStackElem {
};
WX_DEFINE_USER_EXPORTED_ARRAY(UndoStackElem *, UndoStack, class AUDACITY_DLL_API);
WX_DEFINE_USER_EXPORTED_ARRAY_SIZE_T(size_t, SpaceArray, class AUDACITY_DLL_API);
// wxWidgets arrays have a base size and to use wxLongLong_t we need to use DOUBLE
// to ensure we get a size big enough to hold a wxLongLong_t.
WX_DEFINE_USER_EXPORTED_ARRAY_DOUBLE(wxLongLong_t, SpaceArray, class AUDACITY_DLL_API);
// These flags control what extra to do on a PushState
// Default is PUSH_AUTOSAVE
@ -91,7 +93,7 @@ class AUDACITY_DLL_API UndoManager {
unsigned int GetCurrentState();
void GetShortDescription(unsigned int n, wxString *desc);
void GetLongDescription(unsigned int n, wxString *desc, wxString *size);
wxLongLong_t GetLongDescription(unsigned int n, wxString *desc, wxString *size);
void SetLongDescription(unsigned int n, wxString desc);
TrackList *SetStateTo(unsigned int n, SelectedRegion *selectedRegion);