forked from qt-creator/qt-creator
analyzer: move responsibility for run modes to individual tools
Change-Id: Iaf2fa9d4c087470649336a453c6a9a7db12d220f Reviewed-on: http://codereview.qt.nokia.com/1051 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -39,12 +39,19 @@
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
enum AnalyzerStartMode
|
||||
class StartMode
|
||||
{
|
||||
StartLocal,
|
||||
StartRemote
|
||||
public:
|
||||
explicit StartMode(int m = 0) : m(m) {}
|
||||
operator int() const { return m; }
|
||||
void operator=(int m_) { m = m_; }
|
||||
// Often used modes.
|
||||
private:
|
||||
int m;
|
||||
};
|
||||
|
||||
enum { StartLocal = -1, StartRemote = -2 };
|
||||
|
||||
namespace Constants {
|
||||
|
||||
// modes and their priorities
|
||||
|
@@ -100,7 +100,6 @@
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Analyzer;
|
||||
using namespace Analyzer::Internal;
|
||||
|
||||
namespace Analyzer {
|
||||
@@ -135,11 +134,11 @@ AnalyzerStartParameters remoteLinuxStartParameters(ProjectExplorer::RunConfigura
|
||||
= qobject_cast<RemoteLinux::RemoteLinuxRunConfiguration *>(runConfiguration);
|
||||
QTC_ASSERT(rc, return sp);
|
||||
|
||||
sp.startMode = StartRemote;
|
||||
sp.debuggee = rc->remoteExecutableFilePath();
|
||||
sp.debuggeeArgs = rc->arguments();
|
||||
sp.connParams = rc->deviceConfig()->sshParameters();
|
||||
sp.analyzerCmdPrefix = rc->commandPrefix();
|
||||
sp.startMode = StartRemote;
|
||||
sp.displayName = rc->displayName();
|
||||
return sp;
|
||||
}
|
||||
@@ -178,7 +177,6 @@ public:
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Analyzer
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -186,7 +184,7 @@ public:
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AnalyzerManager::AnalyzerManagerPrivate : public QObject
|
||||
class AnalyzerManagerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -211,27 +209,29 @@ public:
|
||||
const QString &stopButtonText, const QString &cancelButtonText) const;
|
||||
|
||||
void addDock(Qt::DockWidgetArea area, QDockWidget *dockWidget);
|
||||
void startLocalTool(IAnalyzerTool *tool);
|
||||
void startRemoteTool(IAnalyzerTool *tool);
|
||||
void addTool(IAnalyzerTool *tool);
|
||||
void addTool(IAnalyzerTool *tool, const StartModes &modes);
|
||||
void stopTool(IAnalyzerTool *tool);
|
||||
void handleToolFinished(IAnalyzerTool *tool);
|
||||
int indexOf(IAnalyzerTool *tool) const;
|
||||
IAnalyzerTool *toolAt(int idx) const;
|
||||
void saveToolSettings(IAnalyzerTool *tool);
|
||||
void loadToolSettings(IAnalyzerTool *tool);
|
||||
void selectTool(IAnalyzerTool *tool, StartMode mode);
|
||||
|
||||
ProjectExplorer::RunControl *createRunControl
|
||||
(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode);
|
||||
|
||||
// Convenience.
|
||||
void startLocalTool(IAnalyzerTool *tool, StartMode mode);
|
||||
void startRemoteTool(IAnalyzerTool *tool, StartMode mode);
|
||||
|
||||
public slots:
|
||||
void startTool();
|
||||
void stopTool() { stopTool(m_currentTool); }
|
||||
|
||||
void selectTool();
|
||||
void selectTool(IAnalyzerTool *tool);
|
||||
void selectTool(QAction *);
|
||||
void selectTool(int);
|
||||
void selectAction();
|
||||
void selectAction(QAction *);
|
||||
void selectAction(int);
|
||||
void modeChanged(Core::IMode *mode);
|
||||
void resetLayout();
|
||||
void updateRunActions();
|
||||
@@ -243,8 +243,10 @@ public:
|
||||
ProjectExplorer::RunControl *m_currentRunControl;
|
||||
Utils::FancyMainWindow *m_mainWindow;
|
||||
IAnalyzerTool *m_currentTool;
|
||||
StartMode m_currentMode;
|
||||
QHash<QAction *, IAnalyzerTool *> m_toolFromAction;
|
||||
QList<IAnalyzerTool *> m_tools;
|
||||
QList<QAction *> m_actions;
|
||||
QAction *m_startAction;
|
||||
QAction *m_stopAction;
|
||||
ActionContainer *m_menu;
|
||||
@@ -264,13 +266,14 @@ public:
|
||||
bool m_initialized;
|
||||
};
|
||||
|
||||
AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
|
||||
AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
|
||||
q(qq),
|
||||
m_mode(0),
|
||||
m_runControlFactory(0),
|
||||
m_currentRunControl(0),
|
||||
m_mainWindow(0),
|
||||
m_currentTool(0),
|
||||
m_currentMode(),
|
||||
m_startAction(0),
|
||||
m_stopAction(0),
|
||||
m_menu(0),
|
||||
@@ -282,7 +285,7 @@ AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager
|
||||
m_initialized(false)
|
||||
{
|
||||
m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox"));
|
||||
connect(m_toolBox, SIGNAL(currentIndexChanged(int)), SLOT(selectTool(int)));
|
||||
connect(m_toolBox, SIGNAL(currentIndexChanged(int)), SLOT(selectAction(int)));
|
||||
|
||||
m_runControlFactory = new AnalyzerRunControlFactory();
|
||||
AnalyzerPlugin::instance()->addAutoReleasedObject(m_runControlFactory);
|
||||
@@ -296,7 +299,7 @@ AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager
|
||||
connect(pe, SIGNAL(updateRunActions()), SLOT(updateRunActions()));
|
||||
}
|
||||
|
||||
AnalyzerManager::AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
|
||||
AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
|
||||
{
|
||||
// as we have to setParent(0) on dock widget that are not selected,
|
||||
// we keep track of all and make sure we don't leak any
|
||||
@@ -306,7 +309,7 @@ AnalyzerManager::AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
|
||||
}
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::setupActions()
|
||||
void AnalyzerManagerPrivate::setupActions()
|
||||
{
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
Core::ActionManager *am = core->actionManager();
|
||||
@@ -347,7 +350,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::setupActions()
|
||||
m_viewsMenu = am->actionContainer(Core::Id(Core::Constants::M_WINDOW_VIEWS));
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::delayedInit()
|
||||
void AnalyzerManagerPrivate::delayedInit()
|
||||
{
|
||||
if (m_initialized)
|
||||
return;
|
||||
@@ -359,7 +362,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::delayedInit()
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
QWidget *AnalyzerManager::AnalyzerManagerPrivate::createModeContents()
|
||||
QWidget *AnalyzerManagerPrivate::createModeContents()
|
||||
{
|
||||
// right-side window with editor, output etc.
|
||||
MiniSplitter *mainWindowSplitter = new MiniSplitter;
|
||||
@@ -385,7 +388,7 @@ static QToolButton *toolButton(QAction *action)
|
||||
return button;
|
||||
}
|
||||
|
||||
QWidget *AnalyzerManager::AnalyzerManagerPrivate::createModeMainWindow()
|
||||
QWidget *AnalyzerManagerPrivate::createModeMainWindow()
|
||||
{
|
||||
m_mainWindow = new Utils::FancyMainWindow();
|
||||
m_mainWindow->setObjectName(QLatin1String("AnalyzerManagerMainWindow"));
|
||||
@@ -448,7 +451,7 @@ QWidget *AnalyzerManager::AnalyzerManagerPrivate::createModeMainWindow()
|
||||
return m_mainWindow;
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::addDock(Qt::DockWidgetArea area,
|
||||
void AnalyzerManagerPrivate::addDock(Qt::DockWidgetArea area,
|
||||
QDockWidget *dockWidget)
|
||||
{
|
||||
dockWidget->setParent(m_mainWindow);
|
||||
@@ -481,7 +484,7 @@ bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AnalyzerManager::AnalyzerManagerPrivate::showPromptDialog(const QString &title,
|
||||
bool AnalyzerManagerPrivate::showPromptDialog(const QString &title,
|
||||
const QString &text,
|
||||
const QString &stopButtonText,
|
||||
const QString &cancelButtonText) const
|
||||
@@ -500,7 +503,7 @@ bool AnalyzerManager::AnalyzerManagerPrivate::showPromptDialog(const QString &ti
|
||||
return messageBox.clickedStandardButton() == QDialogButtonBox::Yes;
|
||||
}
|
||||
|
||||
ProjectExplorer::RunControl *AnalyzerManager::AnalyzerManagerPrivate::createRunControl
|
||||
ProjectExplorer::RunControl *AnalyzerManagerPrivate::createRunControl
|
||||
(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode)
|
||||
{
|
||||
Q_UNUSED(mode);
|
||||
@@ -521,7 +524,7 @@ ProjectExplorer::RunControl *AnalyzerManager::AnalyzerManagerPrivate::createRunC
|
||||
return rc;
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::startRemoteTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManagerPrivate::startRemoteTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
Q_UNUSED(tool);
|
||||
StartRemoteDialog dlg;
|
||||
@@ -529,11 +532,12 @@ void AnalyzerManager::AnalyzerManagerPrivate::startRemoteTool(IAnalyzerTool *too
|
||||
return;
|
||||
|
||||
AnalyzerStartParameters sp;
|
||||
sp.toolId = tool->id();
|
||||
sp.startMode = mode;
|
||||
sp.connParams = dlg.sshParams();
|
||||
sp.debuggee = dlg.executable();
|
||||
sp.debuggeeArgs = dlg.arguments();
|
||||
sp.displayName = dlg.executable();
|
||||
sp.startMode = StartRemote;
|
||||
sp.workingDirectory = dlg.workingDirectory();
|
||||
|
||||
AnalyzerRunControl *runControl = new AnalyzerRunControl(tool, sp, 0);
|
||||
@@ -544,14 +548,15 @@ void AnalyzerManager::AnalyzerManagerPrivate::startRemoteTool(IAnalyzerTool *too
|
||||
->startRunControl(runControl, Constants::MODE_ANALYZE);
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::startLocalTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManagerPrivate::startLocalTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
int index = indexOf(tool);
|
||||
QTC_ASSERT(index >= 0, return);
|
||||
QTC_ASSERT(index < m_tools.size(), return);
|
||||
QTC_ASSERT(tool == m_currentTool, return);
|
||||
QTC_ASSERT(mode == StartLocal, /**/);
|
||||
|
||||
// make sure mode is shown
|
||||
// Make sure mode is shown.
|
||||
q->showMode();
|
||||
|
||||
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
|
||||
@@ -594,8 +599,8 @@ void AnalyzerManager::AnalyzerManagerPrivate::startLocalTool(IAnalyzerTool *tool
|
||||
// Check the project for whether the build config is in the correct mode
|
||||
// if not, notify the user and urge him to use the correct mode.
|
||||
if (!buildTypeAccepted(toolMode, buildType)) {
|
||||
const QString &toolName = tool->displayName();
|
||||
const QString &toolMode = IAnalyzerTool::modeString(tool->mode());
|
||||
const QString toolName = tool->displayName();
|
||||
const QString toolMode = IAnalyzerTool::modeString(tool->mode());
|
||||
const QString currentMode = buildType == ProjectExplorer::BuildConfiguration::Debug ? tr("Debug") : tr("Release");
|
||||
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
@@ -629,13 +634,12 @@ void AnalyzerManager::AnalyzerManagerPrivate::startLocalTool(IAnalyzerTool *tool
|
||||
updateRunActions();
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::startTool()
|
||||
void AnalyzerManagerPrivate::startTool()
|
||||
{
|
||||
if (m_currentTool)
|
||||
m_currentTool->startTool();
|
||||
m_currentTool->startTool(m_currentMode);
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::stopTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManagerPrivate::stopTool(IAnalyzerTool *tool)
|
||||
{
|
||||
QTC_ASSERT(tool == m_currentTool, /**/);
|
||||
if (m_currentRunControl)
|
||||
@@ -647,7 +651,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::stopTool(IAnalyzerTool *tool)
|
||||
// else: wait for the finished() signal to trigger handleToolFinished()
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::modeChanged(IMode *mode)
|
||||
void AnalyzerManagerPrivate::modeChanged(IMode *mode)
|
||||
{
|
||||
if (!m_mainWindow)
|
||||
return;
|
||||
@@ -657,12 +661,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::modeChanged(IMode *mode)
|
||||
m_mainWindow->setDockActionsVisible(makeVisible);
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::selectTool(int index)
|
||||
{
|
||||
selectTool(m_tools[index]);
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::selectTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManagerPrivate::selectTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
int idx = indexOf(tool);
|
||||
QTC_ASSERT(idx >= 0, return);
|
||||
@@ -692,6 +691,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::selectTool(IAnalyzerTool *tool)
|
||||
}
|
||||
|
||||
m_currentTool = tool;
|
||||
m_currentMode = mode;
|
||||
|
||||
m_toolBox->setCurrentIndex(idx);
|
||||
m_controlsWidget->setCurrentIndex(idx);
|
||||
@@ -709,68 +709,77 @@ void AnalyzerManager::AnalyzerManagerPrivate::selectTool(IAnalyzerTool *tool)
|
||||
updateRunActions();
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::selectTool()
|
||||
void AnalyzerManagerPrivate::selectAction()
|
||||
{
|
||||
selectTool(qobject_cast<QAction *>(sender()));
|
||||
selectAction(qobject_cast<QAction *>(sender()));
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::selectTool(QAction *action)
|
||||
void AnalyzerManagerPrivate::selectAction(int index)
|
||||
{
|
||||
selectTool(m_toolFromAction[action]);
|
||||
selectAction(m_actions[index]);
|
||||
}
|
||||
|
||||
int AnalyzerManager::AnalyzerManagerPrivate::indexOf(IAnalyzerTool *tool) const
|
||||
void AnalyzerManagerPrivate::selectAction(QAction *action)
|
||||
{
|
||||
StartMode mode = StartMode(action->property("StartMode").toInt());
|
||||
selectTool(m_toolFromAction[action], mode);
|
||||
}
|
||||
|
||||
int AnalyzerManagerPrivate::indexOf(IAnalyzerTool *tool) const
|
||||
{
|
||||
return m_tools.indexOf(tool);
|
||||
}
|
||||
|
||||
IAnalyzerTool *AnalyzerManager::AnalyzerManagerPrivate::toolAt(int idx) const
|
||||
IAnalyzerTool *AnalyzerManagerPrivate::toolAt(int idx) const
|
||||
{
|
||||
QTC_ASSERT(idx >= 0, return 0);
|
||||
QTC_ASSERT(idx < m_tools.size(), return 0);
|
||||
return m_tools.at(idx);
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::addTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManagerPrivate::addTool(IAnalyzerTool *tool, const StartModes &modes)
|
||||
{
|
||||
ActionManager *am = Core::ICore::instance()->actionManager();
|
||||
delayedInit(); // be sure that there is a valid IMode instance
|
||||
|
||||
QString actionId = QString("Action.Analyzer.Tools." + tool->id());
|
||||
QString displayName = tool->displayName();
|
||||
QAction *action = new QAction(displayName, 0);
|
||||
qDebug() << "ACTION: " << tool << actionId;
|
||||
|
||||
Core::Command *command = am->registerAction(action, actionId,
|
||||
Core::Context(Core::Constants::C_GLOBAL));
|
||||
m_menu->addAction(command, QString::fromLatin1(tool->menuGroup()));
|
||||
connect(action, SIGNAL(triggered()), SLOT(selectTool()));
|
||||
|
||||
const bool blocked = m_toolBox->blockSignals(true); // Do not make current.
|
||||
m_toolBox->addItem(displayName);
|
||||
m_toolBox->blockSignals(blocked);
|
||||
m_toolBox->setEnabled(true);
|
||||
// Populate controls widget.
|
||||
ActionManager *am = Core::ICore::instance()->actionManager();
|
||||
QWidget *controlWidget = tool->createControlWidget(); // might be 0
|
||||
m_controlsWidget->addWidget(controlWidget
|
||||
? controlWidget : AnalyzerUtils::createDummyWidget());
|
||||
m_tools.append(tool);
|
||||
|
||||
const bool blocked = m_toolBox->blockSignals(true); // Do not make current.
|
||||
foreach (StartMode mode, modes) {
|
||||
QString actionName = tool->actionName(mode);
|
||||
QString menuGroup = tool->menuGroup(mode);
|
||||
QString actionId = tool->actionId(mode);
|
||||
QAction *action = new QAction(actionName, 0);
|
||||
action->setProperty("StartMode", int(mode));
|
||||
Core::Command *command = am->registerAction(action, actionId,
|
||||
Core::Context(Core::Constants::C_GLOBAL));
|
||||
m_menu->addAction(command, menuGroup);
|
||||
m_actions.append(action);
|
||||
m_toolFromAction[action] = tool;
|
||||
m_toolBox->addItem(actionName);
|
||||
m_toolBox->blockSignals(blocked);
|
||||
connect(action, SIGNAL(triggered()), SLOT(selectAction()));
|
||||
}
|
||||
m_toolBox->setEnabled(true);
|
||||
|
||||
m_tools.append(tool);
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::handleToolFinished(IAnalyzerTool *tool)
|
||||
void AnalyzerManagerPrivate::handleToolFinished(IAnalyzerTool *tool)
|
||||
{
|
||||
QTC_ASSERT(tool == m_currentTool, /**/);
|
||||
m_currentRunControl = 0;
|
||||
updateRunActions();
|
||||
|
||||
if (m_restartOnStop) {
|
||||
m_currentTool->startTool();
|
||||
m_currentTool->startTool(m_currentMode);
|
||||
m_restartOnStop = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::loadToolSettings(IAnalyzerTool *tool)
|
||||
void AnalyzerManagerPrivate::loadToolSettings(IAnalyzerTool *tool)
|
||||
{
|
||||
QTC_ASSERT(m_mainWindow, return);
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
@@ -780,7 +789,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::loadToolSettings(IAnalyzerTool *to
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::saveToolSettings(IAnalyzerTool *tool)
|
||||
void AnalyzerManagerPrivate::saveToolSettings(IAnalyzerTool *tool)
|
||||
{
|
||||
if (!tool)
|
||||
return; // no active tool, do nothing
|
||||
@@ -794,7 +803,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::saveToolSettings(IAnalyzerTool *to
|
||||
settings->setValue(QLatin1String(lastActiveToolC), tool->id());
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::updateRunActions()
|
||||
void AnalyzerManagerPrivate::updateRunActions()
|
||||
{
|
||||
ProjectExplorer::ProjectExplorerPlugin *pe =
|
||||
ProjectExplorer::ProjectExplorerPlugin::instance();
|
||||
@@ -846,15 +855,16 @@ void AnalyzerManager::extensionsInitialized()
|
||||
const QSettings *settings = Core::ICore::instance()->settings();
|
||||
const QString lastActiveToolId =
|
||||
settings->value(QLatin1String(lastActiveToolC), QString()).toString();
|
||||
IAnalyzerTool *lastTool = 0;
|
||||
|
||||
foreach (IAnalyzerTool *tool, d->m_tools) {
|
||||
foreach (IAnalyzerTool *tool, d->m_tools)
|
||||
tool->extensionsInitialized();
|
||||
if (tool->id() == lastActiveToolId)
|
||||
lastTool = tool;
|
||||
}
|
||||
|
||||
d->selectTool(lastTool);
|
||||
QAction *lastAction = 0;
|
||||
foreach (QAction *action, d->m_actions)
|
||||
if (d->m_toolFromAction[action]->id() == lastActiveToolId)
|
||||
lastAction = action;
|
||||
if (lastAction)
|
||||
d->selectAction(lastAction);
|
||||
}
|
||||
|
||||
void AnalyzerManager::shutdown()
|
||||
@@ -862,14 +872,9 @@ void AnalyzerManager::shutdown()
|
||||
d->saveToolSettings(d->m_currentTool);
|
||||
}
|
||||
|
||||
void AnalyzerManager::registerRunControlFactory(ProjectExplorer::IRunControlFactory *factory)
|
||||
void AnalyzerManager::addTool(IAnalyzerTool *tool, const StartModes &modes)
|
||||
{
|
||||
m_instance->d->registerRunControlFactory(factory);
|
||||
}
|
||||
|
||||
void AnalyzerManager::addTool(IAnalyzerTool *tool)
|
||||
{
|
||||
m_instance->d->addTool(tool);
|
||||
m_instance->d->addTool(tool, modes);
|
||||
}
|
||||
|
||||
QDockWidget *AnalyzerManager::createDockWidget(IAnalyzerTool *tool, const QString &title,
|
||||
@@ -886,15 +891,15 @@ QDockWidget *AnalyzerManager::createDockWidget(IAnalyzerTool *tool, const QStrin
|
||||
return dockWidget;
|
||||
}
|
||||
|
||||
void AnalyzerManager::selectTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManager::selectTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
m_instance->d->selectTool(tool);
|
||||
m_instance->d->selectTool(tool, mode);
|
||||
}
|
||||
|
||||
void AnalyzerManager::startTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManager::startTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
QTC_ASSERT(tool == m_instance->d->m_currentTool, return);
|
||||
m_instance->d->startTool();
|
||||
tool->startTool(mode);
|
||||
}
|
||||
|
||||
Utils::FancyMainWindow *AnalyzerManager::mainWindow()
|
||||
@@ -902,7 +907,7 @@ Utils::FancyMainWindow *AnalyzerManager::mainWindow()
|
||||
return m_instance->d->m_mainWindow;
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::resetLayout()
|
||||
void AnalyzerManagerPrivate::resetLayout()
|
||||
{
|
||||
m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentTool));
|
||||
}
|
||||
@@ -940,14 +945,14 @@ void AnalyzerManager::stopTool(IAnalyzerTool *tool)
|
||||
m_instance->stopTool(tool);
|
||||
}
|
||||
|
||||
void AnalyzerManager::startLocalTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManager::startLocalTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
m_instance->startLocalTool(tool);
|
||||
m_instance->startLocalTool(tool, mode);
|
||||
}
|
||||
|
||||
void AnalyzerManager::startRemoteTool(IAnalyzerTool *tool)
|
||||
void AnalyzerManager::startRemoteTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
m_instance->startRemoteTool(tool);
|
||||
m_instance->startRemoteTool(tool, mode);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunControl *AnalyzerManager::createRunControl
|
||||
@@ -970,4 +975,6 @@ IAnalyzerTool *AnalyzerManager::toolById(const QByteArray &id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Analyzer
|
||||
|
||||
#include "analyzermanager.moc"
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#define ANALYZERMANAGER_H
|
||||
|
||||
#include "analyzerbase_global.h"
|
||||
#include "analyzerconstants.h"
|
||||
#include "projectexplorer/runconfiguration.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
@@ -49,9 +50,11 @@ class FancyMainWindow;
|
||||
}
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
typedef QList<StartMode> StartModes;
|
||||
|
||||
class IAnalyzerTool;
|
||||
class IAnalyzerEngine;
|
||||
class AnalyzerStartParameters;
|
||||
class AnalyzerManagerPrivate;
|
||||
|
||||
class ANALYZER_EXPORT AnalyzerManager : public QObject
|
||||
{
|
||||
@@ -61,7 +64,6 @@ public:
|
||||
explicit AnalyzerManager(QObject *parent = 0);
|
||||
~AnalyzerManager();
|
||||
|
||||
static void registerRunControlFactory(ProjectExplorer::IRunControlFactory *factory);
|
||||
void extensionsInitialized();
|
||||
void shutdown();
|
||||
|
||||
@@ -69,7 +71,7 @@ public:
|
||||
(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode);
|
||||
|
||||
// Register a tool and initialize it.
|
||||
static void addTool(Analyzer::IAnalyzerTool *tool);
|
||||
static void addTool(Analyzer::IAnalyzerTool *tool, const StartModes &mode);
|
||||
static IAnalyzerTool *toolById(const QByteArray &id);
|
||||
|
||||
// Dockwidgets are registered to the main window.
|
||||
@@ -79,13 +81,13 @@ public:
|
||||
static Utils::FancyMainWindow *mainWindow();
|
||||
|
||||
static void showMode();
|
||||
static void selectTool(IAnalyzerTool *tool);
|
||||
static void startTool(IAnalyzerTool *tool);
|
||||
static void selectTool(IAnalyzerTool *tool, StartMode mode);
|
||||
static void startTool(IAnalyzerTool *tool, StartMode mode);
|
||||
static void stopTool(IAnalyzerTool *tool);
|
||||
|
||||
// Convienience functions.
|
||||
static void startLocalTool(IAnalyzerTool *tool);
|
||||
static void startRemoteTool(IAnalyzerTool *tool);
|
||||
static void startLocalTool(IAnalyzerTool *tool, StartMode mode);
|
||||
static void startRemoteTool(IAnalyzerTool *tool, StartMode mode);
|
||||
|
||||
static QString msgToolStarted(const QString &name);
|
||||
static QString msgToolFinished(const QString &name, int issuesFound);
|
||||
@@ -96,7 +98,6 @@ public:
|
||||
static void handleToolFinished(IAnalyzerTool *tool);
|
||||
|
||||
private:
|
||||
class AnalyzerManagerPrivate;
|
||||
friend class AnalyzerManagerPrivate;
|
||||
AnalyzerManagerPrivate *const d;
|
||||
};
|
||||
|
@@ -50,11 +50,10 @@ class ANALYZER_EXPORT AnalyzerStartParameters
|
||||
{
|
||||
public:
|
||||
AnalyzerStartParameters()
|
||||
: startMode(StartLocal)
|
||||
, connParams(Utils::SshConnectionParameters::NoProxy)
|
||||
{ }
|
||||
: connParams(Utils::SshConnectionParameters::NoProxy)
|
||||
{}
|
||||
|
||||
AnalyzerStartMode startMode;
|
||||
StartMode startMode;
|
||||
Utils::SshConnectionParameters connParams;
|
||||
|
||||
QByteArray toolId;
|
||||
|
@@ -33,6 +33,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "ianalyzertool.h"
|
||||
#include "analyzermanager.h"
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
@@ -53,6 +54,35 @@ QString IAnalyzerTool::modeString(ToolMode mode)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QByteArray IAnalyzerTool::defaultMenuGroup(StartMode mode)
|
||||
{
|
||||
if (mode == StartRemote)
|
||||
return Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS;
|
||||
return Analyzer::Constants::G_ANALYZER_TOOLS;
|
||||
}
|
||||
|
||||
QByteArray IAnalyzerTool::defaultActionId(const QByteArray &id, StartMode mode)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (mode == StartRemote)
|
||||
return base + tr(" (Remote)");
|
||||
return base;
|
||||
}
|
||||
|
||||
void IAnalyzerTool::defaultStartTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
if (mode == StartLocal)
|
||||
AnalyzerManager::startLocalTool(tool, mode);
|
||||
if (mode == StartRemote)
|
||||
AnalyzerManager::startRemoteTool(tool, mode);
|
||||
}
|
||||
|
||||
void IAnalyzerTool::initializeDockWidgets()
|
||||
{
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#define IANALYZERTOOL_H
|
||||
|
||||
#include "analyzerbase_global.h"
|
||||
#include "analyzerconstants.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
@@ -49,8 +50,12 @@ class AnalyzerStartParameters;
|
||||
class IAnalyzerOutputPaneAdapter;
|
||||
class IAnalyzerEngine;
|
||||
|
||||
|
||||
/**
|
||||
* This class represents an analyzation tool, e.g. "Valgrind Memcheck".
|
||||
*
|
||||
* Each tool can run in different run modes. The modes are specific to the mode.
|
||||
*
|
||||
* @code
|
||||
* bool YourPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
* {
|
||||
@@ -72,13 +77,18 @@ public:
|
||||
virtual QString displayName() const = 0;
|
||||
/// Returns a user readable description name for this tool.
|
||||
virtual QString description() const = 0;
|
||||
/// Returns the name of the menu group of the start action.
|
||||
virtual QByteArray menuGroup() const = 0;
|
||||
/// Returns an id for the start action.
|
||||
virtual QByteArray actionId(StartMode m) const { return defaultActionId(id(), m); }
|
||||
/// Returns the menu group the start action should go to.
|
||||
virtual QByteArray menuGroup(StartMode m) const { return defaultMenuGroup(m); }
|
||||
/// Returns a short user readable action name for this tool.
|
||||
virtual QString actionName(StartMode m) const
|
||||
{ return defaultActionName(displayName(), m); }
|
||||
|
||||
/**
|
||||
* The mode in which this tool should preferably be run
|
||||
*
|
||||
* The memcheckt tool, for example, requires debug symbols, hence DebugMode
|
||||
* The memcheck tool, for example, requires debug symbols, hence DebugMode
|
||||
* is preferred. On the other hand, callgrind should look at optimized code,
|
||||
* hence ReleaseMode.
|
||||
*/
|
||||
@@ -91,6 +101,12 @@ public:
|
||||
|
||||
static QString modeString(ToolMode mode);
|
||||
|
||||
/// Convenience implementation.
|
||||
static QByteArray defaultMenuGroup(StartMode m);
|
||||
static QByteArray defaultActionId(const QByteArray &id, StartMode m);
|
||||
static QString defaultActionName(const QString &base, StartMode m);
|
||||
static void defaultStartTool(IAnalyzerTool *tool, StartMode mode);
|
||||
|
||||
/// This gets called after all analyzation tools where initialized.
|
||||
virtual void extensionsInitialized() = 0;
|
||||
|
||||
@@ -109,8 +125,8 @@ public:
|
||||
virtual IAnalyzerEngine *createEngine(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0) = 0;
|
||||
|
||||
/// Starts the tool.
|
||||
virtual void startTool() = 0;
|
||||
virtual void startTool(StartMode m)
|
||||
{ return defaultStartTool(this, m); }
|
||||
|
||||
/// Called when tools gets selected.
|
||||
virtual void toolSelected() const {}
|
||||
|
@@ -45,16 +45,15 @@ using namespace QmlProfiler::Internal;
|
||||
|
||||
bool QmlProfilerPlugin::debugOutput = false;
|
||||
|
||||
QmlProfilerPlugin::QmlProfilerPlugin()
|
||||
{}
|
||||
|
||||
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
addAutoReleasedObject(new QmlProjectAnalyzerRunControlFactory());
|
||||
AnalyzerManager::addTool(new QmlProfilerTool(true, this));
|
||||
AnalyzerManager::addTool(new QmlProfilerTool(false, this));
|
||||
StartModes modes;
|
||||
modes.append(StartMode(StartLocal));
|
||||
modes.append(StartMode(StartRemote));
|
||||
AnalyzerManager::addTool(new QmlProfilerTool(this), modes);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -92,7 +92,6 @@ public:
|
||||
|
||||
QmlProfilerTool *q;
|
||||
|
||||
bool m_local;
|
||||
QDeclarativeDebugConnection *m_client;
|
||||
QTimer m_connectionTimer;
|
||||
int m_connectionAttempts;
|
||||
@@ -119,10 +118,9 @@ public:
|
||||
QString m_ostDevice;
|
||||
};
|
||||
|
||||
QmlProfilerTool::QmlProfilerTool(bool local, QObject *parent)
|
||||
QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
|
||||
{
|
||||
d->m_local = local;
|
||||
d->m_client = 0;
|
||||
d->m_connectionAttempts = 0;
|
||||
d->m_traceWindow = 0;
|
||||
@@ -151,24 +149,12 @@ QmlProfilerTool::~QmlProfilerTool()
|
||||
|
||||
QByteArray QmlProfilerTool::id() const
|
||||
{
|
||||
return d->m_local ? "QmlLocalProfiler" : "QmlRemoteProfiler";
|
||||
return "QmlProfiler";
|
||||
}
|
||||
|
||||
QString QmlProfilerTool::displayName() const
|
||||
{
|
||||
return d->m_local ? tr("QML Profiler") : tr("QML Profiler (Remote)");
|
||||
}
|
||||
|
||||
QByteArray QmlProfilerTool::menuGroup() const
|
||||
{
|
||||
return d->m_local ? Analyzer::Constants::G_ANALYZER_TOOLS
|
||||
: Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS;
|
||||
}
|
||||
|
||||
void QmlProfilerTool::startTool()
|
||||
{
|
||||
return d->m_local ? AnalyzerManager::startLocalTool(this)
|
||||
: AnalyzerManager::startRemoteTool(this);
|
||||
return tr("QML Profiler");
|
||||
}
|
||||
|
||||
QString QmlProfilerTool::description() const
|
||||
|
@@ -45,12 +45,11 @@ class QmlProfilerTool : public Analyzer::IAnalyzerTool
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlProfilerTool(bool local, QObject *parent);
|
||||
explicit QmlProfilerTool(QObject *parent);
|
||||
~QmlProfilerTool();
|
||||
|
||||
QByteArray id() const;
|
||||
QString displayName() const;
|
||||
QByteArray menuGroup() const;
|
||||
QString description() const;
|
||||
ToolMode mode() const;
|
||||
|
||||
@@ -58,7 +57,6 @@ public:
|
||||
void initializeDockWidgets();
|
||||
void toolSelected();
|
||||
void toolDeselected();
|
||||
void startTool();
|
||||
|
||||
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0);
|
||||
|
@@ -175,7 +175,6 @@ public slots:
|
||||
public:
|
||||
CallgrindTool *q;
|
||||
|
||||
bool m_local;
|
||||
DataModel *m_dataModel;
|
||||
DataProxyModel *m_proxyModel;
|
||||
StackBrowser *m_stackBrowser;
|
||||
@@ -218,7 +217,6 @@ public:
|
||||
|
||||
CallgrindToolPrivate::CallgrindToolPrivate(CallgrindTool *parent)
|
||||
: q(parent)
|
||||
, m_local(true)
|
||||
, m_dataModel(new DataModel(this))
|
||||
, m_proxyModel(new DataProxyModel(this))
|
||||
, m_stackBrowser(new StackBrowser(this))
|
||||
@@ -499,11 +497,10 @@ static QToolButton *createToolButton(QAction *action)
|
||||
return button;
|
||||
}
|
||||
|
||||
CallgrindTool::CallgrindTool(bool local, QObject *parent)
|
||||
CallgrindTool::CallgrindTool(QObject *parent)
|
||||
: Analyzer::IAnalyzerTool(parent)
|
||||
{
|
||||
d = new CallgrindToolPrivate(this);
|
||||
d->m_local = local;
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
|
||||
// EditorManager
|
||||
@@ -519,19 +516,12 @@ CallgrindTool::~CallgrindTool()
|
||||
|
||||
QByteArray CallgrindTool::id() const
|
||||
{
|
||||
return d->m_local ? "CallgrindLocal" : "CallgrindRemote";
|
||||
return "Callgrind";
|
||||
}
|
||||
|
||||
QString CallgrindTool::displayName() const
|
||||
{
|
||||
return d->m_local ? tr("Valgrind Function Profile")
|
||||
: tr("Valgrind Function Profile (Remote)");
|
||||
}
|
||||
|
||||
QByteArray CallgrindTool::menuGroup() const
|
||||
{
|
||||
return d->m_local ? Analyzer::Constants::G_ANALYZER_TOOLS
|
||||
: Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS;
|
||||
return tr("Valgrind Function Profile");
|
||||
}
|
||||
|
||||
QString CallgrindTool::description() const
|
||||
@@ -540,14 +530,6 @@ QString CallgrindTool::description() const
|
||||
"record function calls when a program runs.");
|
||||
}
|
||||
|
||||
void CallgrindTool::startTool()
|
||||
{
|
||||
if (d->m_local)
|
||||
AnalyzerManager::startLocalTool(this);
|
||||
else
|
||||
AnalyzerManager::startRemoteTool(this);
|
||||
}
|
||||
|
||||
IAnalyzerTool::ToolMode CallgrindTool::mode() const
|
||||
{
|
||||
return ReleaseMode;
|
||||
@@ -947,8 +929,8 @@ void CallgrindToolPrivate::handleShowCostsOfFunction()
|
||||
|
||||
m_toggleCollectFunction = QString("%1()").arg(qualifiedFunctionName);
|
||||
|
||||
AnalyzerManager::selectTool(q);
|
||||
AnalyzerManager::startTool(q);
|
||||
AnalyzerManager::selectTool(q, StartMode(StartLocal));
|
||||
AnalyzerManager::startTool(q, StartMode(StartLocal));
|
||||
}
|
||||
|
||||
void CallgrindToolPrivate::slotRequestDump()
|
||||
|
@@ -45,16 +45,14 @@ class CallgrindTool : public Analyzer::IAnalyzerTool
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CallgrindTool(bool local, QObject *parent);
|
||||
CallgrindTool(QObject *parent);
|
||||
~CallgrindTool();
|
||||
|
||||
QByteArray id() const;
|
||||
QString displayName() const;
|
||||
QByteArray menuGroup() const;
|
||||
QString description() const;
|
||||
ToolMode mode() const;
|
||||
|
||||
void startTool();
|
||||
void extensionsInitialized();
|
||||
void initializeDockWidgets();
|
||||
|
||||
|
@@ -184,10 +184,9 @@ static void initKindFilterAction(QAction *action, const QList<int> &kinds)
|
||||
action->setData(data);
|
||||
}
|
||||
|
||||
MemcheckTool::MemcheckTool(bool local, QObject *parent)
|
||||
MemcheckTool::MemcheckTool(QObject *parent)
|
||||
: Analyzer::IAnalyzerTool(parent)
|
||||
{
|
||||
m_local = local;
|
||||
m_settings = 0;
|
||||
m_errorModel = 0;
|
||||
m_errorProxyModel = 0;
|
||||
@@ -295,13 +294,7 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
|
||||
|
||||
QByteArray MemcheckTool::id() const
|
||||
{
|
||||
return m_local ? "MemcheckLocal" : "MemcheckGlobal";
|
||||
}
|
||||
|
||||
QByteArray MemcheckTool::menuGroup() const
|
||||
{
|
||||
return m_local ? Analyzer::Constants::G_ANALYZER_TOOLS
|
||||
: Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS;
|
||||
return "MemcheckLocal";
|
||||
}
|
||||
|
||||
QString MemcheckTool::displayName() const
|
||||
@@ -320,14 +313,6 @@ IAnalyzerTool::ToolMode MemcheckTool::mode() const
|
||||
return DebugMode;
|
||||
}
|
||||
|
||||
void MemcheckTool::startTool()
|
||||
{
|
||||
if (m_local)
|
||||
AnalyzerManager::startLocalTool(this);
|
||||
else
|
||||
AnalyzerManager::startRemoteTool(this);
|
||||
}
|
||||
|
||||
class FrameFinder : public ErrorListModel::RelevantFrameFinder
|
||||
{
|
||||
public:
|
||||
|
@@ -91,13 +91,11 @@ class MemcheckTool : public Analyzer::IAnalyzerTool
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MemcheckTool(bool local, QObject *parent);
|
||||
MemcheckTool(QObject *parent);
|
||||
|
||||
QByteArray id() const;
|
||||
QString displayName() const;
|
||||
QString description() const;
|
||||
QByteArray menuGroup() const;
|
||||
void startTool();
|
||||
|
||||
private slots:
|
||||
void settingsDestroyed(QObject *settings);
|
||||
|
@@ -80,14 +80,14 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
AnalyzerGlobalSettings::instance()->registerSubConfigs(&globalCallgrindFactory, &projectCallgrindFactory);
|
||||
AnalyzerGlobalSettings::instance()->registerSubConfigs(&globalMemcheckFactory, &projectMemcheckFactory);
|
||||
|
||||
StartModes modes;
|
||||
#ifndef Q_OS_WIN
|
||||
AnalyzerManager::addTool(new MemcheckTool(true, this));
|
||||
modes.append(StartMode(StartLocal));
|
||||
#endif
|
||||
AnalyzerManager::addTool(new MemcheckTool(false, this));
|
||||
#ifndef Q_OS_WIN
|
||||
AnalyzerManager::addTool(new CallgrindTool(true, this));
|
||||
#endif
|
||||
AnalyzerManager::addTool(new CallgrindTool(false, this));
|
||||
modes.append(StartMode(StartRemote));
|
||||
|
||||
AnalyzerManager::addTool(new MemcheckTool(this), modes);
|
||||
AnalyzerManager::addTool(new CallgrindTool(this), modes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user