Browse Source

Build fixes for FileListComponent and FileTreeComponent

tags/2021-05-28
jules 8 years ago
parent
commit
ee8c2303c6
2 changed files with 22 additions and 23 deletions
  1. +12
    -12
      modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp
  2. +10
    -11
      modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp

+ 12
- 12
modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp View File

@@ -33,12 +33,12 @@ FileListComponent::FileListComponent (DirectoryContentsList& listToShow)
DirectoryContentsDisplayComponent (listToShow)
{
setModel (this);
fileList.addChangeListener (this);
directoryContentsList.addChangeListener (this);
}
FileListComponent::~FileListComponent()
{
fileList.removeChangeListener (this);
directoryContentsList.removeChangeListener (this);
}
int FileListComponent::getNumSelectedFiles() const
@@ -48,7 +48,7 @@ int FileListComponent::getNumSelectedFiles() const
File FileListComponent::getSelectedFile (int index) const
{
return fileList.getFile (getSelectedRow (index));
return directoryContentsList.getFile (getSelectedRow (index));
}
void FileListComponent::deselectAllFiles()
@@ -63,9 +63,9 @@ void FileListComponent::scrollToTop()
void FileListComponent::setSelectedFile (const File& f)
{
for (int i = fileList.getNumFiles(); --i >= 0;)
for (int i = directoryContentsList.getNumFiles(); --i >= 0;)
{
if (fileList.getFile(i) == f)
if (directoryContentsList.getFile(i) == f)
{
selectRow (i);
return;
@@ -80,9 +80,9 @@ void FileListComponent::changeListenerCallback (ChangeBroadcaster*)
{
updateContent();
if (lastDirectory != fileList.getDirectory())
if (lastDirectory != directoryContentsList.getDirectory())
{
lastDirectory = fileList.getDirectory();
lastDirectory = directoryContentsList.getDirectory();
deselectAllRows();
}
}
@@ -218,7 +218,7 @@ private:
//==============================================================================
int FileListComponent::getNumRows()
{
return fileList.getNumFiles();
return directoryContentsList.getNumFiles();
}
void FileListComponent::paintListBoxItem (int, Graphics&, int, int, bool)
@@ -232,11 +232,11 @@ Component* FileListComponent::refreshComponentForRow (int row, bool isSelected,
auto comp = static_cast<ItemComponent*> (existingComponentToUpdate);
if (comp == nullptr)
comp = new ItemComponent (*this, fileList.getTimeSliceThread());
comp = new ItemComponent (*this, directoryContentsList.getTimeSliceThread());
DirectoryContentsList::FileInfo fileInfo;
comp->update (fileList.getDirectory(),
fileList.getFileInfo (row, fileInfo) ? &fileInfo : nullptr,
comp->update (directoryContentsList.getDirectory(),
directoryContentsList.getFileInfo (row, fileInfo) ? &fileInfo : nullptr,
row, isSelected);
return comp;
@@ -253,5 +253,5 @@ void FileListComponent::deleteKeyPressed (int /*currentSelectedRow*/)
void FileListComponent::returnKeyPressed (int currentSelectedRow)
{
sendDoubleClickMessage (fileList.getFile (currentSelectedRow));
sendDoubleClickMessage (directoryContentsList.getFile (currentSelectedRow));
}

+ 10
- 11
modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp View File

@@ -34,8 +34,8 @@ class FileListTreeItem : public TreeViewItem,
{
public:
FileListTreeItem (FileTreeComponent& treeComp,
DirectoryContentsList* const parentContents,
const int indexInContents,
DirectoryContentsList* parentContents,
int indexInContents,
const File& f,
TimeSliceThread& t)
: file (f),
@@ -135,7 +135,7 @@ public:
for (int maxRetries = 500; --maxRetries > 0;)
{
for (int i = 0; i < getNumSubItems(); ++i)
if (FileListTreeItem* f = dynamic_cast<FileListTreeItem*> (getSubItem (i)))
if (auto* f = dynamic_cast<FileListTreeItem*> (getSubItem (i)))
if (f->selectFile (target))
return true;
@@ -233,8 +233,8 @@ private:
{
if (icon.isNull())
{
const int hashCode = (file.getFullPathName() + "_iconCacheSalt").hashCode();
Image im (ImageCache::getFromHashCode (hashCode));
auto hashCode = (file.getFullPathName() + "_iconCacheSalt").hashCode();
auto im = ImageCache::getFromHashCode (hashCode);
if (im.isNull() && ! onlyUpdateIfCached)
{
@@ -273,11 +273,10 @@ void FileTreeComponent::refresh()
{
deleteRootItem();
FileListTreeItem* const root
= new FileListTreeItem (*this, nullptr, 0, fileList.getDirectory(),
fileList.getTimeSliceThread());
auto root = new FileListTreeItem (*this, nullptr, 0, directoryContentsList.getDirectory(),
directoryContentsList.getTimeSliceThread());
root->setSubContentsList (&fileList, false);
root->setSubContentsList (&directoryContentsList, false);
setRootItem (root);
}
@@ -307,7 +306,7 @@ void FileTreeComponent::setDragAndDropDescription (const String& description)
void FileTreeComponent::setSelectedFile (const File& target)
{
if (FileListTreeItem* t = dynamic_cast<FileListTreeItem*> (getRootItem()))
if (auto* t = dynamic_cast<FileListTreeItem*> (getRootItem()))
if (! t->selectFile (target))
clearSelectedItems();
}
@@ -318,7 +317,7 @@ void FileTreeComponent::setItemHeight (int newHeight)
{
itemHeight = newHeight;
if (TreeViewItem* root = getRootItem())
if (auto* root = getRootItem())
root->treeHasChanged();
}
}

Loading…
Cancel
Save