Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-61613

Grant better control over file monitoring of QFileSystemModel

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Widgets: Itemviews
    • None

    Description

      Variation of this is requested multiple times - QFileSystemModel internally monitors the filesystem and user has no control over it. 

      It is true that this is monitoring is an implementation detail, however, the monitoring is very aggressive - every call to fetchMore adds a new watch handle which is never released because there is no way the model to be informed the data is no longer visible (the reverse of fetchMore). In practice every single "expand" in a treeview is a new permanent watch, making it poorly suitable for everything besides a dialog (temporal) window.

      That is not all, often times the monitoring is not needed - the user can subclass the model and eagerly fetchMore without visually displaying the folder contents. In that case monitoring might not be needed at all as the user only needs a snapshot of the current filesystem view.

      Semantically monitoring the filesystem is a bonus feature - there is nothing inherently wrong or fatal if the model is out of date. Also the user is already aware, there might be changes on the background.

      My suggestion is to have "manual mode" on the QFileSystemModel, where the user manually adds/removes the indecies the watch list. There is no need to expose the watcher instance - just startWatchingIndex(QModelIndex), stopWatchingIndex(QModelIndex).

      By default the model will work as it does right now.

      However, the user is free to not watch on fetchMore by overriding it in a subclass; as well as to not watch when he collapses a branch in QTreeView, by connecting to collapsed(QModelIndex) signal.

      Lastly should be noted that monitoring prevents many folder actions in Windows such as USB device removal!

       

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            mnaydenov Mihail Naydenov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes