Analyzer: Move runMode member from IAnalyzerTool to AnalyzerAction

Slim down tool before dissolving.

Change-Id: I502aaa8860293acf8bfd93f541b751d5b96a9563
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-18 11:05:22 +01:00
parent f160d2b8f5
commit 35d3088252
9 changed files with 40 additions and 28 deletions

View File

@@ -431,7 +431,7 @@ bool AnalyzerManagerPrivate::isActionRunnable(AnalyzerAction *action) const
if (action->startMode() == StartRemote) if (action->startMode() == StartRemote)
return true; return true;
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->tool()->runMode(), 0); return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->runMode(), 0);
} }
void AnalyzerManagerPrivate::startTool() void AnalyzerManagerPrivate::startTool()
@@ -590,7 +590,7 @@ void AnalyzerManagerPrivate::updateRunActions()
disabledReason = tr("No analyzer tool selected."); disabledReason = tr("No analyzer tool selected.");
else else
ProjectExplorerPlugin::canRun(SessionManager::startupProject(), ProjectExplorerPlugin::canRun(SessionManager::startupProject(),
m_currentAction->tool()->runMode(), &disabledReason); m_currentAction->runMode(), &disabledReason);
m_startAction->setEnabled(isActionRunnable(m_currentAction)); m_startAction->setEnabled(isActionRunnable(m_currentAction));
m_startAction->setToolTip(disabledReason); m_startAction->setToolTip(disabledReason);
@@ -707,9 +707,8 @@ AnalyzerRunControl *AnalyzerManager::createRunControl(
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
{ {
foreach (AnalyzerAction *action, d->m_actions) { foreach (AnalyzerAction *action, d->m_actions) {
IAnalyzerTool *tool = action->tool(); if (action->runMode() == sp.runMode && action->startMode() == sp.startMode)
if (tool->runMode() == sp.runMode && action->startMode() == sp.startMode) return action->tool()->createRunControl(sp, runConfiguration);
return tool->createRunControl(sp, runConfiguration);
} }
QTC_CHECK(false); QTC_CHECK(false);
return 0; return 0;

View File

@@ -62,13 +62,12 @@ IAnalyzerTool::IAnalyzerTool(QObject *parent)
: QObject(parent) : QObject(parent)
{} {}
/// Returns the run mode for this tool. ProjectExplorer::RunMode AnalyzerAction::runMode() const
ProjectExplorer::RunMode IAnalyzerTool::runMode() const
{ {
return m_runMode; return m_runMode;
} }
void IAnalyzerTool::setRunMode(ProjectExplorer::RunMode mode) void AnalyzerAction::setRunMode(ProjectExplorer::RunMode mode)
{ {
m_runMode = mode; m_runMode = mode;
} }
@@ -103,7 +102,7 @@ static bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
return false; return false;
} }
void IAnalyzerTool::startLocalTool() void IAnalyzerTool::startLocalTool(RunMode runMode)
{ {
// Make sure mode is shown. // Make sure mode is shown.
AnalyzerManager::showMode(); AnalyzerManager::showMode();
@@ -154,10 +153,10 @@ void IAnalyzerTool::startLocalTool()
return; return;
} }
ProjectExplorerPlugin::instance()->runProject(pro, runMode()); ProjectExplorerPlugin::instance()->runProject(pro, runMode);
} }
void IAnalyzerTool::startRemoteTool() void IAnalyzerTool::startRemoteTool(RunMode runMode)
{ {
StartRemoteDialog dlg; StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
@@ -173,7 +172,7 @@ void IAnalyzerTool::startRemoteTool()
AnalyzerRunControl *rc = createRunControl(sp, 0); AnalyzerRunControl *rc = createRunControl(sp, 0);
ProjectExplorerPlugin::startRunControl(rc, runMode()); ProjectExplorerPlugin::startRunControl(rc, runMode);
} }
} // namespace Analyzer } // namespace Analyzer

View File

@@ -68,9 +68,6 @@ class ANALYZER_EXPORT IAnalyzerTool : public QObject
public: public:
explicit IAnalyzerTool(QObject *parent = 0); explicit IAnalyzerTool(QObject *parent = 0);
ProjectExplorer::RunMode runMode() const;
void setRunMode(ProjectExplorer::RunMode mode);
/** /**
* The mode in which this tool should preferably be run * The mode in which this tool should preferably be run
* *
@@ -98,11 +95,10 @@ public:
virtual void startTool(StartMode mode) = 0; virtual void startTool(StartMode mode) = 0;
void startLocalTool(); void startLocalTool(ProjectExplorer::RunMode runMode);
void startRemoteTool(); void startRemoteTool(ProjectExplorer::RunMode runMode);
private: private:
ProjectExplorer::RunMode m_runMode;
ToolMode m_toolMode; ToolMode m_toolMode;
}; };
@@ -131,11 +127,15 @@ public:
Core::Id id() const { return m_id; } Core::Id id() const { return m_id; }
void setId(Core::Id id) { m_id = id; } void setId(Core::Id id) { m_id = id; }
ProjectExplorer::RunMode runMode() const;
void setRunMode(ProjectExplorer::RunMode mode);
protected: protected:
IAnalyzerTool *m_tool; IAnalyzerTool *m_tool;
StartMode m_startMode; StartMode m_startMode;
Core::Id m_menuGroup; Core::Id m_menuGroup;
Core::Id m_id; Core::Id m_id;
ProjectExplorer::RunMode m_runMode;
}; };

View File

@@ -63,6 +63,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
action = new AnalyzerAction(this); action = new AnalyzerAction(this);
action->setId("QmlProfiler.Local"); action->setId("QmlProfiler.Local");
action->setTool(tool); action->setTool(tool);
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
action->setText(tr("QML Profiler")); action->setText(tr("QML Profiler"));
action->setToolTip(description); action->setToolTip(description);
action->setStartMode(StartLocal); action->setStartMode(StartLocal);
@@ -72,6 +73,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
action = new AnalyzerAction(this); action = new AnalyzerAction(this);
action->setId("QmlProfiler.Remote"); action->setId("QmlProfiler.Remote");
action->setTool(tool); action->setTool(tool);
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
action->setText(tr("QML Profiler (External)")); action->setText(tr("QML Profiler (External)"));
action->setToolTip(description); action->setToolTip(description);
action->setStartMode(StartRemote); action->setStartMode(StartRemote);

View File

@@ -124,7 +124,6 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate) : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate)
{ {
setObjectName(QLatin1String("QmlProfilerTool")); setObjectName(QLatin1String("QmlProfilerTool"));
setRunMode(QmlProfilerRunMode);
setToolMode(AnyMode); setToolMode(AnyMode);
d->m_profilerState = 0; d->m_profilerState = 0;
@@ -528,7 +527,7 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
AnalyzerRunControl *rc = tool->createRunControl(sp, 0); AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
ProjectExplorerPlugin::startRunControl(rc, tool->runMode()); ProjectExplorerPlugin::startRunControl(rc, QmlProfilerRunMode);
} }
void QmlProfilerTool::startTool(StartMode mode) void QmlProfilerTool::startTool(StartMode mode)
@@ -546,7 +545,7 @@ void QmlProfilerTool::startTool(StartMode mode)
if (mode == StartLocal) { if (mode == StartLocal) {
// ### not sure if we're supposed to check if the RunConFiguration isEnabled // ### not sure if we're supposed to check if the RunConFiguration isEnabled
Project *pro = SessionManager::startupProject(); Project *pro = SessionManager::startupProject();
ProjectExplorerPlugin::instance()->runProject(pro, runMode()); ProjectExplorerPlugin::instance()->runProject(pro, QmlProfilerRunMode);
} else if (mode == StartRemote) { } else if (mode == StartRemote) {
Internal::startRemoteTool(this, mode); Internal::startRemoteTool(this, mode);
} }

View File

@@ -502,7 +502,6 @@ CallgrindTool::CallgrindTool(QObject *parent)
{ {
d = new CallgrindToolPrivate(this); d = new CallgrindToolPrivate(this);
setObjectName(QLatin1String("CallgrindTool")); setObjectName(QLatin1String("CallgrindTool"));
setRunMode(CallgrindRunMode);
setToolMode(ReleaseMode); setToolMode(ReleaseMode);
connect(EditorManager::instance(), &EditorManager::editorOpened, connect(EditorManager::instance(), &EditorManager::editorOpened,
@@ -561,9 +560,9 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa
void CallgrindTool::startTool(StartMode mode) void CallgrindTool::startTool(StartMode mode)
{ {
if (mode == StartLocal) if (mode == StartLocal)
startLocalTool(); startLocalTool(CallgrindRunMode);
if (mode == StartRemote) if (mode == StartRemote)
startRemoteTool(); startRemoteTool(CallgrindRunMode);
d->setBusyCursor(true); d->setBusyCursor(true);
} }

View File

@@ -196,7 +196,6 @@ MemcheckTool::MemcheckTool(QObject *parent)
m_filterMenu = 0; m_filterMenu = 0;
setObjectName(QLatin1String("MemcheckTool")); setObjectName(QLatin1String("MemcheckTool"));
setRunMode(MemcheckRunMode);
setToolMode(DebugMode); setToolMode(DebugMode);
m_filterProjectAction = new QAction(tr("External Errors"), this); m_filterProjectAction = new QAction(tr("External Errors"), this);
@@ -602,18 +601,27 @@ void MemcheckTool::setBusyCursor(bool busy)
void MemcheckTool::startTool(StartMode mode) void MemcheckTool::startTool(StartMode mode)
{ {
if (mode == StartLocal) if (mode == StartLocal)
startLocalTool(); startLocalTool(MemcheckRunMode);
if (mode == StartRemote) if (mode == StartRemote)
startRemoteTool(); startRemoteTool(MemcheckRunMode);
} }
MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) : MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) :
MemcheckTool(parent) MemcheckTool(parent)
{ {
setRunMode(MemcheckWithGdbRunMode);
setObjectName(QLatin1String("MemcheckWithGdbTool")); setObjectName(QLatin1String("MemcheckWithGdbTool"));
} }
void MemcheckWithGdbTool::startTool(Analyzer::StartMode mode)
{
if (mode == StartLocal)
startLocalTool(MemcheckWithGdbRunMode);
if (mode == StartRemote)
startRemoteTool(MemcheckWithGdbRunMode);
}
MemcheckRunControl *MemcheckWithGdbTool::createMemcheckRunControl(const AnalyzerStartParameters &sp, MemcheckRunControl *MemcheckWithGdbTool::createMemcheckRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration) RunConfiguration *runConfiguration)
{ {

View File

@@ -139,6 +139,7 @@ public:
MemcheckWithGdbTool(QObject *parent); MemcheckWithGdbTool(QObject *parent);
protected: protected:
void startTool(Analyzer::StartMode mode);
MemcheckRunControl *createMemcheckRunControl( MemcheckRunControl *createMemcheckRunControl(
const Analyzer::AnalyzerStartParameters &sp, const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) Q_DECL_OVERRIDE; ProjectExplorer::RunConfiguration *runConfiguration) Q_DECL_OVERRIDE;

View File

@@ -128,6 +128,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action = new AnalyzerAction(this); action = new AnalyzerAction(this);
action->setId("Memcheck.Local"); action->setId("Memcheck.Local");
action->setTool(m_memcheckTool); action->setTool(m_memcheckTool);
action->setRunMode(ProjectExplorer::MemcheckRunMode);
action->setText(tr("Valgrind Memory Analyzer")); action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(memcheckToolTip); action->setToolTip(memcheckToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
@@ -138,6 +139,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action = new AnalyzerAction(this); action = new AnalyzerAction(this);
action->setId("MemcheckWithGdb.Local"); action->setId("MemcheckWithGdb.Local");
action->setTool(m_memcheckWithGdbTool); action->setTool(m_memcheckWithGdbTool);
action->setRunMode(ProjectExplorer::MemcheckWithGdbRunMode);
action->setText(tr("Valgrind Memory Analyzer with GDB")); action->setText(tr("Valgrind Memory Analyzer with GDB"));
action->setToolTip(memcheckWithGdbToolTip); action->setToolTip(memcheckWithGdbToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
@@ -148,6 +150,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action = new AnalyzerAction(this); action = new AnalyzerAction(this);
action->setId("Callgrind.Local"); action->setId("Callgrind.Local");
action->setTool(m_callgrindTool); action->setTool(m_callgrindTool);
action->setRunMode(ProjectExplorer::CallgrindRunMode);
action->setText(tr("Valgrind Function Profiler")); action->setText(tr("Valgrind Function Profiler"));
action->setToolTip(callgrindToolTip); action->setToolTip(callgrindToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
@@ -159,6 +162,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action = new AnalyzerAction(this); action = new AnalyzerAction(this);
action->setId("Memcheck.Remote"); action->setId("Memcheck.Remote");
action->setTool(m_memcheckTool); action->setTool(m_memcheckTool);
action->setRunMode(ProjectExplorer::MemcheckRunMode);
action->setText(tr("Valgrind Memory Analyzer (External Remote Application)")); action->setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
action->setToolTip(memcheckToolTip); action->setToolTip(memcheckToolTip);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
@@ -168,6 +172,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action = new AnalyzerAction(this); action = new AnalyzerAction(this);
action->setId("Callgrind.Remote"); action->setId("Callgrind.Remote");
action->setTool(m_callgrindTool); action->setTool(m_callgrindTool);
action->setRunMode(ProjectExplorer::CallgrindRunMode);
action->setText(tr("Valgrind Function Profiler (External Remote Application)")); action->setText(tr("Valgrind Function Profiler (External Remote Application)"));
action->setToolTip(callgrindToolTip); action->setToolTip(callgrindToolTip);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);