7a9dcfa8fc
big thanks to Martynas Venckus for his work on regression tests "go ahead!" jasper@
237 lines
6.9 KiB
Plaintext
237 lines
6.9 KiB
Plaintext
$OpenBSD: patch-src_DirManager_cpp,v 1.1 2006/12/17 12:12:59 ajacoutot Exp $
|
|
--- src/DirManager.cpp.orig Sun Oct 29 02:05:26 2006
|
|
+++ src/DirManager.cpp Sat Dec 9 20:19:42 2006
|
|
@@ -69,7 +69,9 @@
|
|
#include "blockfile/PCMAliasBlockFile.h"
|
|
#include "DirManager.h"
|
|
#include "Internat.h"
|
|
+#ifndef NO_PROJECT_LEVEL
|
|
#include "Project.h"
|
|
+#endif
|
|
#include "Prefs.h"
|
|
#include "widgets/Warning.h"
|
|
#include "widgets/MultiDialog.h"
|
|
@@ -163,9 +165,13 @@ static int rm_dash_rf_enumerate_i(wxStri
|
|
wxString dirspec,
|
|
int files_p,int dirs_p,
|
|
int progress_count,int progress_bias,
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ const wxChar *prompt, wxProgressDialog **progress){
|
|
+#else
|
|
const wxChar *prompt){
|
|
|
|
AudacityProject *p = GetActiveProject();
|
|
+#endif
|
|
int count=0;
|
|
bool cont;
|
|
|
|
@@ -183,9 +189,24 @@ static int rm_dash_rf_enumerate_i(wxStri
|
|
|
|
cont = dir.GetNext(&name);
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ if (prompt && progress && !*progress && wxGetElapsedTime(false) > 500)
|
|
+ *progress =
|
|
+ new wxProgressDialog(_("Progress"),
|
|
+ prompt,
|
|
+ 1000,
|
|
+ NULL,
|
|
+ wxPD_REMAINING_TIME | wxPD_AUTO_HIDE);
|
|
+
|
|
+ if (progress && *progress)
|
|
+ (*progress)->Update(int ((count+progress_bias * 1000.0) /
|
|
+ progress_count));
|
|
+
|
|
+#else
|
|
if (prompt && p)
|
|
p->ProgressUpdate(int ((count+progress_bias * 1000.0) /
|
|
progress_count));
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
@@ -194,7 +215,11 @@ static int rm_dash_rf_enumerate_i(wxStri
|
|
wxString subdirpath=dirpath + wxFILE_SEP_PATH + name;
|
|
count+=rm_dash_rf_enumerate_i(subdirpath,flist,wxEmptyString,
|
|
files_p,dirs_p,progress_count,
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ count+progress_bias,prompt,progress);
|
|
+#else
|
|
count+progress_bias,prompt);
|
|
+#endif
|
|
cont = dir.GetNext(&name);
|
|
}
|
|
}
|
|
@@ -214,17 +239,29 @@ static int rm_dash_rf_enumerate_prompt(w
|
|
int files_p,int dirs_p,
|
|
int progress_count,
|
|
const wxChar *prompt){
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ wxProgressDialog *progress = NULL;
|
|
+ wxStartTimer();
|
|
+#else
|
|
AudacityProject *p = GetActiveProject();
|
|
|
|
if (p)
|
|
p->ProgressShow(_("Progress"), prompt);
|
|
+#endif
|
|
|
|
int count=rm_dash_rf_enumerate_i(dirpath, flist, dirspec, files_p,dirs_p,
|
|
progress_count,0,
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ prompt, &progress);
|
|
+
|
|
+ if (progress)
|
|
+ delete progress;
|
|
+#else
|
|
prompt);
|
|
|
|
if (p)
|
|
p->ProgressHide();
|
|
+#endif
|
|
|
|
return count;
|
|
}
|
|
@@ -235,7 +272,11 @@ static int rm_dash_rf_enumerate(wxString
|
|
int files_p,int dirs_p){
|
|
|
|
return rm_dash_rf_enumerate_i(dirpath, flist, dirspec, files_p,dirs_p,
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ 0,0,0,0);
|
|
+#else
|
|
0,0,NULL);
|
|
+#endif
|
|
|
|
}
|
|
|
|
@@ -244,10 +285,15 @@ static void rm_dash_rf_execute(wxArraySt
|
|
int count, int files_p, int dirs_p,
|
|
const wxChar *prompt){
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ wxProgressDialog *progress = NULL;
|
|
+ wxStartTimer();
|
|
+#else
|
|
AudacityProject *p = GetActiveProject();
|
|
|
|
if (prompt && p)
|
|
p->ProgressShow(_("Progress"), prompt);
|
|
+#endif
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
const wxChar *file = fList[i].c_str();
|
|
@@ -258,12 +304,30 @@ static void rm_dash_rf_execute(wxArraySt
|
|
wxRmdir(file);
|
|
}
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ if (prompt && !progress && wxGetElapsedTime(false) > 500)
|
|
+ progress =
|
|
+ new wxProgressDialog(_("Progress"),
|
|
+ prompt,
|
|
+ 1000,
|
|
+ NULL,
|
|
+ wxPD_REMAINING_TIME | wxPD_AUTO_HIDE);
|
|
+
|
|
+ if (progress)
|
|
+ progress->Update(int ((i * 1000.0) / count));
|
|
+#else
|
|
if (prompt && p)
|
|
p->ProgressUpdate(int ((i * 1000.0) / count));
|
|
+#endif
|
|
}
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ if (progress)
|
|
+ delete progress;
|
|
+#else
|
|
if (prompt && p)
|
|
p->ProgressHide();
|
|
+#endif
|
|
}
|
|
|
|
// static
|
|
@@ -326,13 +390,20 @@ bool DirManager::SetProject(wxString & p
|
|
saved version of the old project must not be moved,
|
|
otherwise the old project would not be safe. */
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ wxProgressDialog *progress = NULL;
|
|
+#else
|
|
AudacityProject *p = GetActiveProject();
|
|
if (p)
|
|
p->ProgressShow(_("Progress"),
|
|
_("Saving project data files"));
|
|
+#endif
|
|
|
|
int total=blockFileHash.size();
|
|
int count=0;
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ wxStartTimer();
|
|
+#endif
|
|
|
|
BlockHash::iterator i=blockFileHash.begin();
|
|
bool success = true;
|
|
@@ -345,8 +416,22 @@ bool DirManager::SetProject(wxString & p
|
|
success = MoveToNewProjectDirectory(b);
|
|
}
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ if (!progress && wxGetElapsedTime(false) > 500)
|
|
+ progress =
|
|
+ new wxProgressDialog(_("Progress"),
|
|
+ _("Saving project data files"),
|
|
+ 1000,
|
|
+ NULL,
|
|
+ wxPD_REMAINING_TIME |
|
|
+ wxPD_AUTO_HIDE);
|
|
+
|
|
+ if (progress)
|
|
+ progress->Update(int ((count * 1000.0) / total));
|
|
+#else
|
|
if (p)
|
|
p->ProgressUpdate(int ((count * 1000.0) / total));
|
|
+#endif
|
|
|
|
i++;
|
|
count++;
|
|
@@ -366,8 +451,13 @@ bool DirManager::SetProject(wxString & p
|
|
BlockFile *b = i->second;
|
|
MoveToNewProjectDirectory(b);
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ if (progress && count>=0)
|
|
+ progress->Update(int ((count * 1000.0) / total));
|
|
+#else
|
|
if (count>=0 && p)
|
|
p->ProgressUpdate(int ((count * 1000.0) / total));
|
|
+#endif
|
|
|
|
i++;
|
|
count--;
|
|
@@ -377,14 +467,24 @@ bool DirManager::SetProject(wxString & p
|
|
this->projPath = oldPath;
|
|
this->projName = oldName;
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ if (progress)
|
|
+ delete progress;
|
|
+#else
|
|
if (p)
|
|
p->ProgressHide();
|
|
+#endif
|
|
|
|
return false;
|
|
}
|
|
|
|
+#ifdef NO_PROJECT_LEVEL
|
|
+ if (progress)
|
|
+ delete progress;
|
|
+#else
|
|
if (p)
|
|
p->ProgressHide();
|
|
+#endif
|
|
|
|
// Some subtlety; SetProject is used both to move a temp project
|
|
// into a permanent home as well as just set up path variables when
|