Commit a89158b8 authored by hjk's avatar hjk Committed by hjk
Browse files

analyzer: handle all possibilities to start qml profiler in QmlProfilerTool

Change-Id: I286bdc4dc3fbab2e784e72f47ff02644cc2899e5
Reviewed-on: http://codereview.qt.nokia.com/1096

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 5418a137
......@@ -450,7 +450,6 @@ void AnalyzerManagerPrivate::startLocalTool(IAnalyzerTool *tool, StartMode mode)
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.
q->showMode();
......@@ -587,6 +586,7 @@ void AnalyzerManagerPrivate::selectAction(int index)
void AnalyzerManagerPrivate::selectAction(QAction *action)
{
AnalyzerManager::showMode();
selectTool(m_toolFromAction[action], m_modeFromAction[action]);
}
......
......@@ -51,8 +51,9 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
Q_UNUSED(errorString)
addAutoReleasedObject(new QmlProjectAnalyzerRunControlFactory());
StartModes modes;
// They are handled the same actually.
//modes.append(StartMode(StartRemote));
modes.append(StartMode(StartLocal));
modes.append(StartMode(StartRemote));
AnalyzerManager::addTool(new QmlProfilerTool(this), modes);
return true;
}
......
......@@ -540,8 +540,13 @@ void QmlProfilerTool::updateRecordingState()
void QmlProfilerTool::startTool(StartMode mode)
{
if (mode == StartLocal)
AnalyzerManager::startLocalTool(this, mode);
if (mode == StartRemote)
AnalyzerManager::startLocalTool(this, mode);
using namespace ProjectExplorer;
// Make sure mode is shown.
AnalyzerManager::showMode();
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
Project *pro = pe->startupProject();
pe->runProject(pro, id());
}
......@@ -39,31 +39,20 @@
#include <analyzerbase/analyzersettings.h>
#include <analyzerbase/analyzerrunconfigwidget.h>
#include <projectexplorer/applicationrunconfiguration.h>
#include <projectexplorer/projectexplorer.h>
#include <remotelinux/linuxdeviceconfiguration.h>
#include <remotelinux/remotelinuxrunconfiguration.h>
#include <utils/qtcassert.h>
#include <QtGui/QAction>
using namespace Analyzer;
using namespace ProjectExplorer;
using namespace QmlProfiler::Internal;
static AnalyzerStartParameters localStartParameters(ProjectExplorer::RunConfiguration *runConfiguration)
{
AnalyzerStartParameters sp;
QTC_ASSERT(runConfiguration, return sp);
QmlProjectManager::QmlProjectRunConfiguration *rc =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
QTC_ASSERT(rc, return sp);
sp.toolId = "QmlProfiler";
sp.startMode = StartLocal;
sp.environment = rc->environment();
sp.workingDirectory = rc->workingDirectory();
sp.debuggee = rc->observerPath();
sp.debuggeeArgs = rc->viewerArguments();
sp.displayName = rc->displayName();
sp.connParams.host = QLatin1String("localhost");
sp.connParams.port = rc->qmlDebugServerPort();
return sp;
}
using namespace QmlProjectManager;
QmlProjectAnalyzerRunControlFactory::QmlProjectAnalyzerRunControlFactory(QObject *parent)
: IRunControlFactory(parent)
......@@ -73,21 +62,61 @@ QmlProjectAnalyzerRunControlFactory::QmlProjectAnalyzerRunControlFactory(QObject
bool QmlProjectAnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
{
return mode.startsWith(QLatin1String("QmlProfiler"))
&& qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
if (qobject_cast<QmlProjectRunConfiguration *>(runConfiguration))
return mode == QLatin1String("QmlProfiler");
if (qobject_cast<RemoteLinux::RemoteLinuxRunConfiguration *>(runConfiguration))
return mode == QLatin1String("QmlProfiler");
if (qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration))
return mode == QLatin1String("QmlProfiler");
return false;
}
RunControl *QmlProjectAnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode)
{
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
const AnalyzerStartParameters sp = localStartParameters(runConfiguration);
return create(sp, runConfiguration);
}
AnalyzerRunControl *QmlProjectAnalyzerRunControlFactory::create
(const Analyzer::AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
{
return new AnalyzerRunControl(AnalyzerManager::toolFromId(sp.toolId), sp, runConfiguration);
AnalyzerStartParameters sp;
sp.toolId = "QmlProfiler";
if (QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectRunConfiguration *>(runConfiguration)) {
// This is a "plain" .qmlproject.
sp.startMode = StartLocal;
sp.environment = rc1->environment();
sp.workingDirectory = rc1->workingDirectory();
sp.debuggee = rc1->observerPath();
sp.debuggeeArgs = rc1->viewerArguments();
sp.displayName = rc1->displayName();
sp.connParams.host = QLatin1String("localhost");
sp.connParams.port = rc1->qmlDebugServerPort();
} else if (LocalApplicationRunConfiguration *rc2 =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
sp.startMode = StartLocal;
sp.environment = rc2->environment();
sp.workingDirectory = rc2->workingDirectory();
sp.debuggee = rc2->executable();
sp.debuggeeArgs = rc2->commandLineArguments();
sp.displayName = rc2->displayName();
sp.connParams.host = QLatin1String("localhost");
sp.connParams.port = rc2->qmlDebugServerPort();
} else if (RemoteLinux::RemoteLinuxRunConfiguration *rc3 =
qobject_cast<RemoteLinux::RemoteLinuxRunConfiguration *>(runConfiguration)) {
sp.startMode = StartRemote;
sp.debuggee = rc3->remoteExecutableFilePath();
sp.debuggeeArgs = rc3->arguments();
sp.connParams = rc3->deviceConfig()->sshParameters();
sp.analyzerCmdPrefix = rc3->commandPrefix();
sp.displayName = rc3->displayName();
} else {
// Might be S60DeviceRunfiguration, or something else ... ?
//sp.startMode = StartRemote;
QTC_ASSERT(false, return 0);
}
IAnalyzerTool *tool = AnalyzerManager::toolFromId(mode.toLatin1());
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration);
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
return rc;
}
QString QmlProjectAnalyzerRunControlFactory::displayName() const
......
......@@ -54,10 +54,6 @@ public:
QString displayName() const;
bool canRun(RunConfiguration *runConfiguration, const QString &mode) const;
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, const QString &mode);
// FIXME: Remove function.
Analyzer::AnalyzerRunControl *create(const Analyzer::AnalyzerStartParameters &sp, RunConfiguration *runConfiguration);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect();
ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
......
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