From e6bc65318c76ebde716c13669aacc9c48b1adb85 Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Fri, 10 Oct 2008 14:08:16 +0000 Subject: [PATCH] Finished new Filesystem tree viewer git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@827 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Core/DolphinWX/Src/FilesystemViewer.cpp | 37 ++++++++++++++----- Source/Core/DolphinWX/Src/FilesystemViewer.h | 1 + 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinWX/Src/FilesystemViewer.cpp b/Source/Core/DolphinWX/Src/FilesystemViewer.cpp index da10f04759..4226ef6c57 100644 --- a/Source/Core/DolphinWX/Src/FilesystemViewer.cpp +++ b/Source/Core/DolphinWX/Src/FilesystemViewer.cpp @@ -52,9 +52,10 @@ CFilesystemViewer::CFilesystemViewer(const std::string fileName, wxWindow* paren // shuffle2: things only appear in the tree for me when using debug build; why? :< wxTreeItemId dirId = NULL; - fileIter beginning = Our_Files.begin(), pos = Our_Files.begin(); + fileIter beginning = Our_Files.begin(), end = Our_Files.end(), + pos = Our_Files.begin(); - CreateDirectoryTree(RootId, beginning, pos, "\\"); + CreateDirectoryTree(RootId, beginning, end, pos, "\\"); m_Treectrl->Expand(RootId); @@ -98,15 +99,22 @@ CFilesystemViewer::~CFilesystemViewer() void CFilesystemViewer::CreateDirectoryTree(wxTreeItemId& parent, fileIter& begin, + fileIter& end, fileIter& iterPos, char *directory) { + bool bRoot = true; //TODO(XK): Fix more than one folder/file not appearing in the root if(iterPos == begin) ++iterPos; + else + bRoot = false; char *name = (char *)((*iterPos)->m_FullPath); + if(iterPos == end) + return; + do { if((*iterPos)->IsDirectory()) { @@ -117,17 +125,26 @@ void CFilesystemViewer::CreateDirectoryTree(wxTreeItemId& parent, dirName = name; else dirName++; - //filename = strrchr(name, '\\'); ++filename; - wxTreeItemId item = m_Treectrl->AppendItem(parent, wxT(dirName)); - CreateDirectoryTree(item, begin, ++iterPos, name); - } else { - //filename = strrchr(name, '\\'); ++filename; - m_Treectrl->AppendItem(parent, wxT(strrchr(name, '\\') + 1)); + wxTreeItemId item = m_Treectrl->AppendItem(parent, wxT(dirName)); + CreateDirectoryTree(item, begin, end, ++iterPos, name); + } else { + char *fileName = strrchr(name, '\\'); + if(!fileName) + fileName = name; + else + fileName++; + + m_Treectrl->AppendItem(parent, wxT(fileName)); + ++iterPos; } - ++iterPos; + + if(iterPos == end) + break; + name = (char *)((*iterPos)->m_FullPath); - } while(strstr(name, directory)); + + } while(bRoot || strstr(name, directory)); } void CFilesystemViewer::CreateGUIControls() diff --git a/Source/Core/DolphinWX/Src/FilesystemViewer.h b/Source/Core/DolphinWX/Src/FilesystemViewer.h index cbbf2b706a..e918924ccb 100644 --- a/Source/Core/DolphinWX/Src/FilesystemViewer.h +++ b/Source/Core/DolphinWX/Src/FilesystemViewer.h @@ -138,6 +138,7 @@ class CFilesystemViewer : public wxDialog typedef std::vector::iterator fileIter; void CreateDirectoryTree(wxTreeItemId& parent,fileIter& begin, + fileIter& end, fileIter& iterPos, char *directory); };