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

QFileSystemModel does not sort if a file is renamed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.12.3
    • None
    • openSUSE Leap 15.0
    • Linux/X11

      In an application using QTreeView and QFileSystemModel, if a file is renamed in the tree view, the model does not sort its contents and QTreeView keeps showing the renamed file at its old position.

      This can be easily reproduced with "QTDIR/examples/widgets/itemviews/dirview/dirview.pro" by just adding  "model.setReadOnly(false)".

      This bug report corresponds to the meanwhile closed QTBUG-52479, but is related to LINUX.

       Suggested fix (1):

      bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, int role)
      {
      ...
              d->forceSort = true; // <=== added instruction
              d->delayedSort();
              emit fileRenamed(parentPath, oldName, newName);
          }
          return true;
      }
      

       

      Suggested fix (2):

      Consider to place the added instruction (shown above) in QFileSystemModelPrivate::_q_performDelayedSort() and to remove its further occurrences, because this instruction seems to be always required:

      void QFileSystemModelPrivate::_q_performDelayedSort()
      {
          Q_Q(QFileSystemModel);
          forceSort = true; // <=== added instruction
          q->sort(sortColumn, sortOrder);
      }
      

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            wschenke Winfried Schenke
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes