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 "Prefs.h"
|
||||
|
||||
#include <wx/arrstr.h>
|
||||
#include <wx/file.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
FilePaths ActiveProjects::GetAll()
|
||||
{
|
||||
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;
|
||||
long ndx;
|
||||
|
||||
|
@ -37,12 +59,31 @@ FilePaths ActiveProjects::GetAll()
|
|||
more = gPrefs->GetNextEntry(key, ndx);
|
||||
}
|
||||
gPrefs->SetPath(configPath);
|
||||
|
||||
#endif
|
||||
return files;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (key.empty())
|
||||
|
@ -56,10 +97,31 @@ void ActiveProjects::Add(const FilePath &path)
|
|||
gPrefs->Write(key, path);
|
||||
gPrefs->Flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!key.empty())
|
||||
|
@ -67,6 +129,7 @@ void ActiveProjects::Remove(const FilePath &path)
|
|||
gPrefs->DeleteEntry(wxT("/ActiveProjects/" + key));
|
||||
gPrefs->Flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
wxString ActiveProjects::Find(const FilePath &path)
|
||||
|
|
Loading…
Reference in New Issue