Commit aff2518b authored by Tobias Hunger's avatar Tobias Hunger
Browse files

ProjectManagers: Update project languages based on data sent to the codemodel



Change-Id: Iecf61f66389fff6f3995c4f4bc893ffd190c50e6
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 920e7ca1
...@@ -456,5 +456,7 @@ void AutotoolsProject::updateCppCodeModel() ...@@ -456,5 +456,7 @@ void AutotoolsProject::updateCppCodeModel()
modelManager->updateProjectInfo(pinfo); modelManager->updateProjectInfo(pinfo);
modelManager->updateSourceFiles(m_files); modelManager->updateSourceFiles(m_files);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty());
} }
} }
...@@ -394,6 +394,8 @@ bool CMakeProject::parseCMakeLists() ...@@ -394,6 +394,8 @@ bool CMakeProject::parseCMakeLists()
modelmanager->updateProjectInfo(pinfo); modelmanager->updateProjectInfo(pinfo);
m_codeModelFuture.cancel(); m_codeModelFuture.cancel();
m_codeModelFuture = modelmanager->updateSourceFiles(m_files); m_codeModelFuture = modelmanager->updateSourceFiles(m_files);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty());
} }
} }
emit buildTargetsChanged(); emit buildTargetsChanged();
......
...@@ -293,6 +293,7 @@ void GenericProject::refresh(RefreshOptions options) ...@@ -293,6 +293,7 @@ void GenericProject::refresh(RefreshOptions options)
} }
pinfo.appendProjectPart(part); pinfo.appendProjectPart(part);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty());
modelManager->updateProjectInfo(pinfo); modelManager->updateProjectInfo(pinfo);
m_codeModelFuture = modelManager->updateSourceFiles(filesToUpdate); m_codeModelFuture = modelManager->updateSourceFiles(filesToUpdate);
......
...@@ -404,6 +404,32 @@ void Project::setProjectLanguages(Core::Context language) ...@@ -404,6 +404,32 @@ void Project::setProjectLanguages(Core::Context language)
emit projectLanguagesUpdated(); emit projectLanguagesUpdated();
} }
void Project::addProjectLanguage(Core::Id id)
{
Core::Context lang = projectLanguages();
int pos = lang.indexOf(id);
if (pos < 0)
lang.add(id);
setProjectLanguages(lang);
}
void Project::removeProjectLanguage(Core::Id id)
{
Core::Context lang = projectLanguages();
int pos = lang.indexOf(id);
if (pos >= 0)
lang.removeAt(pos);
setProjectLanguages(lang);
}
void Project::setProjectLanguage(Core::Id id, bool enabled)
{
if (enabled)
addProjectLanguage(id);
else
removeProjectLanguage(id);
}
Core::Context Project::projectContext() const Core::Context Project::projectContext() const
{ {
return d->m_projectContext; return d->m_projectContext;
......
...@@ -112,8 +112,8 @@ public: ...@@ -112,8 +112,8 @@ public:
QString projectDirectory() const; QString projectDirectory() const;
static QString projectDirectory(const QString &top); static QString projectDirectory(const QString &top);
virtual Core::Context projectContext() const; Core::Context projectContext() const;
virtual Core::Context projectLanguages() const; Core::Context projectLanguages() const;
QVariant namedSettings(const QString &name) const; QVariant namedSettings(const QString &name) const;
void setNamedSettings(const QString &name, const QVariant &value); void setNamedSettings(const QString &name, const QVariant &value);
...@@ -149,8 +149,11 @@ protected: ...@@ -149,8 +149,11 @@ protected:
virtual bool fromMap(const QVariantMap &map); virtual bool fromMap(const QVariantMap &map);
virtual bool setupTarget(Target *t); virtual bool setupTarget(Target *t);
virtual void setProjectContext(Core::Context context); void setProjectContext(Core::Context context);
virtual void setProjectLanguages(Core::Context language); void setProjectLanguages(Core::Context language);
void addProjectLanguage(Core::Id id);
void removeProjectLanguage(Core::Id id);
void setProjectLanguage(Core::Id id, bool enabled);
private slots: private slots:
void changeEnvironment(); void changeEnvironment();
......
...@@ -521,6 +521,8 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData *prj) ...@@ -521,6 +521,8 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData *prj)
} }
} }
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
if (pinfo.projectParts().isEmpty()) if (pinfo.projectParts().isEmpty())
return; return;
...@@ -538,6 +540,8 @@ void QbsProject::updateQmlJsCodeModel(const qbs::ProjectData *prj) ...@@ -538,6 +540,8 @@ void QbsProject::updateQmlJsCodeModel(const qbs::ProjectData *prj)
QmlJS::ModelManagerInterface::ProjectInfo projectInfo = QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
QmlJSTools::defaultProjectInfoForProject(this); QmlJSTools::defaultProjectInfoForProject(this);
setProjectLanguage(ProjectExplorer::Constants::LANG_QMLJS, !projectInfo.sourceFiles.isEmpty());
modelManager->updateProjectInfo(projectInfo); modelManager->updateProjectInfo(projectInfo);
} }
......
...@@ -581,6 +581,8 @@ void Qt4Project::updateCppCodeModel() ...@@ -581,6 +581,8 @@ void Qt4Project::updateCppCodeModel()
pinfo.appendProjectPart(part); pinfo.appendProjectPart(part);
} }
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
modelmanager->updateProjectInfo(pinfo); modelmanager->updateProjectInfo(pinfo);
m_codeModelFuture = modelmanager->updateSourceFiles(allFiles); m_codeModelFuture = modelmanager->updateSourceFiles(allFiles);
} }
...@@ -613,6 +615,8 @@ void Qt4Project::updateQmlJSCodeModel() ...@@ -613,6 +615,8 @@ void Qt4Project::updateQmlJSCodeModel()
projectInfo.importPaths.removeDuplicates(); projectInfo.importPaths.removeDuplicates();
setProjectLanguage(ProjectExplorer::Constants::LANG_QMLJS, !projectInfo.sourceFiles.isEmpty());
modelManager->updateProjectInfo(projectInfo); modelManager->updateProjectInfo(projectInfo);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment