From 16b4e4e91ffc04c86cdb6afc67d6a4acc26e734d Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 22 Jun 2010 12:54:19 +0200 Subject: QmlJS: Fix import path handling in the model manager. Previously, the model manager always had exactly one import path - but you can open more than one Qml project at once. Now, we store the union of all import paths in the model manager. Reviewed-by: Roberto Raggi --- src/plugins/qmljseditor/qmljsmodelmanager.cpp | 66 +++++++++++++++++++-------- 1 file changed, 48 insertions(+), 18 deletions(-) (limited to 'src/plugins/qmljseditor/qmljsmodelmanager.cpp') diff --git a/src/plugins/qmljseditor/qmljsmodelmanager.cpp b/src/plugins/qmljseditor/qmljsmodelmanager.cpp index bd5bd6a9e9..1df8e4c8e7 100644 --- a/src/plugins/qmljseditor/qmljsmodelmanager.cpp +++ b/src/plugins/qmljseditor/qmljsmodelmanager.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -180,6 +181,33 @@ void ModelManager::removeFiles(const QStringList &files) _snapshot.remove(file); } +QList ModelManager::projectInfos() const +{ + QMutexLocker locker(&m_mutex); + + return m_projects.values(); +} + +ModelManager::ProjectInfo ModelManager::projectInfo(ProjectExplorer::Project *project) const +{ + QMutexLocker locker(&m_mutex); + + return m_projects.value(project, ProjectInfo(project)); +} + +void ModelManager::updateProjectInfo(const ProjectInfo &pinfo) +{ + if (! pinfo.isValid()) + return; + + { + QMutexLocker locker(&m_mutex); + m_projects.insert(pinfo.project, pinfo); + } + + updateImportPaths(); +} + void ModelManager::emitDocumentChangedOnDisk(Document::Ptr doc) { emit documentChangedOnDisk(doc); } @@ -400,26 +428,9 @@ bool ModelManager::matchesMimeType(const Core::MimeType &fileMimeType, const Cor return false; } -void ModelManager::setProjectImportPaths(const QStringList &importPaths) -{ - m_projectImportPaths = importPaths; - - // check if any file in the snapshot imports something new in the new paths - Snapshot snapshot = _snapshot; - QStringList importedFiles; - QSet scannedPaths; - foreach (const Document::Ptr &doc, snapshot) - findNewLibraryImports(doc, snapshot, this, &importedFiles, &scannedPaths); - - updateSourceFiles(importedFiles, true); -} - QStringList ModelManager::importPaths() const { - QStringList paths; - paths << m_projectImportPaths; - paths << m_defaultImportPaths; - return paths; + return m_allImportPaths; } static QStringList environmentImportPaths() @@ -471,6 +482,25 @@ void ModelManager::loadQmlPluginTypes(const QString &pluginPath) m_runningQmldumps.insert(process, pluginPath); } +void ModelManager::updateImportPaths() +{ + QMapIterator it(m_projects); + while (it.hasNext()) { + it.next(); + m_allImportPaths += it.value().importPaths; + } + m_allImportPaths += m_defaultImportPaths; + + // check if any file in the snapshot imports something new in the new paths + Snapshot snapshot = _snapshot; + QStringList importedFiles; + QSet scannedPaths; + foreach (const Document::Ptr &doc, snapshot) + findNewLibraryImports(doc, snapshot, this, &importedFiles, &scannedPaths); + + updateSourceFiles(importedFiles, true); +} + void ModelManager::qmlPluginTypeDumpDone(int exitCode) { QProcess *process = qobject_cast(sender()); -- cgit v1.2.1