From 74a727b42ff91a63bd7e8a6d660280d05ad1ceea Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 26 Oct 2011 18:23:49 +0100 Subject: [PATCH] Added a FileTreeComponent::refresh() method. --- .../filebrowser/juce_FileTreeComponent.cpp | 19 +++++++++++++------ .../filebrowser/juce_FileTreeComponent.h | 3 +++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index 2ae3ba3332..d124d8e42d 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -209,13 +209,8 @@ private: FileTreeComponent::FileTreeComponent (DirectoryContentsList& listToShow) : DirectoryContentsDisplayComponent (listToShow) { - FileListTreeItem* const root - = new FileListTreeItem (*this, 0, 0, listToShow.getDirectory(), - listToShow.getTimeSliceThread()); - - root->setSubContentsList (&listToShow, false); setRootItemVisible (false); - setRootItem (root); + refresh(); } FileTreeComponent::~FileTreeComponent() @@ -223,6 +218,18 @@ FileTreeComponent::~FileTreeComponent() deleteRootItem(); } +void FileTreeComponent::refresh() +{ + deleteRootItem(); + + FileListTreeItem* const root + = new FileListTreeItem (*this, nullptr, 0, fileList.getDirectory(), + fileList.getTimeSliceThread()); + + root->setSubContentsList (&fileList, false); + setRootItem (root); +} + //============================================================================== File FileTreeComponent::getSelectedFile (const int index) const { diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h index 534bd50500..316188465a 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h @@ -76,6 +76,9 @@ public: (and if the file isn't in the list, all other items will be deselected). */ void setSelectedFile (const File&); + /** Updates the files in the list. */ + void refresh(); + /** Setting a name for this allows tree items to be dragged. The string that you pass in here will be returned by the getDragSourceDescription()