Commit 2086d948 authored by hjk's avatar hjk Committed by hjk

analyzer: finish split of tools into "tools-with-modes"

Change-Id: I82b61c07172a33b861a7d6db903ac2516019498b
Reviewed-on: http://codereview.qt.nokia.com/1054Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent d6bf0c37
......@@ -71,7 +71,7 @@ public:
(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode);
// Register a tool and initialize it.
static void addTool(Analyzer::IAnalyzerTool *tool, const StartModes &mode);
static void addTool(IAnalyzerTool *tool, const StartModes &mode);
static IAnalyzerTool *toolById(const QByteArray &id);
// Dockwidgets are registered to the main window.
......@@ -83,9 +83,9 @@ public:
static void showMode();
static void selectTool(IAnalyzerTool *tool, StartMode mode);
static void startTool(IAnalyzerTool *tool, StartMode mode);
static void stopTool(IAnalyzerTool *tool);
static void stopTool(IAnalyzerTool *tool, StartMode mode);
// Convienience functions.
// Convenience functions.
static void startLocalTool(IAnalyzerTool *tool, StartMode mode);
static void startRemoteTool(IAnalyzerTool *tool, StartMode mode);
......@@ -95,7 +95,7 @@ public:
static void showStatusMessage(const QString &message, int timeoutMS = 10000);
static void showPermanentStatusMessage(const QString &message);
static void handleToolFinished(IAnalyzerTool *tool);
static void handleToolFinished(IAnalyzerTool *tool, StartMode mode);
private:
friend class AnalyzerManagerPrivate;
......
......@@ -131,7 +131,7 @@ void AnalyzerRunControl::engineFinished()
void AnalyzerRunControl::runControlFinished()
{
AnalyzerManager::handleToolFinished(d->m_engine->tool());
AnalyzerManager::handleToolFinished(d->m_engine->tool(), d->m_engine->mode());
}
bool AnalyzerRunControl::isRunning() const
......
......@@ -57,7 +57,7 @@ public:
RunConfiguration *runConfiguration);
~AnalyzerRunControl();
// pure virtuals from ProjectExplorer::RunControl
// ProjectExplorer::RunControl
void start();
StopResult stop();
bool isRunning() const;
......
......@@ -45,6 +45,7 @@
using namespace Analyzer;
using namespace Analyzer::Internal;
using namespace ProjectExplorer;
/////////////////////////////////////////////////////////////////////////////////
//
......@@ -55,6 +56,7 @@ using namespace Analyzer::Internal;
AnalyzerRunControlFactory::AnalyzerRunControlFactory(QObject *parent)
: IRunControlFactory(parent)
{
setObjectName(QLatin1String("AnalyzerRunControlFactory"));
}
bool AnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
......@@ -62,8 +64,7 @@ bool AnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const
return runConfiguration->isEnabled() && mode == Constants::MODE_ANALYZE;
}
ProjectExplorer::RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration,
const QString &mode)
RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode)
{
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
return AnalyzerManager::createRunControl(runConfiguration, mode);
......@@ -74,16 +75,15 @@ QString AnalyzerRunControlFactory::displayName() const
return tr("Analyzer");
}
ProjectExplorer::IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect()
IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect()
{
return new AnalyzerProjectSettings;
}
ProjectExplorer::RunConfigWidget *AnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration
*runConfiguration)
RunConfigWidget *AnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
{
ProjectExplorer::LocalApplicationRunConfiguration *localRc =
qobject_cast<ProjectExplorer::LocalApplicationRunConfiguration *>(runConfiguration);
LocalApplicationRunConfiguration *localRc =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
if (!localRc)
return 0;
AnalyzerProjectSettings *settings = runConfiguration->extraAspect<AnalyzerProjectSettings>();
......
......@@ -83,7 +83,8 @@ public:
const AnalyzerStartParameters &startParameters() const { return m_sp; }
/// The tool this engine is associated with.
IAnalyzerTool *tool() { return m_tool; }
IAnalyzerTool *tool() const { return m_tool; }
StartMode mode() const { return m_sp.startMode; }
signals:
/// Should be emitted when the debuggee outputted something.
......
......@@ -41,19 +41,6 @@ IAnalyzerTool::IAnalyzerTool(QObject *parent)
: QObject(parent)
{}
QString IAnalyzerTool::modeString(ToolMode mode)
{
switch (mode) {
case IAnalyzerTool::DebugMode:
return tr("Debug");
case IAnalyzerTool::ReleaseMode:
return tr("Release");
case IAnalyzerTool::AnyMode:
break;
}
return QString();
}
QByteArray IAnalyzerTool::defaultMenuGroup(StartMode mode)
{
if (mode == StartRemote)
......@@ -61,15 +48,17 @@ QByteArray IAnalyzerTool::defaultMenuGroup(StartMode mode)
return Analyzer::Constants::G_ANALYZER_TOOLS;
}
QByteArray IAnalyzerTool::defaultActionId(const QByteArray &id, StartMode mode)
QByteArray IAnalyzerTool::defaultActionId(const IAnalyzerTool *tool, StartMode mode)
{
QByteArray id = tool->id();
if (mode == StartRemote)
return "Action." + id + ".RemoteStart." + QByteArray::number(mode);
return "Action." + id + ".LocalStart." + QByteArray::number(mode);
}
QString IAnalyzerTool::defaultActionName(const QString &base, StartMode mode)
QString IAnalyzerTool::defaultActionName(const IAnalyzerTool *tool, StartMode mode)
{
QString base = tool->displayName();
if (mode == StartRemote)
return base + tr(" (Remote)");
return base;
......
......@@ -78,12 +78,14 @@ public:
/// Returns a user readable description name for this tool.
virtual QString description() const = 0;
/// Returns an id for the start action.
virtual QByteArray actionId(StartMode m) const { return defaultActionId(id(), m); }
virtual QByteArray actionId(StartMode mode) const
{ return defaultActionId(this, mode); }
/// Returns the menu group the start action should go to.
virtual QByteArray menuGroup(StartMode m) const { return defaultMenuGroup(m); }
virtual QByteArray menuGroup(StartMode mode) const
{ return defaultMenuGroup(mode); }
/// Returns a short user readable action name for this tool.
virtual QString actionName(StartMode m) const
{ return defaultActionName(displayName(), m); }
virtual QString actionName(StartMode mode) const
{ return defaultActionName(this, mode); }
/**
* The mode in which this tool should preferably be run
......@@ -97,14 +99,12 @@ public:
ReleaseMode,
AnyMode
};
virtual ToolMode mode() const = 0;
static QString modeString(ToolMode mode);
virtual ToolMode toolMode() const = 0;
/// Convenience implementation.
static QByteArray defaultMenuGroup(StartMode m);
static QByteArray defaultActionId(const QByteArray &id, StartMode m);
static QString defaultActionName(const QString &base, StartMode m);
static QByteArray defaultMenuGroup(StartMode mode);
static QByteArray defaultActionId(const IAnalyzerTool *tool, StartMode mode);
static QString defaultActionName(const IAnalyzerTool *tool, StartMode mode);
static void defaultStartTool(IAnalyzerTool *tool, StartMode mode);
/// This gets called after all analyzation tools where initialized.
......@@ -125,8 +125,8 @@ public:
virtual IAnalyzerEngine *createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0) = 0;
virtual void startTool(StartMode m)
{ return defaultStartTool(this, m); }
virtual void startTool(StartMode mode)
{ return defaultStartTool(this, mode); }
/// Called when tools gets selected.
virtual void toolSelected() const {}
......
......@@ -48,7 +48,7 @@ const char * const C_QMLDEBUGGER = "Qml/JavaScript Debugger";
// Project Explorer run mode (RUN/DEBUG)
const char * const DEBUGMODE = "Debugger.DebugMode";
const char * const DEBUGMODE2 = "Debugger.DebugMode2";
const char * const DEBUGMODE2 = "Debugger.DebugMode2"; // Breaks on main.
// Common actions (accessed by QML inspector)
const char * const INTERRUPT = "Debugger.Interrupt";
......
......@@ -159,7 +159,7 @@ void QmlProfilerEngine::stop()
void QmlProfilerEngine::stopped()
{
d->m_running = false;
AnalyzerManager::stopTool(tool());
AnalyzerManager::stopTool(tool(), mode());
emit finished();
}
......
......@@ -121,6 +121,7 @@ public:
QmlProfilerTool::QmlProfilerTool(QObject *parent)
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
{
setObjectName("QmlProfilerTool");
d->m_client = 0;
d->m_connectionAttempts = 0;
d->m_traceWindow = 0;
......@@ -163,7 +164,7 @@ QString QmlProfilerTool::description() const
"applications using QML.");
}
IAnalyzerTool::ToolMode QmlProfilerTool::mode() const
IAnalyzerTool::ToolMode QmlProfilerTool::toolMode() const
{
return AnyMode;
}
......
......@@ -51,7 +51,7 @@ public:
QByteArray id() const;
QString displayName() const;
QString description() const;
ToolMode mode() const;
ToolMode toolMode() const;
void extensionsInitialized() {}
void initializeDockWidgets();
......
......@@ -68,6 +68,7 @@ AnalyzerStartParameters localStartParameters(ProjectExplorer::RunConfiguration *
QmlProjectAnalyzerRunControlFactory::QmlProjectAnalyzerRunControlFactory(QObject *parent)
: IRunControlFactory(parent)
{
setObjectName(QLatin1String("QmlProjectAnalyzerRunControlFactory"));
}
bool QmlProjectAnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
......
......@@ -501,9 +501,9 @@ CallgrindTool::CallgrindTool(QObject *parent)
: Analyzer::IAnalyzerTool(parent)
{
d = new CallgrindToolPrivate(this);
Core::ICore *core = Core::ICore::instance();
setObjectName(QLatin1String("CallgrindTool"));
// EditorManager
Core::ICore *core = Core::ICore::instance();
QObject *editorManager = core->editorManager();
connect(editorManager, SIGNAL(editorOpened(Core::IEditor*)),
d, SLOT(editorOpened(Core::IEditor*)));
......@@ -530,7 +530,7 @@ QString CallgrindTool::description() const
"record function calls when a program runs.");
}
IAnalyzerTool::ToolMode CallgrindTool::mode() const
IAnalyzerTool::ToolMode CallgrindTool::toolMode() const
{
return ReleaseMode;
}
......
......@@ -51,7 +51,7 @@ public:
QByteArray id() const;
QString displayName() const;
QString description() const;
ToolMode mode() const;
ToolMode toolMode() const;
void extensionsInitialized();
void initializeDockWidgets();
......
......@@ -229,11 +229,6 @@ void MemcheckTool::settingsDestroyed(QObject *settings)
m_settings = AnalyzerGlobalSettings::instance();
}
void MemcheckTool::extensionsInitialized()
{
//ensureWidgets(); // FIXME: Try to do that later.
}
void MemcheckTool::maybeActiveRunConfigurationChanged()
{
ensureWidgets();
......@@ -308,7 +303,7 @@ QString MemcheckTool::description() const
"memory leaks");
}
IAnalyzerTool::ToolMode MemcheckTool::mode() const
IAnalyzerTool::ToolMode MemcheckTool::toolMode() const
{
return DebugMode;
}
......
......@@ -110,10 +110,10 @@ private slots:
void suppressionActionTriggered();
private:
ToolMode mode() const;
ToolMode toolMode() const;
void ensureWidgets();
void initializeDockWidgets();
void extensionsInitialized();
void extensionsInitialized() {}
QWidget *createControlWidget();
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
......@@ -122,7 +122,6 @@ private:
void clearErrorView();
private:
bool m_local;
Analyzer::AnalyzerSettings *m_settings;
QMenu *m_filterMenu;
......
......@@ -130,7 +130,7 @@ QString ValgrindEngine::executable() const
void ValgrindEngine::handleProgressCanceled()
{
AnalyzerManager::stopTool(tool());
AnalyzerManager::stopTool(tool(), mode());
}
void ValgrindEngine::handleProgressFinished()
......
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