Browse Source

Added a method DirectoryContentsList::setFileFilter()

tags/2021-05-28
jules 12 years ago
parent
commit
2f721b4889
2 changed files with 17 additions and 2 deletions
  1. +8
    -2
      modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp
  2. +9
    -0
      modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h

+ 8
- 2
modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp View File

@@ -108,6 +108,12 @@ void DirectoryContentsList::refresh()
}
}
void DirectoryContentsList::setFileFilter (const FileFilter* newFileFilter)
{
const ScopedLock sl (fileListLock);
fileFilter = newFileFilter;
}
//==============================================================================
bool DirectoryContentsList::getFileInfo (const int index,
FileInfo& result) const
@@ -225,6 +231,8 @@ bool DirectoryContentsList::addFile (const File& file, const bool isDir,
Time modTime, Time creationTime,
const bool isReadOnly)
{
const ScopedLock sl (fileListLock);
if (fileFilter == nullptr
|| ((! isDir) && fileFilter->isFileSuitable (file))
|| (isDir && fileFilter->isDirectorySuitable (file)))
@@ -238,8 +246,6 @@ bool DirectoryContentsList::addFile (const File& file, const bool isDir,
info->isDirectory = isDir;
info->isReadOnly = isReadOnly;
const ScopedLock sl (fileListLock);
for (int i = files.size(); --i >= 0;)
if (files.getUnchecked(i)->filename == info->filename)
return false;


+ 9
- 0
modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h View File

@@ -108,6 +108,15 @@ public:
*/
bool ignoresHiddenFiles() const;
/** Replaces the current FileFilter.
This can be nullptr to have no filter. The DirectoryContentList does not take
ownership of this object - it just keeps a pointer to it, so you must manage its
lifetime.
Note that this only replaces the filter, it doesn't refresh the list - you'll
probably want to call refresh() after calling this.
*/
void setFileFilter (const FileFilter* newFileFilter);
//==============================================================================
/** Contains cached information about one of the files in a DirectoryContentsList.
*/


Loading…
Cancel
Save