diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 508ed62d7a182b896edfa29fe6780588507507ba..9da413a81a89ae5d25fa587e53f041f2822dad90 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -42,6 +42,7 @@ #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> +#include <coreplugin/filemanager.h> #include <extensionsystem/pluginmanager.h> #include <qtsupport/qmldumptool.h> #include <qtsupport/baseqtversion.h> @@ -60,10 +61,8 @@ namespace QmlProjectManager { QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName) : m_manager(manager), m_fileName(fileName), - m_modelManager(ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>()), - m_fileWatcher(new Utils::FileSystemWatcher(this)) + m_modelManager(ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>()) { - m_fileWatcher->setObjectName(QLatin1String("QmlProjectWatcher")); setProjectContext(Core::Context(QmlProjectManager::Constants::PROJECTCONTEXT)); setProjectLanguage(Core::Context(QmlProjectManager::Constants::LANG_QML)); @@ -73,9 +72,7 @@ QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName) m_file = new Internal::QmlProjectFile(this, fileName); m_rootNode = new Internal::QmlProjectNode(this, m_file); - m_fileWatcher->addFile(fileName, Utils::FileSystemWatcher::WatchModifiedDate); - connect(m_fileWatcher, SIGNAL(fileChanged(QString)), - this, SLOT(refreshProjectFile())); + Core::FileManager::instance()->addFile(m_file, true); m_manager->registerProject(this); } @@ -84,6 +81,8 @@ QmlProject::~QmlProject() { m_manager->unregisterProject(this); + Core::FileManager::instance()->removeFile(m_file); + delete m_projectItem.data(); delete m_rootNode; } diff --git a/src/plugins/qmlprojectmanager/qmlproject.h b/src/plugins/qmlprojectmanager/qmlproject.h index f163a9d2089caa9e34d9a65d499c0a1c961e036f..caa4a751b825aa5693cffe4164c73e7d1dc6d57c 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.h +++ b/src/plugins/qmlprojectmanager/qmlproject.h @@ -100,8 +100,9 @@ public: bool addFiles(const QStringList &filePaths); -private slots: void refreshProjectFile(); + +private slots: void refreshFiles(const QSet<QString> &added, const QSet<QString> &removed); protected: @@ -124,7 +125,6 @@ private: // qml based, new format QDeclarativeEngine m_engine; QWeakPointer<QmlProjectItem> m_projectItem; - Utils::FileSystemWatcher *m_fileWatcher; Internal::QmlProjectNode *m_rootNode; }; diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp index 44189f12f3687d2fed404d6bf54f25a98756adf3..4fd10bba868d9f53afe4dc5631239689f05ebb56 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp @@ -33,6 +33,7 @@ #include "qmlprojectfile.h" #include "qmlproject.h" #include "qmlprojectconstants.h" +#include <utils/qtcassert.h> namespace QmlProjectManager { namespace Internal { @@ -41,10 +42,14 @@ QmlProjectFile::QmlProjectFile(QmlProject *parent, QString fileName) : Core::IFile(parent), m_project(parent), m_fileName(fileName) -{ } +{ + QTC_CHECK(m_project); + QTC_CHECK(!fileName.isEmpty()); +} QmlProjectFile::~QmlProjectFile() -{ } +{ +} bool QmlProjectFile::save(QString *, const QString &, bool) { @@ -104,7 +109,10 @@ bool QmlProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty { Q_UNUSED(errorString) Q_UNUSED(flag) - Q_UNUSED(type) + + if (type == TypeContents) + m_project->refreshProjectFile(); + return true; }