mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 08:30:06 +02:00
Fix for bug #992 and add total space used to History
This commit is contained in:
parent
9987ac2020
commit
4b9d81f228
@ -38,6 +38,7 @@ undo memory so as to free up space.
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
ID_AVAIL = 1000,
|
ID_AVAIL = 1000,
|
||||||
|
ID_TOTAL,
|
||||||
ID_LEVELS,
|
ID_LEVELS,
|
||||||
ID_DISCARD
|
ID_DISCARD
|
||||||
};
|
};
|
||||||
@ -71,7 +72,7 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
|
|||||||
S.SetBorder(5);
|
S.SetBorder(5);
|
||||||
S.StartVerticalLay(true);
|
S.StartVerticalLay(true);
|
||||||
{
|
{
|
||||||
S.StartStatic(_("Manage History"), 1);
|
S.StartStatic(_("&Manage History"), 1);
|
||||||
{
|
{
|
||||||
mList = S.AddListControlReportMode();
|
mList = S.AddListControlReportMode();
|
||||||
// Do this BEFORE inserting the columns. On the Mac at least, the
|
// 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);
|
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 = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10);
|
||||||
mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
|
mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
|
||||||
S.AddVariableText(wxT(""))->Hide();
|
S.AddVariableText(wxT(""))->Hide();
|
||||||
}
|
|
||||||
|
|
||||||
{
|
S.AddPrompt(_("&Levels To Discard"));
|
||||||
S.AddPrompt(_("Levels To Discard"));
|
|
||||||
mLevels = new wxSpinCtrl(this,
|
mLevels = new wxSpinCtrl(this,
|
||||||
ID_LEVELS,
|
ID_LEVELS,
|
||||||
wxT("1"),
|
wxT("1"),
|
||||||
@ -146,15 +149,18 @@ void HistoryWindow::DoUpdate()
|
|||||||
|
|
||||||
mList->DeleteAllItems();
|
mList->DeleteAllItems();
|
||||||
|
|
||||||
|
wxLongLong_t total = 0;
|
||||||
mSelected = mManager->GetCurrentState() - 1;
|
mSelected = mManager->GetCurrentState() - 1;
|
||||||
for (i = 0; i < (int)mManager->GetNumStates(); i++) {
|
for (i = 0; i < (int)mManager->GetNumStates(); i++) {
|
||||||
wxString desc, size;
|
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->InsertItem(i, desc, i == mSelected ? 1 : 0);
|
||||||
mList->SetItem(i, 1, size);
|
mList->SetItem(i, 1, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mTotal->SetValue(Internat::FormatSize(total));
|
||||||
|
|
||||||
mList->EnsureVisible(mSelected);
|
mList->EnsureVisible(mSelected);
|
||||||
|
|
||||||
mList->SetItemState(mSelected,
|
mList->SetItemState(mSelected,
|
||||||
|
@ -44,6 +44,7 @@ class HistoryWindow :public wxDialog {
|
|||||||
AudacityProject *mProject;
|
AudacityProject *mProject;
|
||||||
UndoManager *mManager;
|
UndoManager *mManager;
|
||||||
wxListCtrl *mList;
|
wxListCtrl *mList;
|
||||||
|
wxTextCtrl *mTotal;
|
||||||
wxTextCtrl *mAvail;
|
wxTextCtrl *mAvail;
|
||||||
wxSpinCtrl *mLevels;
|
wxSpinCtrl *mLevels;
|
||||||
wxButton *mDiscard;
|
wxButton *mDiscard;
|
||||||
|
@ -87,7 +87,7 @@ void UndoManager::CalculateSpaceUsage()
|
|||||||
|
|
||||||
// Accumulate space used by the file if the file didn't exist
|
// Accumulate space used by the file if the file didn't exist
|
||||||
// in the previous level
|
// in the previous level
|
||||||
if (!prev->count(file))
|
if (prev->count(file) == 0 && cur->count(file) == 0)
|
||||||
{
|
{
|
||||||
space[i] += file->GetSpaceUsage().GetValue();
|
space[i] += file->GetSpaceUsage().GetValue();
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ void UndoManager::CalculateSpaceUsage()
|
|||||||
TIMER_STOP( space_calc );
|
TIMER_STOP( space_calc );
|
||||||
}
|
}
|
||||||
|
|
||||||
void UndoManager::GetLongDescription(unsigned int n, wxString *desc,
|
wxLongLong_t UndoManager::GetLongDescription(unsigned int n, wxString *desc,
|
||||||
wxString *size)
|
wxString *size)
|
||||||
{
|
{
|
||||||
n -= 1; // 1 based to zero based
|
n -= 1; // 1 based to zero based
|
||||||
@ -119,6 +119,8 @@ void UndoManager::GetLongDescription(unsigned int n, wxString *desc,
|
|||||||
*desc = stack[n]->description;
|
*desc = stack[n]->description;
|
||||||
|
|
||||||
*size = Internat::FormatSize(space[n]);
|
*size = Internat::FormatSize(space[n]);
|
||||||
|
|
||||||
|
return space[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
void UndoManager::GetShortDescription(unsigned int n, wxString *desc)
|
void UndoManager::GetShortDescription(unsigned int n, wxString *desc)
|
||||||
|
@ -64,7 +64,9 @@ struct UndoStackElem {
|
|||||||
};
|
};
|
||||||
|
|
||||||
WX_DEFINE_USER_EXPORTED_ARRAY(UndoStackElem *, UndoStack, class AUDACITY_DLL_API);
|
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
|
// These flags control what extra to do on a PushState
|
||||||
// Default is PUSH_AUTOSAVE
|
// Default is PUSH_AUTOSAVE
|
||||||
@ -91,7 +93,7 @@ class AUDACITY_DLL_API UndoManager {
|
|||||||
unsigned int GetCurrentState();
|
unsigned int GetCurrentState();
|
||||||
|
|
||||||
void GetShortDescription(unsigned int n, wxString *desc);
|
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);
|
void SetLongDescription(unsigned int n, wxString desc);
|
||||||
|
|
||||||
TrackList *SetStateTo(unsigned int n, SelectedRegion *selectedRegion);
|
TrackList *SetStateTo(unsigned int n, SelectedRegion *selectedRegion);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user