Results 1 to 3 of 3

Thread: Accepting or rejecting whenever QFileSystemModel is emitting dataChanged?

  1. #1
    Join Date
    Feb 2014
    Posts
    24
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Accepting or rejecting whenever QFileSystemModel is emitting dataChanged?

    Greeting,

    After implementing a fairly complex file browser (Windows style), I realized that dataChanged is emitted quite often and surprisingly, when there is no apparent reason to do update anything. One would say that this is no big deal but it become very apparent while dealing with several thousands of files, freezing the entire app for about a second. The reason why it is quite heavy on process is that each file have to validate their source controlled states inside QFileSystemModel::data.

    In any case, the more obvious dataChanged I would like to prevent form happening is when QFileSystemModel parent widget (I presume) is Entered or Leaved. I tried to filter and catch who is triggering the dataChanged but with no luck so far. Any hint on why would dataChange being triggered at this moment might be helpful to track and prevent it form happening.

    In the event where we cannot prevent the dataChanged from occurring, would it be possible to move the QFileSystemModel::data to a separate thread? If yes, how would this be accomplish?

    Thank you,

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Accepting or rejecting whenever QFileSystemModel is emitting dataChanged?

    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?

    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?

    Users have become accustomed to "live" file updates in file browsers. If you turn off updating, this will probably annoy your users.

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Feb 2014
    Posts
    24
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Accepting or rejecting whenever QFileSystemModel is emitting dataChanged?

    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:

    Qt Code:
    1. QVariant QT_BrowserModel::data(const QModelIndex &in_index, int in_role) const
    2. {
    3. if (in_index.column() == 0)
    4. if (in_role == Qt::DecorationRole)
    5.  
    6. ...
    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,
    Last edited by neosettler; 16th April 2017 at 23:40.

Similar Threads

  1. QListView not accepting external drops
    By battersea in forum Qt Programming
    Replies: 1
    Last Post: 15th November 2010, 19:46
  2. Replies: 0
    Last Post: 4th May 2010, 10:24
  3. TextEdit in QDialog not accepting data
    By nbkhwjm in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2008, 03:53
  4. widgets not accepting hoverevents ?
    By maverick_pol in forum Qt Programming
    Replies: 5
    Last Post: 10th October 2007, 13:14
  5. QListView trouble accepting drops
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 6th September 2007, 19:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.