Analyzer: Reduce explicit use of StartMode enum

Change-Id: I27b1d06395dea940c8dd39cd2bd41fc09cee3a9c
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-18 18:51:29 +01:00
parent 1eb36bb1d3
commit 813e995ebf
11 changed files with 78 additions and 62 deletions

View File

@@ -53,7 +53,6 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
Q_UNUSED(errorString)
auto tool = new QmlProfilerTool(this);
auto toolStarter = [tool](StartMode mode) { return tool->startTool(mode); };
auto widgetCreator = [tool] { return tool->createWidgets(); };
auto runControlCreator = [tool](const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) {
@@ -71,7 +70,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
action->setToolId(QmlProfilerToolId);
action->setWidgetCreator(widgetCreator);
action->setRunControlCreator(runControlCreator);
action->setToolStarter(toolStarter);
action->setToolStarter([tool] { tool->startLocalTool(); });
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
action->setText(tr("QML Profiler"));
action->setToolTip(description);
@@ -84,7 +83,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
action->setToolId(QmlProfilerToolId);
action->setWidgetCreator(widgetCreator);
action->setRunControlCreator(runControlCreator);
action->setToolStarter(toolStarter);
action->setToolStarter([tool] { tool->startRemoteTool(); });
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
action->setText(tr("QML Profiler (External)"));
action->setToolTip(description);

View File

@@ -486,8 +486,32 @@ void QmlProfilerTool::clearDisplay()
updateTimeDisplay();
}
static void startRemoteTool(QmlProfilerTool *tool, StartMode mode)
void QmlProfilerTool::startLocalTool()
{
if (d->m_recordButton->isChecked()) {
if (!checkForUnsavedNotes())
return;
clearData(); // clear right away to suppress second warning on server recording change
}
// Make sure mode is shown.
AnalyzerManager::showMode();
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
Project *pro = SessionManager::startupProject();
ProjectExplorerPlugin::runProject(pro, QmlProfilerRunMode);
}
void QmlProfilerTool::startRemoteTool()
{
if (d->m_recordButton->isChecked()) {
if (!checkForUnsavedNotes())
return;
clearData(); // clear right away to suppress second warning on server recording change
}
AnalyzerManager::showMode();
Id kitId;
quint16 port;
Kit *kit = 0;
@@ -514,7 +538,7 @@ static void startRemoteTool(QmlProfilerTool *tool, StartMode mode)
}
AnalyzerStartParameters sp;
sp.startMode = mode;
sp.startMode = StartRemote;
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
if (device) {
@@ -524,32 +548,10 @@ static void startRemoteTool(QmlProfilerTool *tool, StartMode mode)
sp.sysroot = SysRootKitInformation::sysRoot(kit).toString();
sp.analyzerPort = port;
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
AnalyzerRunControl *rc = createRunControl(sp, 0);
ProjectExplorerPlugin::startRunControl(rc, QmlProfilerRunMode);
}
void QmlProfilerTool::startTool(StartMode mode)
{
if (d->m_recordButton->isChecked()) {
if (!checkForUnsavedNotes())
return;
else
clearData(); // clear right away to suppress second warning on server recording change
}
// Make sure mode is shown.
AnalyzerManager::showMode();
if (mode == StartLocal) {
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
Project *pro = SessionManager::startupProject();
ProjectExplorerPlugin::instance()->runProject(pro, QmlProfilerRunMode);
} else if (mode == StartRemote) {
Internal::startRemoteTool(this, mode);
}
}
void QmlProfilerTool::logState(const QString &msg)
{
MessageManager::write(msg, MessageManager::Flash);

View File

@@ -58,7 +58,8 @@ public:
ProjectExplorer::RunConfiguration *runConfiguration = 0);
QWidget *createWidgets();
void startTool(Analyzer::StartMode mode);
void startLocalTool();
void startRemoteTool();
QList <QAction *> profilerContextMenuActions() const;