1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-04 03:40:07 +00:00

FileTreeComponent fix.

This commit is contained in:
jules 2013-05-12 16:18:17 +01:00
parent a1461637ee
commit 334ad5a51a

View file

@ -32,22 +32,22 @@ class FileListTreeItem : public TreeViewItem,
private ChangeListener
{
public:
FileListTreeItem (FileTreeComponent& owner_,
DirectoryContentsList* const parentContentsList_,
const int indexInContentsList_,
const File& file_,
TimeSliceThread& thread_)
: file (file_),
owner (owner_),
parentContentsList (parentContentsList_),
indexInContentsList (indexInContentsList_),
FileListTreeItem (FileTreeComponent& treeComp,
DirectoryContentsList* const parentContents,
const int indexInContents,
const File& f,
TimeSliceThread& t)
: file (f),
owner (treeComp),
parentContentsList (parentContents),
indexInContentsList (indexInContents),
subContentsList (nullptr, false),
thread (thread_)
thread (t)
{
DirectoryContentsList::FileInfo fileInfo;
if (parentContentsList_ != nullptr
&& parentContentsList_->getFileInfo (indexInContentsList_, fileInfo))
if (parentContents != nullptr
&& parentContents->getFileInfo (indexInContents, fileInfo))
{
fileSize = File::descriptionOfSizeInBytes (fileInfo.fileSize);
modTime = fileInfo.modificationTime.formatted ("%d %b '%y %H:%M");
@ -63,6 +63,7 @@ public:
{
thread.removeTimeSliceClient (this);
clearSubItems();
removeSubContentsList();
}
//==============================================================================
@ -97,8 +98,19 @@ public:
}
}
void removeSubContentsList()
{
if (subContentsList != nullptr)
{
subContentsList->removeChangeListener (this);
subContentsList.clear();
}
}
void setSubContentsList (DirectoryContentsList* newList, const bool canDeleteList)
{
removeSubContentsList();
OptionalScopedPointer<DirectoryContentsList> newPointer (newList, canDeleteList);
subContentsList = newPointer;
newList->addChangeListener (this);