diff options
Diffstat (limited to 'src/gui/dialogs/qfilesystemmodel.cpp')
-rw-r--r-- | src/gui/dialogs/qfilesystemmodel.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index ba0a560..8a6190f 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1373,6 +1373,16 @@ QModelIndex QFileSystemModel::setRootPath(const QString &newPath) if (!showDrives && !newPathDir.exists()) return d->index(rootPath()); + //We remove the watcher on the previous path + if (!rootPath().isEmpty() && rootPath() != QLatin1String(".")) { + //This remove the watcher for the old rootPath + d->fileInfoGatherer.removePath(rootPath()); + //This line "marks" the node as dirty, so the next fetchMore + //call on the path will ask the gatherer to install a watcher again + //But it doesn't re-fetch everything + d->node(rootPath())->populatedChildren = false; + } + // We have a new valid root path d->rootDir = newPathDir; QModelIndex newRootIndex; @@ -1896,6 +1906,13 @@ void QFileSystemModelPrivate::init() q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)), q, SIGNAL(directoryLoaded(QString))); q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); + + QHash<int, QByteArray> roles = q->roleNames(); + roles.insertMulti(QFileSystemModel::FileIconRole, "fileIcon"); // == Qt::decoration + roles.insert(QFileSystemModel::FilePathRole, "filePath"); + roles.insert(QFileSystemModel::FileNameRole, "fileName"); + roles.insert(QFileSystemModel::FilePermissions, "filePermissions"); + q->setRoleNames(roles); } /*! |