diff --git a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp index 6c1bc578e49..dea4960bc15 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp @@ -36,15 +36,22 @@ #include #include +#include +#include + static QString s_lastBrowserPath; FileResourcesModel::FileResourcesModel(QObject *parent) : QObject(parent) , m_filter(QLatin1String("(*.*)")) - , m_fileSystemWatcher(new Utils::FileSystemWatcher(this)) { - connect(m_fileSystemWatcher, &Utils::FileSystemWatcher::directoryChanged, - this, &FileResourcesModel::refreshModel); + ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile( + QmlDesigner::DocumentManager::currentFilePath()); + + if (project) { + connect(project, &ProjectExplorer::Project::fileListChanged, + this, &FileResourcesModel::refreshModel); + } } void FileResourcesModel::setModelNodeBackend(const QVariant &modelNodeBackend) @@ -195,12 +202,7 @@ bool filterMetaIcons(const QString &fileName) void FileResourcesModel::setupModel() { m_dirPath = QDir(m_path.toLocalFile()); - refreshModel(); - - m_fileSystemWatcher->removeDirectories(m_fileSystemWatcher->directories()); - m_fileSystemWatcher->addDirectory(m_dirPath.absolutePath(), - Utils::FileSystemWatcher::WatchAllChanges); } void FileResourcesModel::refreshModel() diff --git a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h index c1ebd6a8ad9..f0380c5a52e 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h +++ b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h @@ -27,8 +27,6 @@ #include -#include - #include #include #include @@ -87,7 +85,6 @@ private: QString m_lastResourcePath; QStringList m_fullPathModel; QStringList m_fileNameModel; - Utils::FileSystemWatcher *m_fileSystemWatcher; }; QML_DECLARE_TYPE(FileResourcesModel)