Commit 20d7d5e5 authored by hjk's avatar hjk

ProjectExplorer/Analyzer: Merge RunConfigurationAspects

The Analyzer implementation is now simple and still generic enough
to serve as general base.

Change-Id: I050a21919bf128929b77a64da1f46d157691d849
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 02105ddf
......@@ -11,7 +11,6 @@ SOURCES += \
analyzerplugin.cpp \
analyzerruncontrol.cpp \
analyzermanager.cpp \
analyzersettings.cpp \
analyzerrunconfigwidget.cpp \
analyzerutils.cpp \
startremotedialog.cpp
......@@ -23,7 +22,6 @@ HEADERS += \
analyzerplugin.h \
analyzerruncontrol.h \
analyzermanager.h \
analyzersettings.h \
analyzerstartparameters.h \
analyzerrunconfigwidget.h \
analyzerutils.h \
......
......@@ -24,8 +24,6 @@ QtcPlugin {
"analyzerrunconfigwidget.h",
"analyzerruncontrol.cpp",
"analyzerruncontrol.h",
"analyzersettings.cpp",
"analyzersettings.h",
"analyzerstartparameters.h",
"analyzerutils.cpp",
"analyzerutils.h",
......
......@@ -32,7 +32,6 @@
#include "analyzerplugin.h"
#include "ianalyzertool.h"
#include "analyzersettings.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/findplaceholder.h>
......
......@@ -41,9 +41,8 @@
#include <QPushButton>
namespace Analyzer {
namespace Internal {
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(AnalyzerRunConfigurationAspect *aspect)
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect)
{
m_aspect = aspect;
m_config = aspect->projectSettings();
......@@ -106,8 +105,7 @@ void AnalyzerRunConfigWidget::chooseSettings(int setting)
void AnalyzerRunConfigWidget::restoreGlobal()
{
QTC_ASSERT(m_aspect, return);
m_aspect->resetCustomToGlobalSettings();
m_aspect->resetProjectToGlobalSettings();
}
} // namespace Internal
} // namespace Analyzer
......@@ -28,10 +28,12 @@
**
****************************************************************************/
#ifndef ANALYZER_INTERNAL_ANALYZERRUNCONFIGWIDGET_H
#define ANALYZER_INTERNAL_ANALYZERRUNCONFIGWIDGET_H
#ifndef ANALYZERRUNCONFIGWIDGET_H
#define ANALYZERRUNCONFIGWIDGET_H
#include "analyzersettings.h"
#include "analyzerbase_global.h"
#include <projectexplorer/runconfiguration.h>
QT_BEGIN_NAMESPACE
class QComboBox;
......@@ -41,14 +43,13 @@ QT_END_NAMESPACE
namespace Utils { class DetailsWidget; }
namespace Analyzer {
namespace Internal {
class AnalyzerRunConfigWidget : public ProjectExplorer::RunConfigWidget
class ANALYZER_EXPORT AnalyzerRunConfigWidget : public ProjectExplorer::RunConfigWidget
{
Q_OBJECT
public:
AnalyzerRunConfigWidget(AnalyzerRunConfigurationAspect *aspect);
AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect);
QString displayName() const;
......@@ -58,14 +59,13 @@ private slots:
private:
QWidget *m_configWidget;
AnalyzerRunConfigurationAspect *m_aspect;
ISettingsAspect *m_config;
ProjectExplorer::IRunConfigurationAspect *m_aspect;
ProjectExplorer::ISettingsAspect *m_config;
QComboBox *m_settingsCombo;
QPushButton *m_restoreButton;
Utils::DetailsWidget *m_details;
};
} // namespace Internal
} // namespace Analyzer
#endif // ANALYZER_INTERNAL_ANALYZERRUNCONFIGWIDGET_H
#endif // ANALYZERRUNCONFIGWIDGET_H
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Milian Wolff, KDAB (milian.wolff@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, 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, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "analyzersettings.h"
#include "analyzermanager.h"
#include "analyzerrunconfigwidget.h"
#include "ianalyzertool.h"
#include "analyzerplugin.h"
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <QSettings>
using namespace Analyzer::Internal;
static const char useGlobalC[] = "Analyzer.Project.UseGlobal";
namespace Analyzer {
ISettingsAspect *ISettingsAspect::clone() const
{
ISettingsAspect *other = create();
QVariantMap data;
toMap(data);
other->fromMap(data);
return other;
}
AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect(ISettingsAspect *projectSettings,
ISettingsAspect *globalSettings)
{
m_useGlobalSettings = true;
m_projectSettings = projectSettings;
m_globalSettings = globalSettings;
}
ISettingsAspect *AnalyzerRunConfigurationAspect::currentSettings() const
{
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
}
AnalyzerRunConfigurationAspect::~AnalyzerRunConfigurationAspect()
{
delete m_projectSettings;
}
void AnalyzerRunConfigurationAspect::fromMap(const QVariantMap &map)
{
m_projectSettings->fromMap(map);
m_useGlobalSettings = map.value(QLatin1String(useGlobalC), true).toBool();
}
void AnalyzerRunConfigurationAspect::toMap(QVariantMap &map) const
{
m_projectSettings->toMap(map);
map.insert(QLatin1String(useGlobalC), m_useGlobalSettings);
}
AnalyzerRunConfigurationAspect *AnalyzerRunConfigurationAspect::clone(
ProjectExplorer::RunConfiguration *parent) const
{
Q_UNUSED(parent)
AnalyzerRunConfigurationAspect *other
= new AnalyzerRunConfigurationAspect(m_projectSettings->clone(), m_globalSettings);
other->m_useGlobalSettings = m_useGlobalSettings;
return other;
}
void AnalyzerRunConfigurationAspect::setUsingGlobalSettings(bool value)
{
m_useGlobalSettings = value;
}
void AnalyzerRunConfigurationAspect::resetCustomToGlobalSettings()
{
ISettingsAspect *global = globalSettings();
QTC_ASSERT(global, return);
QVariantMap map;
global->toMap(map);
m_projectSettings->fromMap(map);
}
ProjectExplorer::RunConfigWidget *AnalyzerRunConfigurationAspect::createConfigurationWidget()
{
return new AnalyzerRunConfigWidget(this);
}
} // namespace Analyzer
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Milian Wolff, KDAB (milian.wolff@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, 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, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef ANALYZER_INTERNAL_ANALYZERSETTINGS_H
#define ANALYZER_INTERNAL_ANALYZERSETTINGS_H
#include <QObject>
#include "analyzerbase_global.h"
#include <projectexplorer/runconfiguration.h>
namespace Analyzer {
/**
* Subclass this to add configuration to your analyzer tool.
*
* If global and project-specific settings differ for your tool,
* create one subclass for each.
*/
class ANALYZER_EXPORT ISettingsAspect : public QObject
{
Q_OBJECT
public:
ISettingsAspect() {}
/// Converts current object into map for storage.
virtual void toMap(QVariantMap &map) const = 0;
/// Read object state from @p map.
virtual void fromMap(const QVariantMap &map) = 0;
/// Create a configuration widget for this settings aspect.
virtual QWidget *createConfigWidget(QWidget *parent) = 0;
/// "Virtual default constructor"
virtual ISettingsAspect *create() const = 0;
/// "Virtual copy constructor"
ISettingsAspect *clone() const;
};
/**
* Settings associated with a single project/run configuration
*
*/
class ANALYZER_EXPORT AnalyzerRunConfigurationAspect
: public ProjectExplorer::IRunConfigurationAspect
{
Q_OBJECT
public:
AnalyzerRunConfigurationAspect(ISettingsAspect *projectSettings,
ISettingsAspect *globalSettings);
~AnalyzerRunConfigurationAspect();
AnalyzerRunConfigurationAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
void setUsingGlobalSettings(bool value);
void resetCustomToGlobalSettings();
ISettingsAspect *projectSettings() const { return m_projectSettings; }
ISettingsAspect *globalSettings() const { return m_globalSettings; }
ISettingsAspect *currentSettings() const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
protected:
void fromMap(const QVariantMap &map);
void toMap(QVariantMap &map) const;
private:
bool m_useGlobalSettings;
ISettingsAspect *m_projectSettings;
ISettingsAspect *m_globalSettings;
};
} // namespace Analyzer
#endif // ANALYZER_INTERNAL_ANALYZERSETTINGS_H
......@@ -204,14 +204,14 @@ void DebuggerMainWindowPrivate::updateUiForRunConfiguration(RunConfiguration *rc
{
if (m_previousRunConfiguration)
disconnect(m_previousRunConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>(),
SIGNAL(debuggersChanged()),
SIGNAL(requestRunActionsUpdate()),
this, SLOT(updateUiForCurrentRunConfiguration()));
m_previousRunConfiguration = rc;
updateUiForCurrentRunConfiguration();
if (!rc)
return;
connect(m_previousRunConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>(),
SIGNAL(debuggersChanged()),
SIGNAL(requestRunActionsUpdate()),
SLOT(updateUiForCurrentRunConfiguration()));
}
......
......@@ -194,48 +194,32 @@ void DebuggerRunConfigWidget::useMultiProcessToggled(bool on)
DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(
ProjectExplorer::RunConfiguration *rc) :
m_runConfiguration(rc),
IRunConfigurationAspect(rc),
m_useCppDebugger(AutoEnabledLanguage),
m_useQmlDebugger(AutoEnabledLanguage),
m_qmlDebugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT),
m_useMultiProcess(false)
{
ctor();
}
DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(
ProjectExplorer::RunConfiguration *runConfiguration,
const DebuggerRunConfigurationAspect *other)
: m_runConfiguration(runConfiguration),
m_useCppDebugger(other->m_useCppDebugger),
m_useQmlDebugger(other->m_useQmlDebugger),
m_qmlDebugServerPort(other->m_qmlDebugServerPort),
m_useMultiProcess(other->m_useMultiProcess)
{
ctor();
}
ProjectExplorer::RunConfiguration *DebuggerRunConfigurationAspect::runConfiguration()
{
return m_runConfiguration;
setId("DebuggerAspect");
setDisplayName(tr("Debugger settings"));
}
void DebuggerRunConfigurationAspect::setUseQmlDebugger(bool value)
{
m_useQmlDebugger = value ? EnabledLanguage : DisabledLanguage;
emit debuggersChanged();
emit requestRunActionsUpdate();
}
void DebuggerRunConfigurationAspect::setUseCppDebugger(bool value)
{
m_useCppDebugger = value ? EnabledLanguage : DisabledLanguage;
emit debuggersChanged();
emit requestRunActionsUpdate();
}
bool DebuggerRunConfigurationAspect::useCppDebugger() const
{
if (m_useCppDebugger == DebuggerRunConfigurationAspect::AutoEnabledLanguage)
return m_runConfiguration->target()->project()->projectLanguages().contains(
return runConfiguration()->target()->project()->projectLanguages().contains(
ProjectExplorer::Constants::LANG_CXX);
return m_useCppDebugger == DebuggerRunConfigurationAspect::EnabledLanguage;
}
......@@ -243,7 +227,7 @@ bool DebuggerRunConfigurationAspect::useCppDebugger() const
bool DebuggerRunConfigurationAspect::useQmlDebugger() const
{
if (m_useQmlDebugger == DebuggerRunConfigurationAspect::AutoEnabledLanguage)
return m_runConfiguration->target()->project()->projectLanguages().contains(
return runConfiguration()->target()->project()->projectLanguages().contains(
ProjectExplorer::Constants::LANG_QMLJS);
return m_useQmlDebugger == DebuggerRunConfigurationAspect::EnabledLanguage;
}
......@@ -270,7 +254,7 @@ void DebuggerRunConfigurationAspect::setUseMultiProcess(bool value)
bool DebuggerRunConfigurationAspect::isQmlDebuggingSpinboxSuppressed() const
{
ProjectExplorer::Kit *k = m_runConfiguration->target()->kit();
ProjectExplorer::Kit *k = runConfiguration()->target()->kit();
ProjectExplorer::IDevice::ConstPtr dev = ProjectExplorer::DeviceKitInformation::device(k);
if (dev.isNull())
return false;
......@@ -304,10 +288,10 @@ void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map)
m_useMultiProcess = map.value(QLatin1String(USE_MULTIPROCESS_KEY), false).toBool();
}
DebuggerRunConfigurationAspect *DebuggerRunConfigurationAspect::clone(
ProjectExplorer::RunConfiguration *parent) const
DebuggerRunConfigurationAspect *DebuggerRunConfigurationAspect::create
(ProjectExplorer::RunConfiguration *runConfiguration) const
{
return new DebuggerRunConfigurationAspect(parent, this);
return new DebuggerRunConfigurationAspect(runConfiguration);
}
ProjectExplorer::RunConfigWidget *DebuggerRunConfigurationAspect::createConfigurationWidget()
......@@ -315,15 +299,6 @@ ProjectExplorer::RunConfigWidget *DebuggerRunConfigurationAspect::createConfigur
return new Internal::DebuggerRunConfigWidget(this);
}
void DebuggerRunConfigurationAspect::ctor()
{
setId("DebuggerAspect");
setDisplayName(tr("Debugger settings"));
connect(this, SIGNAL(debuggersChanged()),
m_runConfiguration, SIGNAL(requestRunActionsUpdate()));
}
} // namespace Debugger
......
......@@ -45,8 +45,7 @@ class DEBUGGER_EXPORT DebuggerRunConfigurationAspect
public:
DebuggerRunConfigurationAspect(ProjectExplorer::RunConfiguration *runConfiguration);
DebuggerRunConfigurationAspect(ProjectExplorer::RunConfiguration *runConfiguration,
const DebuggerRunConfigurationAspect *other);
DebuggerRunConfigurationAspect *create(ProjectExplorer::RunConfiguration *runConfiguration) const;
enum DebuggerLanguageStatus {
DisabledLanguage = 0,
......@@ -57,7 +56,6 @@ public:
void fromMap(const QVariantMap &map);
void toMap(QVariantMap &map) const;
DebuggerRunConfigurationAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
bool useCppDebugger() const;
......@@ -69,15 +67,8 @@ public:
bool useMultiProcess() const;
void setUseMultiProcess(bool on);
bool isQmlDebuggingSpinboxSuppressed() const;
ProjectExplorer::RunConfiguration *runConfiguration();
signals:
void debuggersChanged();
private:
void ctor();
ProjectExplorer::RunConfiguration *m_runConfiguration;
DebuggerLanguageStatus m_useCppDebugger;
DebuggerLanguageStatus m_useQmlDebugger;
uint m_qmlDebugServerPort;
......
......@@ -43,21 +43,13 @@ namespace ProjectExplorer {
// EnvironmentAspect:
// --------------------------------------------------------------------
EnvironmentAspect::EnvironmentAspect(RunConfiguration *rc) :
m_base(-1),
m_runConfiguration(rc)
EnvironmentAspect::EnvironmentAspect(RunConfiguration *runConfig)
: IRunConfigurationAspect(runConfig), m_base(-1)
{
QTC_CHECK(m_runConfiguration);
setDisplayName(tr("Run Environment"));
setId("EnvironmentAspect");
}
EnvironmentAspect::EnvironmentAspect(const EnvironmentAspect *other, RunConfiguration *parent) :
m_base(other->m_base),
m_changes(other->m_changes),
m_runConfiguration(parent)
{ }
RunConfigWidget *EnvironmentAspect::createConfigurationWidget()
{
return new EnvironmentAspectWidget(this);
......
......@@ -49,8 +49,6 @@ public:
// IRunConfigurationAspect:
RunConfigWidget *createConfigurationWidget();
virtual RunConfiguration *runConfiguration() const { return m_runConfiguration; }
virtual QList<int> possibleBaseEnvironments() const = 0;
virtual QString baseEnvironmentDisplayName(int base) const = 0;
......@@ -69,15 +67,13 @@ signals:
void environmentChanged();
protected:
EnvironmentAspect(const EnvironmentAspect *other, RunConfiguration *parent);
EnvironmentAspect(RunConfiguration *rc);
explicit EnvironmentAspect(RunConfiguration *rc);
void fromMap(const QVariantMap &map);
void toMap(QVariantMap &map) const;
private:
mutable int m_base;
QList<Utils::EnvironmentItem> m_changes;
RunConfiguration *m_runConfiguration;
};
} // namespace ProjectExplorer
......
......@@ -88,22 +88,16 @@ void LocalEnvironmentAspect::buildEnvironmentHasChanged()
emit environmentChanged();
}
LocalEnvironmentAspect::LocalEnvironmentAspect(RunConfiguration *rc) :
EnvironmentAspect(rc)
LocalEnvironmentAspect::LocalEnvironmentAspect(RunConfiguration *parent) :
EnvironmentAspect(parent)
{
connect(rc->target(), SIGNAL(environmentChanged()),
connect(parent->target(), SIGNAL(environmentChanged()),
this, SLOT(buildEnvironmentHasChanged()));
}
LocalEnvironmentAspect::LocalEnvironmentAspect(const LocalEnvironmentAspect *other,
ProjectExplorer::RunConfiguration *parent) :
EnvironmentAspect(other, parent)
{ }
LocalEnvironmentAspect *LocalEnvironmentAspect::clone(RunConfiguration *parent) const
LocalEnvironmentAspect *LocalEnvironmentAspect::create(RunConfiguration *parent) const
{
Q_UNUSED(parent);
return new LocalEnvironmentAspect(this, parent);
return new LocalEnvironmentAspect(parent);
}
} // namespace ProjectExplorer
......@@ -39,9 +39,8 @@ class PROJECTEXPLORER_EXPORT LocalEnvironmentAspect : public EnvironmentAspect
Q_OBJECT
public:
LocalEnvironmentAspect(RunConfiguration *rc);
LocalEnvironmentAspect *clone(RunConfiguration *parent) const;
LocalEnvironmentAspect(RunConfiguration *parent);
LocalEnvironmentAspect *create(RunConfiguration *parent) const;
QList<int> possibleBaseEnvironments() const;
QString baseEnvironmentDisplayName(int base) const;
......@@ -56,8 +55,6 @@ private:
SystemEnvironmentBase,
BuildEnvironmentBase
};
LocalEnvironmentAspect(const LocalEnvironmentAspect *other, RunConfiguration *parent);
};
} // namespace ProjectExplorer
......
......@@ -103,15 +103,99 @@ bool ProcessHandle::equals(const ProcessHandle &rhs) const
return m_pid == rhs.m_pid;
}
///////////////////////////////////////////////////////////////////////
//
// ISettingsAspect
//
///////////////////////////////////////////////////////////////////////
ISettingsAspect *ISettingsAspect::clone() const
{
ISettingsAspect *other = create();
QVariantMap data;
toMap(data);
other->fromMap(data);
return other;
}
///////////////////////////////////////////////////////////////////////
//
// IRunConfigurationAspect
//
///////////////////////////////////////////////////////////////////////
IRunConfigurationAspect::IRunConfigurationAspect(RunConfiguration *parent)
{
m_runConfiguration = parent;
m_projectSettings = 0;
m_globalSettings = 0;
m_useGlobalSettings = false;
connect(this, SIGNAL(requestRunActionsUpdate()), parent, SIGNAL(requestRunActionsUpdate()));
}
IRunConfigurationAspect::~IRunConfigurationAspect()
{
delete m_projectSettings;
}
/*!
\brief Returns the widget used to configure this run configuration. Ownership is transferred to the caller
*/
RunConfigWidget *IRunConfigurationAspect::createConfigurationWidget()
{
return 0;
}
void IRunConfigurationAspect::setProjectSettings(ISettingsAspect *settings)
{
m_projectSettings = settings;
}
void IRunConfigurationAspect::setGlobalSettings(ISettingsAspect *settings)
{
m_globalSettings = settings;
}
void IRunConfigurationAspect::setUsingGlobalSettings(bool value)
{
m_useGlobalSettings = value;
}
ISettingsAspect *IRunConfigurationAspect::currentSettings() const
{
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
}
void IRunConfigurationAspect::fromMap(const QVariantMap &map)
{
m_projectSettings->fromMap(map);
m_useGlobalSettings = map.value(m_id.toString() + QLatin1String(".UseGlobalSettings"), true).toBool();
}
void IRunConfigurationAspect::toMap(QVariantMap &map) const
{
m_projectSettings->toMap(map);
map.insert(m_id.toString() + QLatin1String(".UseGlobalSettings"), m_useGlobalSettings);
}
IRunConfigurationAspect *IRunConfigurationAspect::clone(RunConfiguration *parent) const