forked from qt-creator/qt-creator
QmlDesigner: Replace filewatcher in resource model
Replace the Utils::FileWatcher with a connection to the ProjectExplorer fileListChanged signal. Change-Id: Ia2d3a6d239451ed979bbfb654fe5258aadd3c686 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
4617023e16
commit
117a8c65b9
@@ -36,15 +36,22 @@
|
||||
#include <QDirIterator>
|
||||
#include <qmlmodelnodeproxy.h>
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
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()
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
#include <qmlitemnode.h>
|
||||
|
||||
#include <utils/filesystemwatcher.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
@@ -87,7 +85,6 @@ private:
|
||||
QString m_lastResourcePath;
|
||||
QStringList m_fullPathModel;
|
||||
QStringList m_fileNameModel;
|
||||
Utils::FileSystemWatcher *m_fileSystemWatcher;
|
||||
};
|
||||
|
||||
QML_DECLARE_TYPE(FileResourcesModel)
|
||||
|
||||
Reference in New Issue
Block a user