Problem with FileTreeView


#1

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:”.

directoryList->setDirectory (folder, true, true); fileTreeComp->setRootItemVisible( true );

What am I doing wrong?


#2

AFAICT it works correctly… Does your folder actually exist?


#3

Hi Jules,

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

btw. do you think about the virtual method to format the file-name http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=7969


#4

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.


#5

Doesn’t look like the same thing to me…


#6

The important sentence in my post is

[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 )

So i get a structure like this:

<OPEN id="C:" scrollPos="0">
  <CLOSED id="D:\archiv"/>

[/quote]


#7

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.


#8

Its not an issue for me, because i’m not displaying the root-item, but i thought my hint was helpful… maybe

Thats always the best!


#9

jules,

Did you try it after the tree had been constructed with a different root?

So far with debugging, after making the call “directoryList->setDirectory( folder, true, true )”, fileTreeComp->setRootItem is not called.


#10

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?


#11

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!


#12

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.


#13

Found a solution that works when added to theTreeView Demo as a test:

[code]void setNewFolder( const File &folder )
{
fileTreeComp = 0;
directoryList = 0;

directoryList = new DirectoryContentsList( 0, thread );
directoryList->setDirectory( folder, true, true );

showFileTreeComp();
repaint();
}[/code]

Wish it were int he juce code


#14

I actually added a refresh() method a few days ago…


#15

Do I just get the latest juce update?


#16

The latest stuff is in the modules branch.


#17

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.