mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-18 09:00:07 +02:00
AUP3: Experiment to see if it helps active project tracking
This commit is contained in:
parent
bfa17b7b69
commit
4b0038c290
@ -15,12 +15,34 @@
|
|||||||
#include "ActiveProjects.h"
|
#include "ActiveProjects.h"
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
|
|
||||||
|
#include <wx/arrstr.h>
|
||||||
|
#include <wx/file.h>
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
|
||||||
FilePaths ActiveProjects::GetAll()
|
FilePaths ActiveProjects::GetAll()
|
||||||
{
|
{
|
||||||
FilePaths files;
|
FilePaths files;
|
||||||
|
|
||||||
|
wxFileName fn(FileNames::DataDir(), wxT("activeprojects.cfg"));
|
||||||
|
wxFile file;
|
||||||
|
if (file.Open(fn.GetFullPath(), wxFile::OpenMode::read))
|
||||||
|
{
|
||||||
|
wxString lines;
|
||||||
|
if (file.ReadAll(&lines))
|
||||||
|
{
|
||||||
|
files = wxSplit(lines, wxT('\n'));
|
||||||
|
for (int i = files.size() - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
if (files[i].empty())
|
||||||
|
{
|
||||||
|
files.RemoveAt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return files;
|
||||||
|
#if 0
|
||||||
wxString key;
|
wxString key;
|
||||||
long ndx;
|
long ndx;
|
||||||
|
|
||||||
@ -37,12 +59,31 @@ FilePaths ActiveProjects::GetAll()
|
|||||||
more = gPrefs->GetNextEntry(key, ndx);
|
more = gPrefs->GetNextEntry(key, ndx);
|
||||||
}
|
}
|
||||||
gPrefs->SetPath(configPath);
|
gPrefs->SetPath(configPath);
|
||||||
|
#endif
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActiveProjects::Add(const FilePath &path)
|
void ActiveProjects::Add(const FilePath &path)
|
||||||
{
|
{
|
||||||
|
FilePaths files = GetAll();
|
||||||
|
|
||||||
|
if (files.Index(path) != wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
files.Add(path);
|
||||||
|
|
||||||
|
wxString lines = wxJoin(files, wxT('\n')) + wxT('\n');
|
||||||
|
|
||||||
|
wxFileName fn(FileNames::DataDir(), wxT("activeprojects.cfg"));
|
||||||
|
wxFile file;
|
||||||
|
if (file.Create(fn.GetFullPath(), true))
|
||||||
|
{
|
||||||
|
file.Write(lines);
|
||||||
|
file.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
wxString key = Find(path);
|
wxString key = Find(path);
|
||||||
|
|
||||||
if (key.empty())
|
if (key.empty())
|
||||||
@ -56,10 +97,31 @@ void ActiveProjects::Add(const FilePath &path)
|
|||||||
gPrefs->Write(key, path);
|
gPrefs->Write(key, path);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActiveProjects::Remove(const FilePath &path)
|
void ActiveProjects::Remove(const FilePath &path)
|
||||||
{
|
{
|
||||||
|
FilePaths files = GetAll();
|
||||||
|
|
||||||
|
int ndx = files.Index(path);
|
||||||
|
if (ndx == wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
files.RemoveAt(ndx);
|
||||||
|
|
||||||
|
wxString lines = wxJoin(files, wxT('\n')) + wxT('\n');
|
||||||
|
|
||||||
|
wxFileName fn(FileNames::DataDir(), wxT("activeprojects.cfg"));
|
||||||
|
wxFile file;
|
||||||
|
if (file.Create(fn.GetFullPath(), true))
|
||||||
|
{
|
||||||
|
file.Write(lines);
|
||||||
|
file.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
wxString key = Find(path);
|
wxString key = Find(path);
|
||||||
|
|
||||||
if (!key.empty())
|
if (!key.empty())
|
||||||
@ -67,6 +129,7 @@ void ActiveProjects::Remove(const FilePath &path)
|
|||||||
gPrefs->DeleteEntry(wxT("/ActiveProjects/" + key));
|
gPrefs->DeleteEntry(wxT("/ActiveProjects/" + key));
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString ActiveProjects::Find(const FilePath &path)
|
wxString ActiveProjects::Find(const FilePath &path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user