From b74fcf6835b287322d2ee763d45dc4bb6f9e9c6f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 30 May 2019 10:53:03 -0400 Subject: [PATCH] Full file tree in sidebar (from cwd) --- CMakeLists.txt | 1 - src/widgets/FilePane.cpp | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a84fa09..9ebc22e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ ################################################################################ cmake_minimum_required (VERSION 2.8) -set(CMAKE_CXX_FLAGS "-stdlib=libc++") set(CMAKE_CXX_STANDARD 11) project(Tyro) diff --git a/src/widgets/FilePane.cpp b/src/widgets/FilePane.cpp index 406f073..9b1620d 100644 --- a/src/widgets/FilePane.cpp +++ b/src/widgets/FilePane.cpp @@ -109,7 +109,7 @@ void FilePane::CreateTree(const wxString &path) */ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wxString &parent) { - wxLogDebug("AddDirToTree path: %s, parent: %s", path, parent); + wxLogInfo("AddDirToTree path: %s, parent: %s", path, parent); auto fullPath = this->base_path; if ( ! parent.empty()) @@ -153,14 +153,17 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx wxDir::GetAllFiles(fullPath, files); wxFileName currentPath((wxString)fullPath); + currentPath.MakeAbsolute(); currentPath.MakeRelativeTo(this->base_path); for (const wxString &file: *files) { auto parentDir = currentPath.GetPath(); + wxLogInfo("- Parent dir: %s, full dir: %s", parentDir, fullPath); + wxFileName fileName(file); - // Make the dir relative to the base path, + // Make the dir relative to the search path, // then only use the first dir segment fileName.MakeRelativeTo(fullPath); auto dir = std::string(fileName.GetPath()); @@ -171,12 +174,20 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx } auto newParent = parentDir; - if (parentDir.empty() || parentDir == ".") { + if (parentDir.empty()) + { newParent = BaseName(fullPath); } + if ( ! newParent.Contains(BaseName(fullPath))) + { + newParent += "/" + BaseName(fullPath); + } + wxArrayString dirs = fileName.GetDirs(); + wxLogInfo("-- Recursing to deeper folder: %s(%s), parent: %s(%s)", dirs[0], dir, newParent, parentDir); + this->AddDirToTree(dir_node, dirs[0], newParent); } @@ -189,7 +200,7 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx void FilePane::AddDirFiles(wxTreeListItem &root, const wxString &path) { - wxLogDebug("Adding files for dir: %s", path); + wxLogInfo("Adding files for dir: %s", path); auto *files = new wxArrayString(); wxDir::GetAllFiles(path, files, wxEmptyString, wxDIR_FILES);