Notifying QFileSystemModel about changes
I have a QFileSystemModel with a custom QSortFilterProxyModel and a custom QFileIconProvider.
My QFileIconProvider fetches file icons in another thread so that the file list can be populated more quickly - get file list first, populate list, and then get the icons in a seperate thread. So my QFileIconProvider::icon() override returns a blank icon until the information is available. How can I get QFileSystemModel to recognise when the new icon is available? I don't want want to refresh the entire list, as I want the list to update as and when the icons become available.
Re: Notifying QFileSystemModel about changes
Emit dataChanged() for each modified index.
Re: Notifying QFileSystemModel about changes
I would normally use that in a model to notify the widget that the data is changed and to refresh it. However, here I don't control the data in the model as it's a QFileSystemModel, and since QFileSystemModel caches the data, will dataChanged actually have any effect? Or will it just retrieve the data from the cache ?
I know it can handle changes from its thread internally, but thats all hidden in QFileSystemModelPrivate.
Re: Notifying QFileSystemModel about changes
It's best to just check what QFileSystemModel::data() returns for decoration (and FileIconRole) role. I would guess emitting dataChanged() is the only thing you can do with the model here. Otherwise apply a proxy over the model and return icons from the proxy - then you'll have full control over what is going on.