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