I have a FileTreeView and have set the directory to a folder on the main drive. I have set setRootItemVisible. How can I get the tree to show the RootItem to be this folder. The tree always shows “C:”.
there is currently a issue with the FileTree, the root-item will not be changed under special conditions
i described it here in the beginning of the first post, but I’m not sure if its the same: http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=7488
AFAICT - It does it on either platform. Yes the folder exists. The tree is showing all the subfolders of the desired folder. I even placed a long delay between the two statements, but I always get the “C:” or the Hard Drive on the MAC.
[quote]if i afterwards change the Root-Directoy with fileList->setDirectory, the rootItem in fileTree will be always the same (because it will be only once initiated in the constructor of FileTreeComponent )
I am assuming that “directoryList->setDirectory( folder, true, true );” is not resetting the root item in the tree and that’s what “chkn” is experiencing. I guess I’ll dig through the code and see why not. Hopefully you two can figure it out before me. I am still new at juce coding.
The problem is as I stated above. The tree is not being informed of a new directory root. I can’t replace the TreeView root, because there is no way to create a new TreeItem to pass to the TreeView-setRootItem function, I am stuck with having to delete the fileTree and recreate it every time the root directory is changed. Please add a
This would solve the problem.
While I’m here I have other questions.
Also is there a way to disable folders from being selected, without writing 20 lines of code? And how do you eliminate empty folders or simple how do you delete a TreeItem?
Oh, I see. I thought you were saying that it actually didn’t work, rather than just not providing a method to do that. Yep, good request, I’ll add that, thanks!
oh, whoops… actually, no, I can’t change that. The base class DirectoryContentsDisplayComponent doesn’t allow the DirectoryList to be changed. But I understand the problem now, it does need to somehow find out when the list’s root is changed, and respond to that.
I did not get an answer on “Hiding Empty Folders” and I read another post about hiding empty folders but I didn’t understand how to determine if a folder is empty. Isn’t it true that when 'isDirectorySuitable" is being called the folder has not been filled in the tree? So how do I determine at the ‘isDirectorySuitable’ call, if the folder contains files of a certain type or any sub folders that contain files of a certain type. For example, I just want to show folders/subfolders that contain MIDI files. I have the filter thing working, but it shows all folders even if they do not contain MIDI files. I think this would be a nice option option in the juce code. Just set a flag to show/hide empty folders.
I wrote a routine that isDirectorySuitable calls to search the directory for files but this takes way too long. So what is the best approach.