Another ugly progress commit
This commit is contained in:
parent
6befab1b4c
commit
72be1d808f
@ -68,8 +68,6 @@ void FilePane::CreateTree(const wxString &path, wxTreeListItem &root)
|
|||||||
auto *files = new wxArrayString();
|
auto *files = new wxArrayString();
|
||||||
wxDir::GetAllFiles(path, files);
|
wxDir::GetAllFiles(path, files);
|
||||||
|
|
||||||
// std::unordered_set<std::string> dirs;
|
|
||||||
|
|
||||||
for (const wxString &file: *files)
|
for (const wxString &file: *files)
|
||||||
{
|
{
|
||||||
wxFileName fileName(file);
|
wxFileName fileName(file);
|
||||||
@ -79,6 +77,12 @@ void FilePane::CreateTree(const wxString &path, wxTreeListItem &root)
|
|||||||
fileName.RemoveDir(0);
|
fileName.RemoveDir(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the file is at the root, add it to the tree
|
||||||
|
if (fileName.GetDirCount() == 1)
|
||||||
|
{
|
||||||
|
this->AddDirFiles(path, root);
|
||||||
|
}
|
||||||
|
|
||||||
auto dir = std::string(fileName.GetPath());
|
auto dir = std::string(fileName.GetPath());
|
||||||
|
|
||||||
if (dir.empty())
|
if (dir.empty())
|
||||||
@ -86,11 +90,7 @@ void FilePane::CreateTree(const wxString &path, wxTreeListItem &root)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->dir_set.insert(dir);
|
// Append the folder to the tree
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& dir: this->dir_set)
|
|
||||||
{
|
|
||||||
wxString wdir = wxString(dir);
|
wxString wdir = wxString(dir);
|
||||||
wxLogDebug("Creating Dir Tree: %s", wdir);
|
wxLogDebug("Creating Dir Tree: %s", wdir);
|
||||||
this->DirToTree(wdir, root, wxString("."));
|
this->DirToTree(wdir, root, wxString("."));
|
||||||
@ -108,29 +108,33 @@ void FilePane::DirToTree(const wxString &path, wxTreeListItem &root, const wxStr
|
|||||||
fullPath += "/";
|
fullPath += "/";
|
||||||
fullPath += path;
|
fullPath += path;
|
||||||
|
|
||||||
|
this->dir_set.insert(".");
|
||||||
|
|
||||||
|
wxLogDebug("Rendering Dir Tree for %s", fullPath);
|
||||||
|
|
||||||
auto *files = new wxArrayString();
|
auto *files = new wxArrayString();
|
||||||
wxDir::GetAllFiles(path, files);
|
wxDir::GetAllFiles(path, files);
|
||||||
|
|
||||||
for (const wxString &item: *files)
|
for (const wxString &item: *files)
|
||||||
{
|
{
|
||||||
wxFileName filename(item);
|
wxFileName fileName(item);
|
||||||
|
|
||||||
// Remove the directory component closest to the root
|
// Remove the directory component closest to the root
|
||||||
if (filename.GetDirCount() > 1)
|
if (fileName.GetDirCount() > 1 || fileName.DirExists("."))
|
||||||
{
|
{
|
||||||
filename.RemoveDir(0);
|
fileName.RemoveDir(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxArrayString dirs = filename.GetDirs();
|
const wxArrayString dirs = fileName.GetDirs();
|
||||||
|
|
||||||
// See if the path already exists on the tree
|
// See if the path already exists on the tree
|
||||||
/* for (const wxString &dir: dirs)
|
for (const wxString &dir: dirs)
|
||||||
{
|
{
|
||||||
this->dir_it = find(this->examined.begin(), this->examined.end(), dir);
|
// Stop early if folder exists
|
||||||
|
auto it = this->dir_set.find(std::string(dir));
|
||||||
if (dir_it != this->examined.end())
|
if (it != this->dir_set.end())
|
||||||
{
|
{
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fileData = new wxStringClientData();
|
auto fileData = new wxStringClientData();
|
||||||
@ -138,23 +142,38 @@ void FilePane::DirToTree(const wxString &path, wxTreeListItem &root, const wxStr
|
|||||||
|
|
||||||
auto dir_node = this->AppendItem(root, dir, Icon_FolderClosed, Icon_FolderOpened, fileData);
|
auto dir_node = this->AppendItem(root, dir, Icon_FolderClosed, Icon_FolderOpened, fileData);
|
||||||
|
|
||||||
this->examined.push_back(dir);
|
this->dir_set.insert(std::string(dir));
|
||||||
|
|
||||||
this->CreateTree(dir, dir_node);
|
this->DirToTree(dir, dir_node, fullPath);
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// If the file is at the root, add it to the tree
|
// break;
|
||||||
if (filename.GetDirCount() == 1)
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FilePane::AddDirFiles(const wxString &path, wxTreeListItem &root)
|
||||||
{
|
{
|
||||||
filename.MakeAbsolute();
|
auto *files = new wxArrayString();
|
||||||
|
wxDir::GetAllFiles(path, files);
|
||||||
|
|
||||||
auto fileData = new wxStringClientData();
|
wxLogDebug("Redering files in : %s", path);
|
||||||
fileData->SetData(filename.GetFullPath());
|
|
||||||
|
|
||||||
this->AppendItem(root, filename.GetFullName(), Icon_File, Icon_File, fileData);
|
for (const wxString &item: *files)
|
||||||
|
{
|
||||||
|
wxFileName fileName(item);
|
||||||
|
fileName.MakeAbsolute();
|
||||||
|
|
||||||
|
auto it = this->file_set.find(std::string(fileName.GetFullPath()));
|
||||||
|
if (it != this->file_set.end())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto fileData = new wxStringClientData();
|
||||||
|
fileData->SetData(fileName.GetFullPath());
|
||||||
|
|
||||||
|
this->AppendItem(root, fileName.GetFullName(), Icon_File, Icon_File, fileData);
|
||||||
|
this->file_set.insert(std::string(fileName.GetFullPath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,5 +25,6 @@ private:
|
|||||||
void InitImageList();
|
void InitImageList();
|
||||||
void CreateTree(const wxString &path, wxTreeListItem &root);
|
void CreateTree(const wxString &path, wxTreeListItem &root);
|
||||||
void DirToTree(const wxString &path, wxTreeListItem &root, const wxString &parent);
|
void DirToTree(const wxString &path, wxTreeListItem &root, const wxString &parent);
|
||||||
|
void AddDirFiles(const wxString &path, wxTreeListItem &root);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -393,11 +393,10 @@ void MainFrame::OnSaveAs(wxCommandEvent &WXUNUSED(event))
|
|||||||
if(editor->SaveFile(filePath))
|
if(editor->SaveFile(filePath))
|
||||||
{
|
{
|
||||||
wxFileName fileName(filePath);
|
wxFileName fileName(filePath);
|
||||||
const wxString fullPath = filePath;
|
|
||||||
const wxString caption = fileName.GetFullName();
|
const wxString caption = fileName.GetFullName();
|
||||||
|
|
||||||
// Update the name of the tab
|
// Update the name of the tab
|
||||||
notebook->SetPageToolTip(notebook->GetSelection(), fullPath);
|
notebook->SetPageToolTip(notebook->GetSelection(), filePath);
|
||||||
notebook->SetPageText(notebook->GetSelection(), caption);
|
notebook->SetPageText(notebook->GetSelection(), caption);
|
||||||
|
|
||||||
// Update the editor highlighting
|
// Update the editor highlighting
|
||||||
@ -541,8 +540,8 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
|
|||||||
EditPane *editor = notebook->GetCurrentEditor();
|
EditPane *editor = notebook->GetCurrentEditor();
|
||||||
|
|
||||||
// Parse flags
|
// Parse flags
|
||||||
int stc_flags = 0;
|
uint stc_flags = 0;
|
||||||
int fr_flags = event.GetFlags();
|
uint fr_flags = event.GetFlags();
|
||||||
|
|
||||||
if (fr_flags & wxFR_WHOLEWORD) stc_flags |= wxSTC_FIND_WHOLEWORD;
|
if (fr_flags & wxFR_WHOLEWORD) stc_flags |= wxSTC_FIND_WHOLEWORD;
|
||||||
if (fr_flags & wxFR_MATCHCASE) stc_flags |= wxSTC_FIND_MATCHCASE;
|
if (fr_flags & wxFR_MATCHCASE) stc_flags |= wxSTC_FIND_MATCHCASE;
|
||||||
@ -686,8 +685,8 @@ void MainFrame::EnableEditControls(bool enable)
|
|||||||
*/
|
*/
|
||||||
void MainFrame::OnLangSelect(wxCommandEvent &event)
|
void MainFrame::OnLangSelect(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxMenu *selectedMenu = (wxMenu *) event.GetEventObject();
|
auto *selectedMenu = (wxMenu *) event.GetEventObject();
|
||||||
wxMenu *langMenu = Glob_menu_bar->GetMenu(myLANG_MENU);
|
auto *langMenu = Glob_menu_bar->GetMenu(myLANG_MENU);
|
||||||
if (langMenu == NULL) wxLogDebug("Couldn't get lang menu");
|
if (langMenu == NULL) wxLogDebug("Couldn't get lang menu");
|
||||||
|
|
||||||
if (selectedMenu == langMenu)
|
if (selectedMenu == langMenu)
|
||||||
|
Loading…
Reference in New Issue
Block a user