Completely rework currentNode/currentProject handling

Centralize the handling inside a new class ProjectTree.
React to moving focus and remove most special handling.

This properly fixes the linked task.

Task-number: QTCREATORBUG-13357
Change-Id: I6b06aa32b1e4305ec8a6d432857b302585d8734b
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Daniel Teske
2014-11-19 17:58:33 +01:00
parent 042ef1aec0
commit 4943510b60
43 changed files with 744 additions and 470 deletions

View File

@@ -53,7 +53,7 @@
#include <coreplugin/icore.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/target.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/coreconstants.h>
@@ -100,8 +100,6 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":qmakeprojectmanager/QmakeProjectManager.mimetypes.xml"), errorMessage))
return false;
m_projectExplorer = ProjectExplorerPlugin::instance();
//create and register objects
m_qmakeProjectManager = new QmakeManager;
addObject(m_qmakeProjectManager);
@@ -235,8 +233,8 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
this, SLOT(buildStateChanged(ProjectExplorer::Project*)));
connect(SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
this, SLOT(startupProjectChanged()));
connect(m_projectExplorer, SIGNAL(currentNodeChanged(ProjectExplorer::Node*,ProjectExplorer::Project*)),
this, SLOT(updateContextActions(ProjectExplorer::Node*,ProjectExplorer::Project*)));
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
this, &QmakeProjectManagerPlugin::updateContextActions);
Core::ActionContainer *contextMenu = Core::ActionManager::createMenu(QmakeProjectManager::Constants::M_CONTEXT);
@@ -307,9 +305,9 @@ void QmakeProjectManagerPlugin::activeTargetChanged()
void QmakeProjectManagerPlugin::updateRunQMakeAction()
{
bool enable = true;
if (BuildManager::isBuilding(m_projectExplorer->currentProject()))
if (BuildManager::isBuilding(ProjectTree::currentProject()))
enable = false;
QmakeProject *pro = qobject_cast<QmakeProject *>(m_projectExplorer->currentProject());
QmakeProject *pro = qobject_cast<QmakeProject *>(ProjectTree::currentProject());
if (!pro
|| !pro->activeTarget()
|| !pro->activeTarget()->activeBuildConfiguration())
@@ -380,10 +378,10 @@ void QmakeProjectManagerPlugin::updateContextActions(ProjectExplorer::Node *node
void QmakeProjectManagerPlugin::buildStateChanged(ProjectExplorer::Project *pro)
{
ProjectExplorer::Project *currentProject = m_projectExplorer->currentProject();
ProjectExplorer::Project *currentProject = ProjectTree::currentProject();
if (pro == currentProject) {
updateRunQMakeAction();
updateContextActions(ProjectExplorerPlugin::currentNode(), pro);
updateContextActions(ProjectTree::currentNode(), pro);
updateBuildFileAction();
}
}