From 4a8432112aacfb5ee25b5514c35d16e657eb2c8d Mon Sep 17 00:00:00 2001 From: Nicolas Arnaud-Cormos Date: Tue, 27 Dec 2011 22:41:31 +0100 Subject: Analyzer: create a run control factory for all tools. Having one factory per tool (or plugin) created some bugs: * analyzer project settings being created twice * per-project analyzer settings widget duplicated Also, most of the code from the run control factory were copied. Now, the Analyzer only creates one run control factory shared among all tools, and the IAnalyzerTool has two new virtual method: canRun and createStartParameters. It simplify the code a bit, and creating a new analyzer tool is easier (only two classes to subclass: IAnalyzerTool and IAnalyzerEngine). Change-Id: I4e180846a26b74b2b77cb99bc97534d680a80a4d Reviewed-by: hjk --- src/plugins/analyzerbase/analyzerbase.pro | 6 +- src/plugins/analyzerbase/analyzermanager.cpp | 1 - src/plugins/analyzerbase/analyzerplugin.cpp | 3 + .../analyzerbase/analyzerrunconfigwidget.cpp | 62 ++++---- src/plugins/analyzerbase/analyzerrunconfigwidget.h | 21 ++- .../analyzerbase/analyzerruncontrolfactory.cpp | 104 ++++++++++++++ .../analyzerbase/analyzerruncontrolfactory.h | 62 ++++++++ src/plugins/analyzerbase/ianalyzertool.h | 11 +- src/plugins/qmlprofiler/qmlprofiler.pro | 6 +- src/plugins/qmlprofiler/qmlprofilerplugin.cpp | 4 +- .../qmlprofiler/qmlprofilerruncontrolfactory.cpp | 160 --------------------- .../qmlprofiler/qmlprofilerruncontrolfactory.h | 65 --------- src/plugins/qmlprofiler/qmlprofilertool.cpp | 70 +++++++++ src/plugins/qmlprofiler/qmlprofilertool.h | 7 + src/plugins/valgrind/callgrindtool.cpp | 2 +- src/plugins/valgrind/callgrindtool.h | 4 +- src/plugins/valgrind/memchecktool.cpp | 2 +- src/plugins/valgrind/memchecktool.h | 4 +- src/plugins/valgrind/valgrind.pro | 6 +- src/plugins/valgrind/valgrindplugin.cpp | 105 -------------- src/plugins/valgrind/valgrindtool.cpp | 91 ++++++++++++ src/plugins/valgrind/valgrindtool.h | 58 ++++++++ 22 files changed, 476 insertions(+), 378 deletions(-) create mode 100644 src/plugins/analyzerbase/analyzerruncontrolfactory.cpp create mode 100644 src/plugins/analyzerbase/analyzerruncontrolfactory.h delete mode 100644 src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp delete mode 100644 src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h create mode 100644 src/plugins/valgrind/valgrindtool.cpp create mode 100644 src/plugins/valgrind/valgrindtool.h diff --git a/src/plugins/analyzerbase/analyzerbase.pro b/src/plugins/analyzerbase/analyzerbase.pro index e42ee34fa8..e735e82d01 100644 --- a/src/plugins/analyzerbase/analyzerbase.pro +++ b/src/plugins/analyzerbase/analyzerbase.pro @@ -20,7 +20,8 @@ SOURCES += \ analyzeroptionspage.cpp \ analyzerrunconfigwidget.cpp \ analyzerutils.cpp \ - startremotedialog.cpp + startremotedialog.cpp \ + analyzerruncontrolfactory.cpp HEADERS += \ ianalyzerengine.h \ @@ -35,7 +36,8 @@ HEADERS += \ analyzeroptionspage.h \ analyzerrunconfigwidget.h \ analyzerutils.h \ - startremotedialog.h + startremotedialog.h \ + analyzerruncontrolfactory.h FORMS += \ startremotedialog.ui diff --git a/src/plugins/analyzerbase/analyzermanager.cpp b/src/plugins/analyzerbase/analyzermanager.cpp index cb24fb0008..e57110177d 100644 --- a/src/plugins/analyzerbase/analyzermanager.cpp +++ b/src/plugins/analyzerbase/analyzermanager.cpp @@ -908,7 +908,6 @@ IAnalyzerTool *AnalyzerManager::toolFromId(const Core::Id &id) foreach (IAnalyzerTool *tool, m_instance->d->m_tools) if (id.name().startsWith(tool->id().name())) return tool; - QTC_ASSERT(false, qDebug() << "NO ANAYLYZER TOOL FOUND FOR ID" << id.name()); return 0; } diff --git a/src/plugins/analyzerbase/analyzerplugin.cpp b/src/plugins/analyzerbase/analyzerplugin.cpp index c9a8b8237f..b9fab35a2f 100644 --- a/src/plugins/analyzerbase/analyzerplugin.cpp +++ b/src/plugins/analyzerbase/analyzerplugin.cpp @@ -36,6 +36,7 @@ #include "analyzerconstants.h" #include "analyzermanager.h" #include "ianalyzertool.h" +#include "analyzerruncontrolfactory.h" #include #include @@ -79,6 +80,8 @@ bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorStri (void) new AnalyzerManager(this); + addAutoReleasedObject(new AnalyzerRunControlFactory()); + // Task integration. ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ProjectExplorer::TaskHub *hub = pm->getObject(); diff --git a/src/plugins/analyzerbase/analyzerrunconfigwidget.cpp b/src/plugins/analyzerbase/analyzerrunconfigwidget.cpp index cc7a6220bd..88117b2a2a 100644 --- a/src/plugins/analyzerbase/analyzerrunconfigwidget.cpp +++ b/src/plugins/analyzerbase/analyzerrunconfigwidget.cpp @@ -34,7 +34,6 @@ #include "analyzerrunconfigwidget.h" -#include #include #include @@ -45,18 +44,31 @@ #include namespace Analyzer { +namespace Internal { + +AnalyzerToolDetailWidget::AnalyzerToolDetailWidget(AbstractAnalyzerSubConfig *config, QWidget *parent) + : Utils::DetailsWidget(parent) +{ + QTC_ASSERT(config!=0, return); + + // update summary text + setSummaryText(tr("%1 settings").arg(config->displayName())); + + // create config widget + QWidget *configWidget = config->createConfigWidget(this); + setWidget(configWidget); +} AnalyzerRunConfigWidget::AnalyzerRunConfigWidget() - : m_detailsWidget(new Utils::DetailsWidget(this)) { - QWidget *mainWidget = new QWidget(this); - new QVBoxLayout(mainWidget); - m_detailsWidget->setWidget(mainWidget); + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); - QWidget *globalSetting = new QWidget(mainWidget); + QWidget *globalSetting = new QWidget(this); QHBoxLayout *globalSettingLayout = new QHBoxLayout(globalSetting); - mainWidget->layout()->addWidget(globalSetting); - QLabel *label = new QLabel(displayName(), globalSetting); + globalSettingLayout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(globalSetting); + QLabel *label = new QLabel(tr("Analyzer Settings:"), globalSetting); globalSettingLayout->addWidget(label); m_settingsCombo = new QComboBox(globalSetting); m_settingsCombo->addItems(QStringList() @@ -72,13 +84,9 @@ AnalyzerRunConfigWidget::AnalyzerRunConfigWidget() connect(m_restoreButton, SIGNAL(clicked()), this, SLOT(restoreGlobal())); globalSettingLayout->addStretch(2); - m_subConfigWidget = new QWidget(mainWidget); - mainWidget->layout()->addWidget(m_subConfigWidget); + m_subConfigWidget = new QWidget(this); new QVBoxLayout(m_subConfigWidget); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(m_detailsWidget); + layout->addWidget(m_subConfigWidget); } QString AnalyzerRunConfigWidget::displayName() const @@ -93,29 +101,28 @@ void AnalyzerRunConfigWidget::setRunConfiguration(ProjectExplorer::RunConfigurat m_settings = rc->extraAspect(); QTC_ASSERT(m_settings, return); - // update summary text - QStringList tools; - foreach (AbstractAnalyzerSubConfig *config, m_settings->subConfigs()) { - tools << QString("%1").arg(config->displayName()); - } - m_detailsWidget->setSummaryText(tr("Available settings: %1").arg(tools.join(", "))); - - // add group boxes for each sub config - QLayout *layout = m_subConfigWidget->layout(); + // add config widget for each sub config foreach (AbstractAnalyzerSubConfig *config, m_settings->customSubConfigs()) { - QWidget *widget = config->createConfigWidget(this); - layout->addWidget(widget); + QWidget *widget = new AnalyzerToolDetailWidget(config); + m_subConfigWidget->layout()->addWidget(widget); } - m_subConfigWidget->setEnabled(!m_settings->isUsingGlobalSettings()); + setDetailEnabled(!m_settings->isUsingGlobalSettings()); m_settingsCombo->setCurrentIndex(m_settings->isUsingGlobalSettings() ? 0 : 1); m_restoreButton->setEnabled(!m_settings->isUsingGlobalSettings()); } +void AnalyzerRunConfigWidget::setDetailEnabled(bool value) +{ + QList details = findChildren(); + foreach (AnalyzerToolDetailWidget *detail, details) + detail->widget()->setEnabled(value); +} + void AnalyzerRunConfigWidget::chooseSettings(int setting) { QTC_ASSERT(m_settings, return); + setDetailEnabled(setting != 0); m_settings->setUsingGlobalSettings(setting == 0); - m_subConfigWidget->setEnabled(!m_settings->isUsingGlobalSettings()); m_restoreButton->setEnabled(!m_settings->isUsingGlobalSettings()); } @@ -125,4 +132,5 @@ void AnalyzerRunConfigWidget::restoreGlobal() m_settings->resetCustomToGlobalSettings(); } +} // namespace Internal } // namespace Analyzer diff --git a/src/plugins/analyzerbase/analyzerrunconfigwidget.h b/src/plugins/analyzerbase/analyzerrunconfigwidget.h index 9d4469f8f9..66d17b1065 100644 --- a/src/plugins/analyzerbase/analyzerrunconfigwidget.h +++ b/src/plugins/analyzerbase/analyzerrunconfigwidget.h @@ -35,11 +35,12 @@ #ifndef ANALYZER_INTERNAL_ANALYZERRUNCONFIGWIDGET_H #define ANALYZER_INTERNAL_ANALYZERRUNCONFIGWIDGET_H -#include "analyzerbase_global.h" #include "analyzersettings.h" #include +#include + QT_BEGIN_NAMESPACE class QComboBox; class QPushButton; @@ -52,8 +53,19 @@ class DetailsWidget; namespace Analyzer { class AnalyzerSettings; +class AbstractAnalyzerSubConfig; + +namespace Internal { + +class AnalyzerToolDetailWidget : public Utils::DetailsWidget +{ + Q_OBJECT -class ANALYZER_EXPORT AnalyzerRunConfigWidget : public ProjectExplorer::RunConfigWidget +public: + explicit AnalyzerToolDetailWidget(AbstractAnalyzerSubConfig *config, QWidget *parent=0); +}; + +class AnalyzerRunConfigWidget : public ProjectExplorer::RunConfigWidget { Q_OBJECT @@ -64,18 +76,21 @@ public: void setRunConfiguration(ProjectExplorer::RunConfiguration *rc); +private: + void setDetailEnabled(bool value); + private slots: void chooseSettings(int setting); void restoreGlobal(); private: - Utils::DetailsWidget *m_detailsWidget; QWidget *m_subConfigWidget; AnalyzerProjectSettings *m_settings; QComboBox *m_settingsCombo; QPushButton *m_restoreButton; }; +} // namespace Internal } // namespace Analyzer #endif // ANALYZER_INTERNAL_ANALYZERRUNCONFIGWIDGET_H diff --git a/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp b/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp new file mode 100644 index 0000000000..c27140c165 --- /dev/null +++ b/src/plugins/analyzerbase/analyzerruncontrolfactory.cpp @@ -0,0 +1,104 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company. +** +** Contact: Kläralvdalens Datakonsult AB (info@kdab.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "analyzerruncontrolfactory.h" +#include "analyzersettings.h" +#include "analyzerruncontrol.h" +#include "analyzerrunconfigwidget.h" +#include "analyzermanager.h" +#include "ianalyzertool.h" +#include "analyzerstartparameters.h" + +#include +#include + +#include + +#include + +using namespace ProjectExplorer; + +namespace Analyzer { +namespace Internal { + +AnalyzerRunControlFactory::AnalyzerRunControlFactory(QObject *parent) : + IRunControlFactory(parent) +{ +} + +QString AnalyzerRunControlFactory::displayName() const +{ + return tr("Analyzer"); +} + +bool AnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const +{ + IAnalyzerTool *tool = AnalyzerManager::toolFromId(Core::Id(mode)); + if (tool) + return tool->canRun(runConfiguration, mode); + return false; +} + +RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode) +{ + IAnalyzerTool *tool = AnalyzerManager::toolFromId(Core::Id(mode)); + if (!tool) + return 0; + + QTC_ASSERT(canRun(runConfiguration, mode), return 0); + + AnalyzerStartParameters sp = tool->createStartParameters(runConfiguration, mode); + sp.toolId = tool->id(); + + AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration); + QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt())); + return rc; +} + +IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect() +{ + return new AnalyzerProjectSettings; +} + +RunConfigWidget *AnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration) +{ + AnalyzerProjectSettings *settings = runConfiguration->extraAspect(); + if (!settings) + return 0; + + AnalyzerRunConfigWidget *ret = new AnalyzerRunConfigWidget; + ret->setRunConfiguration(runConfiguration); + return ret; +} + +} // namespace Internal +} // namespace Analyzer diff --git a/src/plugins/analyzerbase/analyzerruncontrolfactory.h b/src/plugins/analyzerbase/analyzerruncontrolfactory.h new file mode 100644 index 0000000000..0c43027e68 --- /dev/null +++ b/src/plugins/analyzerbase/analyzerruncontrolfactory.h @@ -0,0 +1,62 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company. +** +** Contact: Kläralvdalens Datakonsult AB (info@kdab.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef ANALYZERRUNCONTROLFACTORY_H +#define ANALYZERRUNCONTROLFACTORY_H + +#include +#include + +namespace Analyzer { +namespace Internal { + +class AnalyzerRunControlFactory : public ProjectExplorer::IRunControlFactory +{ + Q_OBJECT +public: + typedef ProjectExplorer::RunConfiguration RunConfiguration; + + explicit AnalyzerRunControlFactory(QObject *parent = 0); + + // IRunControlFactory implementation + QString displayName() const; + bool canRun(RunConfiguration *runConfiguration, const QString &mode) const; + ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, const QString &mode); + ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(); + ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration); + +}; + +} // namespace Internal +} // namespace Analyzer + +#endif // ANALYZERRUNCONTROLFACTORY_H diff --git a/src/plugins/analyzerbase/ianalyzertool.h b/src/plugins/analyzerbase/ianalyzertool.h index ed2954373f..8ceafae63e 100644 --- a/src/plugins/analyzerbase/ianalyzertool.h +++ b/src/plugins/analyzerbase/ianalyzertool.h @@ -37,6 +37,7 @@ #include "analyzerbase_global.h" #include "analyzerconstants.h" +#include "analyzerstartparameters.h" #include @@ -48,7 +49,6 @@ class RunConfiguration; namespace Analyzer { -class AnalyzerStartParameters; class IAnalyzerOutputPaneAdapter; class IAnalyzerEngine; @@ -121,6 +121,15 @@ public: virtual IAnalyzerEngine *createEngine(const AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration = 0) = 0; + /// Returns true if the tool can be run + virtual bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, + const QString &mode) const = 0; + + /// Create the start parameters for the run control factory + virtual AnalyzerStartParameters createStartParameters( + ProjectExplorer::RunConfiguration *runConfiguration, + const QString &mode) const = 0; + virtual void startTool(StartMode mode) = 0; /// Called when tools gets selected. diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index 88b732031c..d6807a6410 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -26,8 +26,7 @@ SOURCES += \ localqmlprofilerrunner.cpp \ codaqmlprofilerrunner.cpp \ remotelinuxqmlprofilerrunner.cpp \ - qmlprofilereventview.cpp \ - qmlprofilerruncontrolfactory.cpp + qmlprofilereventview.cpp HEADERS += \ qmlprofilerconstants.h \ @@ -42,8 +41,7 @@ HEADERS += \ localqmlprofilerrunner.h \ codaqmlprofilerrunner.h \ remotelinuxqmlprofilerrunner.h \ - qmlprofilereventview.h \ - qmlprofilerruncontrolfactory.h + qmlprofilereventview.h RESOURCES += \ qml/qmlprofiler.qrc diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index 4080a34ef2..69e3909751 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -33,7 +33,6 @@ #include "qmlprofilerplugin.h" #include "qmlprofilertool.h" -#include "qmlprofilerruncontrolfactory.h" #include @@ -48,11 +47,12 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS { Q_UNUSED(arguments) Q_UNUSED(errorString) - addAutoReleasedObject(new QmlProfilerRunControlFactory()); + StartModes modes; modes.append(StartMode(StartLocal)); modes.append(StartMode(StartRemote)); AnalyzerManager::addTool(new QmlProfilerTool(this), modes); + return true; } diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp deleted file mode 100644 index d9b43c4cc0..0000000000 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#include "qmlprofilerruncontrolfactory.h" -#include "qmlprojectmanager/qmlprojectrunconfiguration.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include - -using namespace Analyzer; -using namespace ProjectExplorer; -using namespace QmlProfiler::Internal; -using namespace QmlProjectManager; - -QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) - : IRunControlFactory(parent) -{ - setObjectName(QLatin1String("QmlProfilerRunControlFactory")); -} - -bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const -{ - // FIXME: Should this just accept all mode == QLatin1String("QmlProfiler"); ? - if (qobject_cast(runConfiguration)) - return mode == QLatin1String("QmlProfiler"); - if (qobject_cast(runConfiguration)) - return mode == QLatin1String("QmlProfiler"); - if (qobject_cast(runConfiguration)) - return mode == QLatin1String("QmlProfiler"); - if (qobject_cast(runConfiguration)) - return mode == QLatin1String("QmlProfiler"); - return false; -} - -RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode) -{ - QTC_ASSERT(canRun(runConfiguration, mode), return 0); - AnalyzerStartParameters sp; - sp.toolId = "QmlProfiler"; - sp.startMode = StartQml; // FIXME: The parameter struct is not needed/not used. - - - // FIXME: This is only used to communicate the connParams settings. - if (QmlProjectRunConfiguration *rc1 = - qobject_cast(runConfiguration)) { - // This is a "plain" .qmlproject. - 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(runConfiguration)) { - 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(runConfiguration)) { - sp.debuggee = rc3->remoteExecutableFilePath(); - sp.debuggeeArgs = rc3->arguments(); - sp.connParams = rc3->deviceConfig()->sshParameters(); - sp.analyzerCmdPrefix = rc3->commandPrefix(); - sp.displayName = rc3->displayName(); - } else if (Qt4ProjectManager::S60DeviceRunConfiguration *rc4 = - qobject_cast(runConfiguration)) { - Qt4ProjectManager::S60DeployConfiguration *deployConf = - qobject_cast(runConfiguration->target()->activeDeployConfiguration()); - - sp.debuggeeArgs = rc4->commandLineArguments(); - sp.displayName = rc4->displayName(); - sp.connParams.host = deployConf->deviceAddress(); - sp.connParams.port = rc4->qmlDebugServerPort(); - } else { - // What could that be? - QTC_ASSERT(false, return 0); - } - - IAnalyzerTool *tool = AnalyzerManager::toolFromId(Core::Id(mode)); - AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration); - QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt())); - return rc; -} - -QString QmlProfilerRunControlFactory::displayName() const -{ - return tr("QML Profiler"); -} - -IRunConfigurationAspect *QmlProfilerRunControlFactory::createRunConfigurationAspect() -{ - return new AnalyzerProjectSettings; -} - -RunConfigWidget *QmlProfilerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration) -{ - QmlProjectManager::QmlProjectRunConfiguration *localRc = - qobject_cast(runConfiguration); - if (!localRc) - return 0; - - AnalyzerProjectSettings *settings = runConfiguration->extraAspect(); - if (!settings) - return 0; - - Analyzer::AnalyzerRunConfigWidget *ret = new Analyzer::AnalyzerRunConfigWidget; - - ret->setRunConfiguration(runConfiguration); - return ret; -} diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h deleted file mode 100644 index 5c87c1c250..0000000000 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef QMLPROFILERRUNCONTROLFACTORY_H -#define QMLPROFILERRUNCONTROLFACTORY_H - -#include -#include - -namespace QmlProfiler { -namespace Internal { - -class QmlProfilerRunControlFactory : public ProjectExplorer::IRunControlFactory -{ - Q_OBJECT - -public: - typedef ProjectExplorer::RunConfiguration RunConfiguration; - - QmlProfilerRunControlFactory(QObject *parent = 0); - - // IRunControlFactory implementation - QString displayName() const; - bool canRun(RunConfiguration *runConfiguration, const QString &mode) const; - ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, const QString &mode); - ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(); - ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration); - -signals: - void runControlCreated(Analyzer::AnalyzerRunControl *); -}; - -} // namespace Internal -} // namespace QmlProfiler - -#endif // QMLPROFILERRUNCONTROLFACTORY_H diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 694049913b..80fb530037 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -60,6 +60,10 @@ #include #include #include +#include + +#include +#include #include #include @@ -74,6 +78,8 @@ #include #include +#include +#include #include #include @@ -95,6 +101,8 @@ using namespace Analyzer::Constants; using namespace QmlProfiler::Internal; using namespace QmlJsDebugClient; using namespace ProjectExplorer; +using namespace QmlProjectManager; +using namespace RemoteLinux; class QmlProfilerTool::QmlProfilerToolPrivate { @@ -357,6 +365,68 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp return engine; } +bool QmlProfilerTool::canRun(RunConfiguration *runConfiguration, const QString &mode) const +{ + Q_UNUSED(mode); + + if (qobject_cast(runConfiguration) + || qobject_cast(runConfiguration) + || qobject_cast(runConfiguration) + || qobject_cast(runConfiguration)) + return true; + return false; +} + +AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration *runConfiguration, const QString &mode) const +{ + Q_UNUSED(mode); + + AnalyzerStartParameters sp; + sp.startMode = StartQml; // FIXME: The parameter struct is not needed/not used. + + // FIXME: This is only used to communicate the connParams settings. + if (QmlProjectRunConfiguration *rc1 = + qobject_cast(runConfiguration)) { + // This is a "plain" .qmlproject. + 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(runConfiguration)) { + 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(runConfiguration)) { + sp.debuggee = rc3->remoteExecutableFilePath(); + sp.debuggeeArgs = rc3->arguments(); + sp.connParams = rc3->deviceConfig()->sshParameters(); + sp.analyzerCmdPrefix = rc3->commandPrefix(); + sp.displayName = rc3->displayName(); + } else if (Qt4ProjectManager::S60DeviceRunConfiguration *rc4 = + qobject_cast(runConfiguration)) { + Qt4ProjectManager::S60DeployConfiguration *deployConf = + qobject_cast(runConfiguration->target()->activeDeployConfiguration()); + + sp.debuggeeArgs = rc4->commandLineArguments(); + sp.displayName = rc4->displayName(); + sp.connParams.host = deployConf->deviceAddress(); + sp.connParams.port = rc4->qmlDebugServerPort(); + } else { + // What could that be? + QTC_ASSERT(false, return sp); + } + return sp; +} + QWidget *QmlProfilerTool::createWidgets() { QTC_ASSERT(!d->m_traceWindow, return 0); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 12755645b1..b81bb83f29 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -61,6 +61,13 @@ public: Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration = 0); + bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, + const QString &mode) const; + + Analyzer::AnalyzerStartParameters createStartParameters( + ProjectExplorer::RunConfiguration *runConfiguration, + const QString &mode) const; + QWidget *createWidgets(); void startTool(Analyzer::StartMode mode); diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 904e1da332..74c1e027d9 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -497,7 +497,7 @@ static QToolButton *createToolButton(QAction *action) } CallgrindTool::CallgrindTool(QObject *parent) - : Analyzer::IAnalyzerTool(parent) + : ValgrindTool(parent) { d = new CallgrindToolPrivate(this); setObjectName(QLatin1String("CallgrindTool")); diff --git a/src/plugins/valgrind/callgrindtool.h b/src/plugins/valgrind/callgrindtool.h index e6219e8cae..014caa8f8e 100644 --- a/src/plugins/valgrind/callgrindtool.h +++ b/src/plugins/valgrind/callgrindtool.h @@ -33,14 +33,14 @@ #ifndef CALLGRINDTOOL_H #define CALLGRINDTOOL_H -#include +#include "valgrindtool.h" namespace Valgrind { namespace Internal { class CallgrindToolPrivate; -class CallgrindTool : public Analyzer::IAnalyzerTool +class CallgrindTool : public ValgrindTool { Q_OBJECT diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 6f836a89d2..ecd4082601 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -185,7 +185,7 @@ static void initKindFilterAction(QAction *action, const QList &kinds) } MemcheckTool::MemcheckTool(QObject *parent) - : Analyzer::IAnalyzerTool(parent) + : ValgrindTool(parent) { m_settings = 0; m_errorModel = 0; diff --git a/src/plugins/valgrind/memchecktool.h b/src/plugins/valgrind/memchecktool.h index f808e3bc62..f5c1d3f48b 100644 --- a/src/plugins/valgrind/memchecktool.h +++ b/src/plugins/valgrind/memchecktool.h @@ -35,7 +35,7 @@ #ifndef MEMCHECKTOOL_H #define MEMCHECKTOOL_H -#include +#include "valgrindtool.h" #include #include @@ -86,7 +86,7 @@ private: bool m_filterExternalIssues; }; -class MemcheckTool : public Analyzer::IAnalyzerTool +class MemcheckTool : public ValgrindTool { Q_OBJECT diff --git a/src/plugins/valgrind/valgrind.pro b/src/plugins/valgrind/valgrind.pro index f5df7d4d12..f88a5e4d14 100644 --- a/src/plugins/valgrind/valgrind.pro +++ b/src/plugins/valgrind/valgrind.pro @@ -30,7 +30,8 @@ HEADERS += \ memchecktool.h \ memcheckengine.h \ memcheckerrorview.h \ - suppressiondialog.h + suppressiondialog.h \ + valgrindtool.h SOURCES += \ valgrindplugin.cpp \ @@ -52,7 +53,8 @@ SOURCES += \ memchecktool.cpp \ memcheckengine.cpp \ memcheckerrorview.cpp \ - suppressiondialog.cpp + suppressiondialog.cpp \ + valgrindtool.cpp FORMS += \ valgrindconfigwidget.ui diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp index 0129a231c5..b083510412 100644 --- a/src/plugins/valgrind/valgrindplugin.cpp +++ b/src/plugins/valgrind/valgrindplugin.cpp @@ -59,112 +59,12 @@ #include using namespace Analyzer; -using namespace Valgrind::Internal; using namespace ProjectExplorer; -///////////////////////////////////////////////////////////////////////////////// -// -// ValgrindRunControlFactory -// -///////////////////////////////////////////////////////////////////////////////// namespace Valgrind { namespace Internal { -class ValgrindRunControlFactory : public ProjectExplorer::IRunControlFactory -{ - Q_OBJECT - -public: - ValgrindRunControlFactory(QObject *parent = 0); - - // IRunControlFactory - bool canRun(RunConfiguration *runConfiguration, const QString &mode) const; - RunControl *create(RunConfiguration *runConfiguration, const QString &mode); - QString displayName() const; - - IRunConfigurationAspect *createRunConfigurationAspect(); - RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration); -}; - -ValgrindRunControlFactory::ValgrindRunControlFactory(QObject *parent) - : IRunControlFactory(parent) -{ - setObjectName(QLatin1String("ValgrindRunControlFactory")); -} - -bool ValgrindRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const -{ - Q_UNUSED(runConfiguration); - return mode.startsWith("Callgrind") || mode.startsWith("Memcheck"); -} - -RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode) -{ - QTC_ASSERT(canRun(runConfiguration, mode), return 0); - - AnalyzerStartParameters sp; - if (LocalApplicationRunConfiguration *rc1 = - qobject_cast(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(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; - sp.startMode = StartRemote; - } - - IAnalyzerTool *tool = AnalyzerManager::toolFromId(Core::Id(mode)); - AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration); - QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt())); - return rc; -} - -QString ValgrindRunControlFactory::displayName() const -{ - return tr("Analyzer"); -} - -IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect() -{ - return new AnalyzerProjectSettings; -} - -RunConfigWidget *ValgrindRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration) -{ - LocalApplicationRunConfiguration *localRc = - qobject_cast(runConfiguration); - if (!localRc) - return 0; - AnalyzerProjectSettings *settings = runConfiguration->extraAspect(); - if (!settings) - return 0; - - AnalyzerRunConfigWidget *ret = new AnalyzerRunConfigWidget; - ret->setRunConfiguration(runConfiguration); - return ret; -} - -///////////////////////////////////////////////////////////////////////////////// -// -// ValgrindPlugin -// -///////////////////////////////////////////////////////////////////////////////// - static void startRemoteTool(IAnalyzerTool *tool) { Q_UNUSED(tool); @@ -219,9 +119,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) AnalyzerManager::addTool(new MemcheckTool(this), modes); AnalyzerManager::addTool(new CallgrindTool(this), modes); - ValgrindRunControlFactory *factory = new ValgrindRunControlFactory(); - addAutoReleasedObject(factory); - return true; } @@ -230,5 +127,3 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) Q_EXPORT_PLUGIN(Valgrind::Internal::ValgrindPlugin) - -#include "valgrindplugin.moc" diff --git a/src/plugins/valgrind/valgrindtool.cpp b/src/plugins/valgrind/valgrindtool.cpp new file mode 100644 index 0000000000..208ad7cae9 --- /dev/null +++ b/src/plugins/valgrind/valgrindtool.cpp @@ -0,0 +1,91 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company. +** +** Contact: Kläralvdalens Datakonsult AB (info@kdab.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "valgrindtool.h" + +#include +#include + +#include +#include + +using namespace ProjectExplorer; +using namespace RemoteLinux; + +namespace Valgrind { +namespace Internal { + +ValgrindTool::ValgrindTool(QObject *parent) : + Analyzer::IAnalyzerTool(parent) +{ +} + +bool ValgrindTool::canRun(ProjectExplorer::RunConfiguration *, const QString &) const +{ + return true; +} + +Analyzer::AnalyzerStartParameters ValgrindTool::createStartParameters( + ProjectExplorer::RunConfiguration *runConfiguration, + const QString &mode) const +{ + Q_UNUSED(mode); + + Analyzer::AnalyzerStartParameters sp; + if (LocalApplicationRunConfiguration *rc1 = + qobject_cast(runConfiguration)) { + sp.startMode = Analyzer::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 (RemoteLinuxRunConfiguration *rc2 = + qobject_cast(runConfiguration)) { + sp.startMode = Analyzer::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; + sp.startMode = Analyzer::StartRemote; + } + return sp; +} + +} // namespace Internal +} // namespace Valgrind diff --git a/src/plugins/valgrind/valgrindtool.h b/src/plugins/valgrind/valgrindtool.h new file mode 100644 index 0000000000..8c384f4ddd --- /dev/null +++ b/src/plugins/valgrind/valgrindtool.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company. +** +** Contact: Kläralvdalens Datakonsult AB (info@kdab.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef VALGRINDTOOL_H +#define VALGRINDTOOL_H + +#include + +namespace Valgrind { +namespace Internal { + +class ValgrindTool : public Analyzer::IAnalyzerTool +{ + Q_OBJECT +public: + explicit ValgrindTool(QObject *parent); + + bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, + const QString &mode) const; + + Analyzer::AnalyzerStartParameters createStartParameters( + ProjectExplorer::RunConfiguration *runConfiguration, + const QString &mode) const; +}; + +} // namespace Internal +} // namespace Valgrind + +#endif // VALGRINDTOOL_H -- cgit v1.2.1