Commit e505604b authored by dt's avatar dt
Browse files

ProjectExplore: Introduce dis/enabling of buildconfigurations

The build actions are disabled if the buildconfiguration is disabled.
The deploy and run actions are disabled if deploying or running invokes
building automatically.

Qt4BuildConfigurations are disabled while parsing.

Task-Nr: QTCREATORBUG-2576
parent 8fdef8e3
......@@ -211,6 +211,11 @@ void BuildConfiguration::cloneSteps(BuildConfiguration *source)
}
}
bool BuildConfiguration::isEnabled() const
{
return true;
}
bool BuildConfigMacroExpander::resolveMacro(const QString &name, QString *ret)
{
if (name == QLatin1String("sourceDir")) {
......
......@@ -93,11 +93,14 @@ public:
Target *target() const;
virtual bool isEnabled() const;
Utils::AbstractMacroExpander *macroExpander() { return &m_macroExpander; }
signals:
void environmentChanged();
void buildDirectoryChanged();
void enabledChanged();
protected:
BuildConfiguration(Target *target, const QString &id);
......
......@@ -103,11 +103,17 @@ QString Project::makeUnique(const QString &preferredName, const QStringList &use
void Project::changeEnvironment()
{
Target *t(qobject_cast<Target *>(sender()));
Target *t = qobject_cast<Target *>(sender());
if (t == activeTarget())
emit environmentChanged();
}
void Project::changeBuildConfigurationEnabled()
{
Target *t = qobject_cast<Target *>(sender());
if (t == activeTarget())
emit buildConfigurationEnabledChanged();
}
void Project::addTarget(Target *t)
{
......@@ -127,6 +133,8 @@ void Project::addTarget(Target *t)
d->m_targets.push_back(t);
connect(t, SIGNAL(environmentChanged()),
SLOT(changeEnvironment()));
connect(t, SIGNAL(buildConfigurationEnabledChanged()),
this, SLOT(changeBuildConfigurationEnabled()));
emit addedTarget(t);
// check activeTarget:
......@@ -169,6 +177,7 @@ void Project::setActiveTarget(Target *target)
d->m_activeTarget = target;
emit activeTargetChanged(d->m_activeTarget);
emit environmentChanged();
emit buildConfigurationEnabledChanged();
}
}
......
......@@ -131,9 +131,14 @@ signals:
/// convenience signal emitted if the activeBuildConfiguration emits environmentChanged
/// or if the activeBuildConfiguration changes
/// (which theoretically might happen due to the active target changing).
/// (including due to the active target changing).
void environmentChanged();
/// convenience signal emitted if the activeBuildConfiguration emits isEnabledChanged()
/// or if the activeBuildConfiguration changes
/// (including due to the active target changing).
void buildConfigurationEnabledChanged();
protected:
// restore all data from the map.
//
......@@ -142,6 +147,7 @@ protected:
private slots:
void changeEnvironment();
void changeBuildConfigurationEnabled();
private:
QScopedPointer<ProjectPrivate> d;
......
......@@ -295,6 +295,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
this, SLOT(invalidateProject(ProjectExplorer::Project *)));
connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
this, SIGNAL(fileListChanged()));
connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
this, SLOT(projectAdded(ProjectExplorer::Project*)));
connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project *)),
this, SLOT(startupProjectChanged()));
connect(d->m_session, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)),
......@@ -1469,20 +1473,21 @@ void ProjectExplorerPlugin::updateActions()
Project *project = startupProject();
bool enableBuildActions = project
&& ! (d->m_buildManager->isBuilding(project))
&& hasBuildSettings(project);
&& hasBuildSettings(project)
&& buildSettingsEnabled(project);
bool enableBuildActionsContextMenu = d->m_currentProject
&& ! (d->m_buildManager->isBuilding(d->m_currentProject))
&& hasBuildSettings(d->m_currentProject);
&& hasBuildSettings(d->m_currentProject)
&& buildSettingsEnabled(d->m_currentProject);
bool hasProjects = !d->m_session->projects().isEmpty();
bool building = d->m_buildManager->isBuilding();
bool enabledSessionBuildActions = !d->m_buildManager->isBuilding()
&& hasBuildSettings(0)
&& buildSettingsEnabled(0);
QString projectName = project ? project->displayName() : QString();
QString projectNameContextMenu = d->m_currentProject ? d->m_currentProject->displayName() : QString();
if (debug)
qDebug() << "BuildManager::isBuilding()" << building;
d->m_unloadAction->setParameter(projectNameContextMenu);
d->m_buildAction->setParameter(projectName);
......@@ -1505,11 +1510,11 @@ void ProjectExplorerPlugin::updateActions()
d->m_rebuildProjectOnlyAction->setEnabled(enableBuildActions);
d->m_cleanProjectOnlyAction->setEnabled(enableBuildActions);
d->m_clearSession->setEnabled(hasProjects && !building);
d->m_buildSessionAction->setEnabled(hasProjects && !building);
d->m_rebuildSessionAction->setEnabled(hasProjects && !building);
d->m_cleanSessionAction->setEnabled(hasProjects && !building);
d->m_cancelBuildAction->setEnabled(building);
d->m_clearSession->setEnabled(hasProjects && enabledSessionBuildActions);
d->m_buildSessionAction->setEnabled(hasProjects && enabledSessionBuildActions);
d->m_rebuildSessionAction->setEnabled(hasProjects && enabledSessionBuildActions);
d->m_cleanSessionAction->setEnabled(hasProjects && enabledSessionBuildActions);
d->m_cancelBuildAction->setEnabled(d->m_buildManager->isBuilding());
d->m_publishAction->setEnabled(hasProjects);
......@@ -1716,11 +1721,26 @@ bool ProjectExplorerPlugin::hasBuildSettings(Project *pro)
{
const QList<Project *> & projects = d->m_session->projectOrder(pro);
foreach(Project *project, projects)
if (project->activeTarget()->activeBuildConfiguration())
if (project
&& project->activeTarget()
&& project->activeTarget()->activeBuildConfiguration())
return true;
return false;
}
bool ProjectExplorerPlugin::buildSettingsEnabled(Project *pro)
{
const QList<Project *> & projects = d->m_session->projectOrder(pro);
foreach(Project *project, projects)
if (project
&& project->activeTarget()
&& project->activeTarget()->activeBuildConfiguration()
&& !project->activeTarget()->activeBuildConfiguration()->isEnabled())
return false;
return true;
}
bool ProjectExplorerPlugin::coreAboutToClose()
{
if (d->m_buildManager->isBuilding()) {
......@@ -1785,6 +1805,20 @@ void ProjectExplorerPlugin::runControlFinished()
emit updateRunActions();
}
void ProjectExplorerPlugin::projectAdded(ProjectExplorer::Project *pro)
{
// more specific action en and disabling ?
connect(pro, SIGNAL(buildConfigurationEnabledChanged()),
this, SLOT(updateActions()));
}
void ProjectExplorerPlugin::projectRemoved(ProjectExplorer::Project * pro)
{
// more specific action en and disabling ?
disconnect(pro, SIGNAL(buildConfigurationEnabledChanged()),
this, SLOT(updateActions()));
}
void ProjectExplorerPlugin::startupProjectChanged()
{
static QPointer<Project> previousStartupProject = 0;
......@@ -1875,6 +1909,15 @@ void ProjectExplorerPlugin::updateDeployActions()
&& ! (d->m_buildManager->isBuilding(d->m_currentProject))
&& hasDeploySettings(d->m_currentProject);
if (d->m_projectExplorerSettings.buildBeforeDeploy) {
if (hasBuildSettings(project)
&& !buildSettingsEnabled(project))
enableDeployActions = false;
if (hasBuildSettings(d->m_currentProject)
&& !buildSettingsEnabled(d->m_currentProject))
enableDeployActionsContextMenu = false;
}
const QString projectName = project ? project->displayName() : QString();
const QString projectNameContextMenu = d->m_currentProject ? d->m_currentProject->displayName() : QString();
bool hasProjects = !d->m_session->projects().isEmpty();
......@@ -1900,6 +1943,14 @@ bool ProjectExplorerPlugin::canRun(Project *project, const QString &runMode)
!project->activeTarget()->activeRunConfiguration()) {
return false;
}
if (d->m_projectExplorerSettings.buildBeforeDeploy
&& d->m_projectExplorerSettings.deployBeforeRun
&& hasBuildSettings(project)
&& !buildSettingsEnabled(project))
return false;
RunConfiguration *activeRC = project->activeTarget()->activeRunConfiguration();
bool canRun = findRunControlFactory(activeRC, runMode)
......
......@@ -195,9 +195,10 @@ private slots:
void setCurrentFile(const QString &filePath);
// RunControl
void runControlFinished();
void projectAdded(ProjectExplorer::Project *pro);
void projectRemoved(ProjectExplorer::Project *pro);
void startupProjectChanged(); // Calls updateRunAction
void activeTargetChanged();
void activeRunConfigurationChanged();
......@@ -236,6 +237,7 @@ private:
bool parseArguments(const QStringList &arguments, QString *error);
void executeRunConfiguration(RunConfiguration *, const QString &mode);
bool hasBuildSettings(Project *pro);
bool buildSettingsEnabled(Project *pro);
bool hasDeploySettings(Project *pro);
void setCurrent(Project *project, QString filePath, Node *node);
......
......@@ -108,6 +108,13 @@ void Target::changeEnvironment()
emit environmentChanged();
}
void Target::changeBuildConfigurationEnabled()
{
ProjectExplorer::BuildConfiguration *bc = qobject_cast<ProjectExplorer::BuildConfiguration *>(sender());
if (bc == activeBuildConfiguration())
emit buildConfigurationEnabledChanged();
}
Project *Target::project() const
{
return static_cast<Project *>(parent());
......@@ -137,6 +144,9 @@ void Target::addBuildConfiguration(BuildConfiguration *configuration)
connect(configuration, SIGNAL(environmentChanged()),
SLOT(changeEnvironment()));
connect(configuration, SIGNAL(enabledChanged()),
this, SLOT(changeBuildConfigurationEnabled()));
if (!activeBuildConfiguration())
setActiveBuildConfiguration(configuration);
}
......@@ -179,6 +189,7 @@ void Target::setActiveBuildConfiguration(BuildConfiguration *configuration)
d->m_activeBuildConfiguration = configuration;
emit activeBuildConfigurationChanged(d->m_activeBuildConfiguration);
emit environmentChanged();
emit buildConfigurationEnabledChanged();
}
}
......
......@@ -136,6 +136,10 @@ signals:
/// environmentChanged() or if the active build configuration changes
void environmentChanged();
/// convenience signal, emitted if either the active buildconfiguration emits
/// enabledChanged() or if the active build configuration changes
void buildConfigurationEnabledChanged();
protected:
Target(Project *parent, const QString &id);
......@@ -145,6 +149,7 @@ protected:
private slots:
void changeEnvironment();
void changeBuildConfigurationEnabled();
private:
QScopedPointer<TargetPrivate> d;
......
......@@ -70,6 +70,7 @@ enum { debug = 0 };
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BaseTarget *target) :
BuildConfiguration(target, QLatin1String(QT4_BC_ID)),
m_shadowBuild(true),
m_isEnabled(false),
m_qtVersionId(-1),
m_toolChainType(-1), // toolChainType() makes sure to return the default toolchainType
m_qmakeBuildConfiguration(0),
......@@ -81,6 +82,7 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BaseTarget *target) :
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BaseTarget *target, const QString &id) :
BuildConfiguration(target, id),
m_shadowBuild(true),
m_isEnabled(false),
m_qtVersionId(-1),
m_toolChainType(-1), // toolChainType() makes sure to return the default toolchainType
m_qmakeBuildConfiguration(0),
......@@ -92,6 +94,7 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BaseTarget *target, const QStrin
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BaseTarget *target, Qt4BuildConfiguration *source) :
BuildConfiguration(target, source),
m_shadowBuild(source->m_shadowBuild),
m_isEnabled(false),
m_buildDirectory(source->m_buildDirectory),
m_qtVersionId(source->m_qtVersionId),
m_toolChainType(source->m_toolChainType),
......@@ -652,6 +655,19 @@ ProjectExplorer::IOutputParser *Qt4BuildConfiguration::createOutputParser() cons
return 0;
}
bool Qt4BuildConfiguration::isEnabled() const
{
return m_isEnabled;
}
void Qt4BuildConfiguration::setEnabled(bool enabled)
{
if (m_isEnabled == enabled)
return;
m_isEnabled = enabled;
emit enabledChanged();
}
/*!
\class Qt4BuildConfigurationFactory
*/
......
......@@ -123,6 +123,10 @@ public:
ProjectExplorer::IOutputParser *createOutputParser() const;
virtual bool isEnabled() const;
/// \internal For Qt4Project, since that manages the parsing information
void setEnabled(bool enabled);
public slots:
void importFromBuildDirectory();
......@@ -160,6 +164,7 @@ private:
QString rawBuildDirectory() const;
bool m_shadowBuild;
bool m_isEnabled;
QString m_buildDirectory;
QString m_lastEmmitedBuildDirectory;
int m_qtVersionId;
......
......@@ -1394,7 +1394,6 @@ void Qt4ProFileNode::emitProFileUpdated()
}
}
void Qt4ProFileNode::emitProFileInvalidated()
{
foreach (NodesWatcher *watcher, watchers())
......
......@@ -610,6 +610,7 @@ void Qt4Project::update()
if (debug)
qDebug()<<"State is now Base";
m_asyncUpdateState = Base;
activeTarget()->activeBuildConfiguration()->setEnabled(true);
}
void Qt4Project::scheduleAsyncUpdate(Qt4ProFileNode *node)
......@@ -630,6 +631,8 @@ void Qt4Project::scheduleAsyncUpdate(Qt4ProFileNode *node)
return;
}
activeTarget()->activeBuildConfiguration()->setEnabled(false);
if (m_asyncUpdateState == AsyncFullUpdatePending) {
// Just postpone
if (debug)
......@@ -698,6 +701,7 @@ void Qt4Project::scheduleAsyncUpdate()
qDebug()<<" update in progress, canceling and setting state to full update pending";
m_cancelEvaluate = true;
m_asyncUpdateState = AsyncFullUpdatePending;
activeTarget()->activeBuildConfiguration()->setEnabled(false);
m_rootProjectNode->emitProFileInvalidated();
return;
}
......@@ -705,6 +709,7 @@ void Qt4Project::scheduleAsyncUpdate()
if (debug)
qDebug()<<" starting timer for full update, setting state to full update pending";
m_partialEvaluate.clear();
activeTarget()->activeBuildConfiguration()->setEnabled(false);
m_rootProjectNode->emitProFileInvalidated();
m_asyncUpdateState = AsyncFullUpdatePending;
m_asyncUpdateTimer.start();
......@@ -750,6 +755,7 @@ void Qt4Project::decrementPendingEvaluateFutures()
m_asyncUpdateTimer.start();
} else if (m_asyncUpdateState != ShuttingDown){
// After being done, we need to call:
activeTarget()->activeBuildConfiguration()->setEnabled(true);
foreach (Target *t, targets())
static_cast<Qt4BaseTarget *>(t)->createApplicationProFiles();
updateFileList();
......
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