OSDN Git Service

display: simplify AnalyzerStartParameters
authorhjk <qtc-committer@nokia.com>
Wed, 6 Jul 2011 07:54:50 +0000 (09:54 +0200)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>
Wed, 6 Jul 2011 10:01:18 +0000 (12:01 +0200)
Change-Id: Ibc9db3d7de96461b097d1a78e1bcfd757458fc99
Reviewed-on: http://codereview.qt.nokia.com/1205
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/plugins/analyzerbase/analyzerstartparameters.h
src/plugins/qmlprofiler/qmlprofilertool.cpp
src/plugins/valgrind/valgrindplugin.cpp

index c05b14c..5265e70 100644 (file)
@@ -60,9 +60,6 @@ public:
     QString debuggee;
     QString debuggeeArgs;
     QString analyzerCmdPrefix;
-    QString remoteMountPoint;
-    QString localMountDir;
-    QString remoteSourcesDir;
     QString displayName;
     Utils::Environment environment;
     QString workingDirectory;
index 6cc159c..2623b11 100644 (file)
@@ -547,6 +547,8 @@ void QmlProfilerTool::updateRecordingState()
 
 void QmlProfilerTool::startTool(StartMode mode)
 {
+    Q_UNUSED(mode);
+
     using namespace ProjectExplorer;
 
     // Make sure mode is shown.
index c5ec6cf..86ac42e 100644 (file)
@@ -74,59 +74,20 @@ using namespace ProjectExplorer;
 namespace Valgrind {
 namespace Internal {
 
-static AnalyzerStartParameters localStartParameters(RunConfiguration *runConfiguration)
-{
-    AnalyzerStartParameters sp;
-    QTC_ASSERT(runConfiguration, return sp);
-    LocalApplicationRunConfiguration *rc =
-            qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
-    QTC_ASSERT(rc, return sp);
-
-    sp.startMode = StartLocal;
-    sp.environment = rc->environment();
-    sp.workingDirectory = rc->workingDirectory();
-    sp.debuggee = rc->executable();
-    sp.debuggeeArgs = rc->commandLineArguments();
-    sp.displayName = rc->displayName();
-    sp.connParams.host = QLatin1String("localhost");
-    sp.connParams.port = rc->qmlDebugServerPort();
-    return sp;
-}
-
-static AnalyzerStartParameters remoteLinuxStartParameters(RunConfiguration *runConfiguration)
-{
-    AnalyzerStartParameters sp;
-    RemoteLinux::RemoteLinuxRunConfiguration * const rc
-        = 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.displayName = rc->displayName();
-    return sp;
-}
-
-
-class ValgrindRunControlFactory: public ProjectExplorer::IRunControlFactory
+class ValgrindRunControlFactory : public ProjectExplorer::IRunControlFactory
 {
     Q_OBJECT
 
 public:
     ValgrindRunControlFactory(QObject *parent = 0);
 
-    typedef ProjectExplorer::RunConfiguration RunConfiguration;
-    typedef ProjectExplorer::RunControl RunControl;
-
     // IRunControlFactory
     bool canRun(RunConfiguration *runConfiguration, const QString &mode) const;
     RunControl *create(RunConfiguration *runConfiguration, const QString &mode);
     QString displayName() const;
 
-    ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect();
-    ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
+    IRunConfigurationAspect *createRunConfigurationAspect();
+    RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
 };
 
 ValgrindRunControlFactory::ValgrindRunControlFactory(QObject *parent)
@@ -146,10 +107,24 @@ RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration
     QTC_ASSERT(canRun(runConfiguration, mode), return 0);
 
     AnalyzerStartParameters sp;
-    if (qobject_cast<ProjectExplorer::LocalApplicationRunConfiguration *>(runConfiguration)) {
-        sp = localStartParameters(runConfiguration);
-    } else if (qobject_cast<RemoteLinux::RemoteLinuxRunConfiguration *>(runConfiguration)) {
-        sp = remoteLinuxStartParameters(runConfiguration);
+    if (LocalApplicationRunConfiguration *rc1 =
+            qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
+        sp.startMode = StartLocal;
+        sp.environment = rc1->environment();
+        sp.workingDirectory = rc1->workingDirectory();
+        sp.debuggee = rc1->executable();
+        sp.debuggeeArgs = rc1->commandLineArguments();
+        sp.displayName = rc1->displayName();
+        sp.connParams.host = QLatin1String("localhost");
+        sp.connParams.port = rc1->qmlDebugServerPort();
+    } else if (RemoteLinux::RemoteLinuxRunConfiguration *rc2 =
+               qobject_cast<RemoteLinux::RemoteLinuxRunConfiguration *>(runConfiguration)) {
+        sp.startMode = StartRemote;
+        sp.debuggee = rc2->remoteExecutableFilePath();
+        sp.debuggeeArgs = rc2->arguments();
+        sp.connParams = rc2->deviceConfig()->sshParameters();
+        sp.analyzerCmdPrefix = rc2->commandPrefix();
+        sp.displayName = rc2->displayName();
     } else {
         // Might be S60DeviceRunfiguration, or something else ...
         //sp.startMode = StartRemote;
@@ -159,7 +134,6 @@ RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration
     IAnalyzerTool *tool = AnalyzerManager::toolFromId(mode.toLatin1());
     AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration);
     QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
-    //m_isRunning = true;
     return rc;
 }
 
@@ -214,7 +188,7 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
     //m_currentRunControl = rc;
     QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
 
-    ProjectExplorer::ProjectExplorerPlugin::instance()->startRunControl(rc, tool->id());
+    ProjectExplorerPlugin::instance()->startRunControl(rc, tool->id());
 }
 
 void ValgrindPlugin::startValgrindTool(IAnalyzerTool *tool, StartMode mode)