Analyzer: Move isRunnable() decision to AnalyzerAction

Closer to where the information is.

Change-Id: I3ff7e933a99baf8a18e6532213aef0539a364a76
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-18 16:53:25 +01:00
parent 9d707ac63c
commit aab3b6f816
3 changed files with 12 additions and 13 deletions

View File

@@ -153,7 +153,6 @@ public:
void handleToolFinished();
void saveToolSettings(Id toolId);
void loadToolSettings(Id toolId);
bool isActionRunnable(AnalyzerAction *action) const;
void startTool();
void selectToolboxAction(int);
void modeChanged(IMode *mode);
@@ -419,16 +418,6 @@ bool AnalyzerManagerPrivate::showPromptDialog(const QString &title, const QStrin
return messageBox.clickedStandardButton() == QDialogButtonBox::Yes;
}
bool AnalyzerManagerPrivate::isActionRunnable(AnalyzerAction *action) const
{
if (!action || m_isRunning)
return false;
if (action->startMode() == StartRemote)
return true;
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->runMode(), 0);
}
void AnalyzerManagerPrivate::startTool()
{
QTC_ASSERT(m_currentAction, return);
@@ -583,12 +572,12 @@ void AnalyzerManagerPrivate::updateRunActions()
ProjectExplorerPlugin::canRun(SessionManager::startupProject(),
m_currentAction->runMode(), &disabledReason);
m_startAction->setEnabled(isActionRunnable(m_currentAction));
m_startAction->setEnabled(!m_isRunning && m_currentAction && m_currentAction->isRunnable());
m_startAction->setToolTip(disabledReason);
m_toolBox->setEnabled(!m_isRunning);
m_stopAction->setEnabled(m_isRunning);
foreach (AnalyzerAction *action, m_actions)
action->setEnabled(isActionRunnable(action));
action->setEnabled(!m_isRunning && action->isRunnable());
}
////////////////////////////////////////////////////////////////////

View File

@@ -62,6 +62,14 @@ AnalyzerAction::AnalyzerAction(QObject *parent)
: QAction(parent)
{}
bool AnalyzerAction::isRunnable() const
{
if (startMode() == StartRemote)
return true;
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), runMode(), 0);
}
static bool buildTypeAccepted(ToolMode toolMode, BuildConfiguration::BuildType buildType)
{
if (toolMode == AnyMode)

View File

@@ -94,6 +94,8 @@ public:
ProjectExplorer::RunMode runMode() const { return m_runMode; }
void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; }
bool isRunnable() const;
/// Creates all widgets used by the tool.
/// Returns a control widget which will be shown in the status bar when
/// this tool is selected.