forked from qt-creator/qt-creator
ProjectExplorer: Update context whenever project language/context changes
Change-Id: I3bd68518f8aab50e10353b7664e81f6d6783c6cc Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -390,12 +390,18 @@ QString Project::generatedUiHeader(const QString & /* formFile */) const
|
||||
|
||||
void Project::setProjectContext(Core::Context context)
|
||||
{
|
||||
if (d->m_projectContext == context)
|
||||
return;
|
||||
d->m_projectContext = context;
|
||||
emit projectContextUpdated();
|
||||
}
|
||||
|
||||
void Project::setProjectLanguages(Core::Context language)
|
||||
{
|
||||
if (d->m_projectLanguages == language)
|
||||
return;
|
||||
d->m_projectLanguages = language;
|
||||
emit projectLanguagesUpdated();
|
||||
}
|
||||
|
||||
Core::Context Project::projectContext() const
|
||||
|
||||
@@ -142,6 +142,9 @@ signals:
|
||||
void settingsLoaded();
|
||||
void aboutToSaveSettings();
|
||||
|
||||
void projectContextUpdated();
|
||||
void projectLanguagesUpdated();
|
||||
|
||||
protected:
|
||||
virtual bool fromMap(const QVariantMap &map);
|
||||
virtual bool setupTarget(Target *t);
|
||||
|
||||
@@ -211,6 +211,7 @@ struct ProjectExplorerPluginPrivate {
|
||||
QString m_sessionToRestoreAtStartup;
|
||||
|
||||
Project *m_currentProject;
|
||||
Core::Context m_lastProjectContext;
|
||||
Node *m_currentNode;
|
||||
|
||||
BuildManager *m_buildManager;
|
||||
@@ -1757,7 +1758,25 @@ void ProjectExplorerPlugin::updateExternalFileWarning()
|
||||
}
|
||||
infoBar->addInfo(Core::InfoBarEntry(externalFileId,
|
||||
tr("<b>Warning:</b> This file is outside the project directory."),
|
||||
Core::InfoBarEntry::GlobalSuppressionEnabled));
|
||||
Core::InfoBarEntry::GlobalSuppressionEnabled));
|
||||
}
|
||||
|
||||
void ProjectExplorerPlugin::updateContext()
|
||||
{
|
||||
Core::Context oldContext;
|
||||
oldContext.add(d->m_lastProjectContext);
|
||||
|
||||
Core::Context newContext;
|
||||
if (d->m_currentProject) {
|
||||
newContext.add(d->m_currentProject->projectContext());
|
||||
newContext.add(d->m_currentProject->projectLanguages());
|
||||
|
||||
d->m_lastProjectContext = newContext;
|
||||
} else {
|
||||
d->m_lastProjectContext = Core::Context();
|
||||
}
|
||||
|
||||
Core::ICore::updateAdditionalContexts(oldContext, newContext);
|
||||
}
|
||||
|
||||
void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node *node)
|
||||
@@ -1773,24 +1792,22 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
|
||||
|
||||
bool projectChanged = false;
|
||||
if (d->m_currentProject != project) {
|
||||
Core::Context oldContext;
|
||||
Core::Context newContext;
|
||||
|
||||
if (d->m_currentProject) {
|
||||
oldContext.add(d->m_currentProject->projectContext());
|
||||
oldContext.add(d->m_currentProject->projectLanguages());
|
||||
disconnect(d->m_currentProject, SIGNAL(projectContextUpdated()),
|
||||
this, SLOT(updateContext()));
|
||||
disconnect(d->m_currentProject, SIGNAL(projectLanguagesUpdated()),
|
||||
this, SLOT(updateContext()));
|
||||
}
|
||||
if (project) {
|
||||
newContext.add(project->projectContext());
|
||||
newContext.add(project->projectLanguages());
|
||||
connect(project, SIGNAL(projectContextUpdated()),
|
||||
this, SLOT(updateContext()));
|
||||
connect(project, SIGNAL(projectLanguagesUpdated()),
|
||||
this, SLOT(updateContext()));
|
||||
}
|
||||
|
||||
Core::ICore::updateAdditionalContexts(oldContext, newContext);
|
||||
|
||||
d->m_currentProject = project;
|
||||
|
||||
projectChanged = true;
|
||||
}
|
||||
d->m_currentProject = project;
|
||||
updateContext();
|
||||
|
||||
if (!node && Core::EditorManager::currentEditor()) {
|
||||
connect(Core::EditorManager::currentEditor(), SIGNAL(changed()),
|
||||
|
||||
@@ -239,6 +239,8 @@ private slots:
|
||||
void updateWelcomePage();
|
||||
void updateExternalFileWarning();
|
||||
|
||||
void updateContext();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
void testAnsiFilterOutputParser_data();
|
||||
void testAnsiFilterOutputParser();
|
||||
|
||||
Reference in New Issue
Block a user