diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-06-22 12:54:19 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-06-22 13:25:22 +0200 |
commit | 16b4e4e91ffc04c86cdb6afc67d6a4acc26e734d (patch) | |
tree | 264de9a4eade464af5d9eba14a393cc4ee34a6a0 /src/plugins/qmljseditor/qmljsmodelmanager.cpp | |
parent | eba9157476abfb34c4fe60a1f7911ed8b2a636ec (diff) | |
download | qt-creator-16b4e4e91ffc04c86cdb6afc67d6a4acc26e734d.tar.gz |
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
Diffstat (limited to 'src/plugins/qmljseditor/qmljsmodelmanager.cpp')
-rw-r--r-- | src/plugins/qmljseditor/qmljsmodelmanager.cpp | 66 |
1 files changed, 48 insertions, 18 deletions
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 <qmljs/qmljsbind.h> #include <qmljs/parser/qmldirparser_p.h> #include <texteditor/itexteditor.h> +#include <projectexplorer/project.h> #include <QDir> #include <QFile> @@ -180,6 +181,33 @@ void ModelManager::removeFiles(const QStringList &files) _snapshot.remove(file); } +QList<ModelManager::ProjectInfo> 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<QString> 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<ProjectExplorer::Project *, ProjectInfo> 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<QString> 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<QProcess *>(sender()); |