Thank you for your input d_stranz, very appreciated.
Are you checking the index range and roles that are part of the dataChanged() signal to see if they apply to the entries you are displaying in your browser?
I think so yes:
{
if (in_index.column() == 0)
if (in_role == Qt::DecorationRole)
...
QVariant QT_BrowserModel::data(const QModelIndex &in_index, int in_role) const
{
if (in_index.column() == 0)
if (in_role == Qt::DecorationRole)
...
To copy to clipboard, switch view to plain text mode
Are you doing something in your "validate their source controlled states inside QFileSystemModel::data" code that could cause a file system watcher to think that the file / directory has changed? For example, are you changing an icon when you determine that the file is source controlled?
Yes, I do a QPainter "overlay" on the thumbnails BUT, even if no files are being modified, it still tries to refresh the model's data on cursor enter or leave anyways. On that note, I get the same behavior (but faster) when I emptied QFileSystemModel::data and QFileSystemModel::setData. Maybe when QFileSystemModel parent's is getting focus... a QFileSystemWatcher is being triggered? If yes, would it be possible to catch and silence it somehow?
Users have become accustomed to "live" file updates in file browsers. If you turn off updating, this will probably annoy your users.
Agreed.
would it be possible to move the QFileSystemModel::data to a separate thread? I think you would be better off if you changed your model to cache the source control state. This is likely something you could do in the background (eg. in a thread) and emit signals to update the UI periodically instead of for every file.
Keeping into account that the "live" file updates is needed, would the cache still be forced to validate itself whenever an unwanted dataChanged is called? While this sounds like a neat solution I have little to no ideas how it would be accomplish... so feel free to elaborate on this concept. Note, I'd like to build on a nearly working mechanic rather than starting a new one. That said, I'll consider this approach nonetheless.
Thank you,
Bookmarks