1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

FileTreeComponent selection fix.

This commit is contained in:
jules 2013-03-08 14:30:38 +00:00
parent 8820d37d2c
commit d046e30b25

View file

@ -116,28 +116,43 @@ public:
{
setOpen (true);
for (int i = 0; i < getNumSubItems(); ++i)
if (FileListTreeItem* f = dynamic_cast <FileListTreeItem*> (getSubItem (i)))
if (f->selectFile (target))
return true;
for (int maxRetries = 500; --maxRetries > 0;)
{
for (int i = 0; i < getNumSubItems(); ++i)
if (FileListTreeItem* f = dynamic_cast <FileListTreeItem*> (getSubItem (i)))
if (f->selectFile (target))
return true;
// if we've just opened and the contents are still loading, wait for it..
if (subContentsList != nullptr && subContentsList->isStillLoading())
{
Thread::sleep (10);
rebuildItemsFromContentList();
}
else
{
break;
}
}
}
return false;
}
void changeListenerCallback (ChangeBroadcaster*)
{
rebuildItemsFromContentList();
}
void rebuildItemsFromContentList()
{
clearSubItems();
if (isOpen() && subContentsList != nullptr)
{
for (int i = 0; i < subContentsList->getNumFiles(); ++i)
{
FileListTreeItem* const item
= new FileListTreeItem (owner, subContentsList, i, subContentsList->getFile(i), thread);
addSubItem (item);
}
addSubItem (new FileListTreeItem (owner, subContentsList, i,
subContentsList->getFile(i), thread));
}
}