Commit aff2518b authored by Tobias Hunger's avatar Tobias Hunger

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()
modelManager->updateProjectInfo(pinfo);
modelManager->updateSourceFiles(m_files);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty());
}
}
......@@ -394,6 +394,8 @@ bool CMakeProject::parseCMakeLists()
modelmanager->updateProjectInfo(pinfo);
m_codeModelFuture.cancel();
m_codeModelFuture = modelmanager->updateSourceFiles(m_files);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty());
}
}
emit buildTargetsChanged();
......
......@@ -293,6 +293,7 @@ void GenericProject::refresh(RefreshOptions options)
}
pinfo.appendProjectPart(part);
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty());
modelManager->updateProjectInfo(pinfo);
m_codeModelFuture = modelManager->updateSourceFiles(filesToUpdate);
......
......@@ -404,6 +404,32 @@ void Project::setProjectLanguages(Core::Context language)
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
{
return d->m_projectContext;
......
......@@ -112,8 +112,8 @@ public:
QString projectDirectory() const;
static QString projectDirectory(const QString &top);
virtual Core::Context projectContext() const;
virtual Core::Context projectLanguages() const;
Core::Context projectContext() const;
Core::Context projectLanguages() const;
QVariant namedSettings(const QString &name) const;
void setNamedSettings(const QString &name, const QVariant &value);
......@@ -149,8 +149,11 @@ protected:
virtual bool fromMap(const QVariantMap &map);
virtual bool setupTarget(Target *t);
virtual void setProjectContext(Core::Context context);
virtual void setProjectLanguages(Core::Context language);
void setProjectContext(Core::Context context);
void setProjectLanguages(Core::Context language);
void addProjectLanguage(Core::Id id);
void removeProjectLanguage(Core::Id id);
void setProjectLanguage(Core::Id id, bool enabled);
private slots:
void changeEnvironment();
......
......@@ -521,6 +521,8 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData *prj)
}
}
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
if (pinfo.projectParts().isEmpty())
return;
......@@ -538,6 +540,8 @@ void QbsProject::updateQmlJsCodeModel(const qbs::ProjectData *prj)
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
QmlJSTools::defaultProjectInfoForProject(this);
setProjectLanguage(ProjectExplorer::Constants::LANG_QMLJS, !projectInfo.sourceFiles.isEmpty());
modelManager->updateProjectInfo(projectInfo);
}
......
......@@ -581,6 +581,8 @@ void Qt4Project::updateCppCodeModel()
pinfo.appendProjectPart(part);
}
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
modelmanager->updateProjectInfo(pinfo);
m_codeModelFuture = modelmanager->updateSourceFiles(allFiles);
}
......@@ -613,6 +615,8 @@ void Qt4Project::updateQmlJSCodeModel()
projectInfo.importPaths.removeDuplicates();
setProjectLanguage(ProjectExplorer::Constants::LANG_QMLJS, !projectInfo.sourceFiles.isEmpty());
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