Analyzer: Introduce AnalzyerAction

This wraps the menu related aspects of an IAnalyzerTool.

Change-Id: I065cb5f269a40af2137f434a7cdf915bd9a76839
Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
hjk
2013-08-07 19:47:30 +02:00
parent 256509541b
commit e94183ca2f
14 changed files with 192 additions and 174 deletions

View File

@@ -516,27 +516,11 @@ CallgrindTool::~CallgrindTool()
delete d;
}
Core::Id CallgrindTool::id() const
{
return Core::Id("Callgrind");
}
RunMode CallgrindTool::runMode() const
{
return CallgrindRunMode;
}
QString CallgrindTool::displayName() const
{
return tr("Valgrind Function Profiler");
}
QString CallgrindTool::description() const
{
return tr("Valgrind Profile uses the \"callgrind\" tool to "
"record function calls when a program runs.");
}
IAnalyzerTool::ToolMode CallgrindTool::toolMode() const
{
return ReleaseMode;

View File

@@ -45,10 +45,7 @@ public:
CallgrindTool(QObject *parent);
~CallgrindTool();
Core::Id id() const;
ProjectExplorer::RunMode runMode() const;
QString displayName() const;
QString description() const;
ToolMode toolMode() const;
void extensionsInitialized();

View File

@@ -276,27 +276,11 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
m_errorProxyModel->setFilterExternalIssues(memcheckSettings->filterExternalIssues());
}
Core::Id MemcheckTool::id() const
{
return Core::Id("Memcheck");
}
RunMode MemcheckTool::runMode() const
{
return MemcheckRunMode;
}
QString MemcheckTool::displayName() const
{
return tr("Valgrind Memory Analyzer");
}
QString MemcheckTool::description() const
{
return tr("Valgrind Analyze Memory uses the \"memcheck\" tool to find "
"memory leaks");
}
IAnalyzerTool::ToolMode MemcheckTool::toolMode() const
{
return DebugMode;
@@ -537,10 +521,9 @@ void MemcheckTool::finished()
const int issuesFound = m_errorModel->rowCount();
m_goBack->setEnabled(issuesFound > 1);
m_goNext->setEnabled(issuesFound > 1);
AnalyzerManager::showStatusMessage((issuesFound > 0
? AnalyzerManager::tr("Tool \"%1\" finished, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Tool \"%1\" finished, no issues were found."))
.arg(displayName()));
AnalyzerManager::showStatusMessage(issuesFound > 0
? AnalyzerManager::tr("Memory Analyzer Tool finished, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Memory Analyzer Tool finished, no issues were found."));
setBusyCursor(false);
}

View File

@@ -84,10 +84,7 @@ class MemcheckTool : public ValgrindTool
public:
MemcheckTool(QObject *parent);
Core::Id id() const;
ProjectExplorer::RunMode runMode() const;
QString displayName() const;
QString description() const;
private slots:
void settingsDestroyed(QObject *settings);
@@ -103,7 +100,6 @@ private slots:
private:
ToolMode toolMode() const;
void extensionsInitialized() {}
QWidget *createWidgets();
void setBusyCursor(bool busy);

View File

@@ -56,6 +56,12 @@ class ProjectSettingsFactory : public AnalyzerSubConfigFactory
}
};
class ValgrindAction : public AnalyzerAction
{
public:
ValgrindAction() {}
};
bool ValgrindPlugin::initialize(const QStringList &, QString *)
{
AnalyzerGlobalSettings::registerConfig(new ValgrindGlobalSettings());
@@ -63,12 +69,53 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
IAnalyzerTool *memcheckTool = new MemcheckTool(this);
IAnalyzerTool *callgrindTool = new CallgrindTool(this);
ValgrindAction *action = 0;
QString callgrindToolTip = tr("Valgrind Function Profile uses the "
"\"callgrind\" tool to record function calls when a program runs.");
QString memcheckToolTip = tr("Valgrind Analyze Memory uses the "
"\"memcheck\" tool to find memory leaks");
if (!Utils::HostOsInfo::isWindowsHost()) {
AnalyzerManager::addTool(memcheckTool, StartLocal);
AnalyzerManager::addTool(callgrindTool, StartLocal);
action = new ValgrindAction;
action->setId("Memcheck.Local");
action->setTool(memcheckTool);
action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(memcheckToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
action->setStartMode(StartLocal);
action->setEnabled(false);
AnalyzerManager::addAction(action);
action = new ValgrindAction;
action->setId("Callgrind.Local");
action->setTool(callgrindTool);
action->setText(tr("Valgrind Function Profiler"));
action->setToolTip(callgrindToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
action->setStartMode(StartLocal);
action->setEnabled(false);
AnalyzerManager::addAction(action);
}
AnalyzerManager::addTool(memcheckTool, StartRemote);
AnalyzerManager::addTool(callgrindTool, StartRemote);
action = new ValgrindAction;
action->setId("Memcheck.Remote");
action->setTool(memcheckTool);
action->setText(tr("Valgrind Memory Analyzer (Remote)"));
action->setToolTip(memcheckToolTip);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
action->setStartMode(StartRemote);
AnalyzerManager::addAction(action);
action = new ValgrindAction;
action->setId("Callgrind.Remote");
action->setTool(callgrindTool);
action->setText(tr("Valgrind Function Profiler (Remote)"));
action->setToolTip(callgrindToolTip);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
action->setStartMode(StartRemote);
AnalyzerManager::addAction(action);
addAutoReleasedObject(new ValgrindRunControlFactory());

View File

@@ -120,7 +120,8 @@ static void startLocalTool(IAnalyzerTool *tool)
default:
QTC_CHECK(false);
}
const QString toolName = tool->displayName();
//const QString toolName = tool->displayName();
const QString toolName = AnalyzerManager::tr("Tool"); // FIXME
const QString title = AnalyzerManager::tr("Run %1 in %2 Mode?").arg(toolName).arg(currentMode);
const QString message = AnalyzerManager::tr("<html><head/><body><p>You are trying "
"to run the tool \"%1\" on an application in %2 mode. "