Hmm, this is pretty tricky because of the time-sliced model of populating the list. For my own purposes (it's a way to browse filter presets) this works ok, because I never expect to have 1000s of files, but it obviously disables the continuous update of the list as it's populated. Also the selection gets offset if a file is deleted or added in between refreshes. I can live with those constraints, but it obviously wouldn't be suitable for the general case. To do it properly I think you'd need to cache the selections, then re-apply them when the refresh is finished. I may look into doing that tomorrow as a practice excercise in programming something robust enough for a library.
void FileListComponent::changeListenerCallback (ChangeBroadcaster* source)
const auto list = dynamic_cast<DirectoryContentsList*>(source);
if (list == nullptr || !list->isStillLoading())
if (lastDirectory != fileList.getDirectory())
lastDirectory = fileList.getDirectory();