ProjectExplorer: Re-organize RunConfiguration constructors

The idea is to massage the setup in a way to make implementation
of new configurations less error prone by identifying recurring patterns
and sharing repetitive code that tends to be forgotten (see Android cloning).

The former two lines of constructors (owner-and-id, owner-and-source)
are split into a simple, shared, constructor and new setId() and
copyFrom() functions.

The change is mostly mechanical, some multiple calls to fromMap
have been removed, though, some consts added.

Otherwise, to keep the patch small it temporarily introduces two
helper templates in IRunConfigurationFactory. Also, setId() signatures
have not been unified yet. These won't be needed in the final setup.

Change-Id: I8c0734496caae744a9883fe6d92c1d8f8e0234ea
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2017-09-01 13:23:02 +02:00
parent 4710e6b4b2
commit 890c1906e6
52 changed files with 510 additions and 506 deletions

View File

@@ -45,13 +45,8 @@ const char amStartArgsKey[] = "Android.AmStartArgsKey";
const char preStartShellCmdsKey[] = "Android.PreStartShellCmdListKey";
const char postFinishShellCmdsKey[] = "Android.PostFinishShellCmdListKey";
AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, Core::Id id)
: RunConfiguration(parent, id)
{
}
AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, AndroidRunConfiguration *source)
: RunConfiguration(parent, source)
AndroidRunConfiguration::AndroidRunConfiguration(Target *target)
: RunConfiguration(target)
{
}

View File

@@ -29,17 +29,13 @@
#include <projectexplorer/runconfiguration.h>
QT_BEGIN_NAMESPACE
class QToolButton;
QT_END_NAMESPACE
namespace Android {
class ANDROID_EXPORT AndroidRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
public:
AndroidRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
explicit AndroidRunConfiguration(ProjectExplorer::Target *target);
QWidget *createConfigurationWidget() override;
Utils::OutputFormatter *createOutputFormatter() const override;
@@ -51,15 +47,12 @@ public:
const QStringList &preStartShellCommands() const;
const QStringList &postFinishShellCommands() const;
protected:
AndroidRunConfiguration(ProjectExplorer::Target *parent, AndroidRunConfiguration *source);
private:
// FIXME: This appears to miss a copyFrom() implementation.
void setPreStartShellCommands(const QStringList &cmdList);
void setPostFinishShellCommands(const QStringList &cmdList);
void setAmStartExtraArgs(const QStringList &args);
private:
QStringList m_amStartExtraArgs;
QStringList m_preStartShellCommands;
QStringList m_postFinishShellCommands;

View File

@@ -47,8 +47,9 @@ class TestRunConfiguration : public ProjectExplorer::RunConfiguration
public:
TestRunConfiguration(ProjectExplorer::Target *parent, TestConfiguration *config)
: ProjectExplorer::RunConfiguration(parent, "AutoTest.TestRunConfig")
: ProjectExplorer::RunConfiguration(parent)
{
initialize("AutoTest.TestRunConfig");
setDefaultDisplayName(tr("AutoTest Debug"));
// disable QmlDebugger that is enabled by default

View File

@@ -113,15 +113,19 @@ private:
};
BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(ProjectExplorer::Target *parent)
: BareMetalRunConfiguration(parent, runConfigId(), QString())
: BareMetalRunConfiguration(parent)
{
}
BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(ProjectExplorer::Target *parent,
BareMetalCustomRunConfiguration *source)
: BareMetalRunConfiguration(parent, source)
, m_localExecutable(source->m_localExecutable)
void BareMetalCustomRunConfiguration::initialize()
{
BareMetalRunConfiguration::initialize(runConfigId(), QString());
}
void BareMetalCustomRunConfiguration::copyFrom(const BareMetalCustomRunConfiguration *source)
{
BareMetalRunConfiguration::copyFrom(source);
m_localExecutable = source->m_localExecutable;
}
bool BareMetalCustomRunConfiguration::isConfigured() const

View File

@@ -36,9 +36,10 @@ class BareMetalCustomRunConfiguration : public BareMetalRunConfiguration
{
Q_OBJECT
public:
BareMetalCustomRunConfiguration(ProjectExplorer::Target *parent);
BareMetalCustomRunConfiguration(ProjectExplorer::Target *parent,
BareMetalCustomRunConfiguration *source);
explicit BareMetalCustomRunConfiguration(ProjectExplorer::Target *parent);
void initialize();
void copyFrom(const BareMetalCustomRunConfiguration *source);
bool isConfigured() const override;
ConfigurationState ensureConfigured(QString *errorMessage) override;

View File

@@ -45,36 +45,35 @@ const char ProFileKey[] = "Qt4ProjectManager.MaemoRunConfiguration.ProFile";
const char WorkingDirectoryKey[] = "BareMetal.RunConfig.WorkingDirectory";
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent, BareMetalRunConfiguration *other)
: RunConfiguration(parent, other),
m_projectFilePath(other->m_projectFilePath),
m_workingDirectory(other->m_workingDirectory)
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *target)
: RunConfiguration(target)
{
init();
}
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent,
const Core::Id id,
const QString &projectFilePath)
: RunConfiguration(parent, id),
m_projectFilePath(projectFilePath)
{
addExtraAspect(new ArgumentsAspect(this, QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.Arguments")));
init();
}
void BareMetalRunConfiguration::init()
{
setDefaultDisplayName(defaultDisplayName());
connect(target(), &Target::deploymentDataChanged,
addExtraAspect(new ArgumentsAspect(this, "Qt4ProjectManager.MaemoRunConfiguration.Arguments"));
connect(target, &Target::deploymentDataChanged,
this, &BareMetalRunConfiguration::handleBuildSystemDataUpdated);
connect(target(), &Target::applicationTargetsChanged,
connect(target, &Target::applicationTargetsChanged,
this, &BareMetalRunConfiguration::handleBuildSystemDataUpdated);
connect(target(), &Target::kitChanged,
connect(target, &Target::kitChanged,
this, &BareMetalRunConfiguration::handleBuildSystemDataUpdated); // Handles device changes, etc.
}
void BareMetalRunConfiguration::copyFrom(const BareMetalRunConfiguration *other)
{
RunConfiguration::copyFrom(other);
m_projectFilePath = other->m_projectFilePath;
m_workingDirectory = other->m_workingDirectory;
setDefaultDisplayName(defaultDisplayName());
}
void BareMetalRunConfiguration::initialize(const Core::Id id, const QString &projectFilePath)
{
RunConfiguration::initialize(id);
m_projectFilePath = projectFilePath;
setDefaultDisplayName(defaultDisplayName());
}
QWidget *BareMetalRunConfiguration::createConfigurationWidget()
{
return new BareMetalRunConfigurationWidget(this);

View File

@@ -37,12 +37,11 @@ class BareMetalRunConfiguration : public ProjectExplorer::RunConfiguration
Q_OBJECT
Q_DISABLE_COPY(BareMetalRunConfiguration)
friend class BareMetalRunConfigurationFactory;
friend class ProjectExplorer::IRunConfigurationFactory;
friend class BareMetalRunConfigurationWidget;
public:
explicit BareMetalRunConfiguration(ProjectExplorer::Target *parent, Core::Id id,
const QString &projectFilePath);
explicit BareMetalRunConfiguration(ProjectExplorer::Target *target);
QWidget *createConfigurationWidget() override;
Utils::OutputFormatter *createOutputFormatter() const override;
@@ -65,13 +64,13 @@ signals:
void targetInformationChanged() const;
protected:
BareMetalRunConfiguration(ProjectExplorer::Target *parent, BareMetalRunConfiguration *source);
bool fromMap(const QVariantMap &map) override;
QString defaultDisplayName();
void initialize(Core::Id id, const QString &projectFilePath);
void copyFrom(const BareMetalRunConfiguration *source);
private:
void handleBuildSystemDataUpdated();
void init();
QString m_projectFilePath;
QString m_workingDirectory;

View File

@@ -107,7 +107,7 @@ RunConfiguration *BareMetalRunConfigurationFactory::doCreate(Target *parent, Cor
{
if (id == BareMetalCustomRunConfiguration::runConfigId())
return new BareMetalCustomRunConfiguration(parent);
return new BareMetalRunConfiguration(parent, id, pathFromId(id));
return createHelper<BareMetalRunConfiguration>(parent, id, pathFromId(id));
}
RunConfiguration *BareMetalRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
@@ -120,10 +120,9 @@ RunConfiguration *BareMetalRunConfigurationFactory::doRestore(Target *parent, co
RunConfiguration *BareMetalRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
{
QTC_ASSERT(canClone(parent, source), return 0);
if (BareMetalCustomRunConfiguration *old = qobject_cast<BareMetalCustomRunConfiguration *>(source))
return new BareMetalCustomRunConfiguration(parent, old);
BareMetalRunConfiguration *old = static_cast<BareMetalRunConfiguration*>(source);
return new BareMetalRunConfiguration(parent,old);
if (qobject_cast<BareMetalCustomRunConfiguration *>(source))
return cloneHelper<BareMetalCustomRunConfiguration>(parent, source);
return cloneHelper<BareMetalRunConfiguration>(parent, source);
}
bool BareMetalRunConfigurationFactory::canHandle(const Target *target) const

View File

@@ -71,8 +71,9 @@ class DummyRunConfiguration : public RunConfiguration
public:
DummyRunConfiguration(Target *parent)
: RunConfiguration(parent, "ClangStaticAnalyzer.DummyRunConfig")
: RunConfiguration(parent)
{
initialize("ClangStaticAnalyzer.DummyRunConfig");
setDefaultDisplayName(tr("Clang Static Analyzer"));
}

View File

@@ -60,35 +60,36 @@ const char CMAKE_RC_PREFIX[] = "CMakeProjectManager.CMakeRunConfiguration.";
const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title";
} // namespace
CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, Core::Id id, const QString &target,
const Utils::FileName &workingDirectory, const QString &title) :
RunConfiguration(parent, id),
m_buildSystemTarget(target),
m_executable(target),
m_title(title)
CMakeRunConfiguration::CMakeRunConfiguration(Target *target)
: RunConfiguration(target)
{
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.Arguments")));
addExtraAspect(new TerminalAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.UseTerminal")));
auto wd = new WorkingDirectoryAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"));
wd->setDefaultWorkingDirectory(workingDirectory);
addExtraAspect(wd);
ctor();
addExtraAspect(new ArgumentsAspect(this, "CMakeProjectManager.CMakeRunConfiguration.Arguments"));
addExtraAspect(new TerminalAspect(this, "CMakeProjectManager.CMakeRunConfiguration.UseTerminal"));
addExtraAspect(new WorkingDirectoryAspect(this, "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"));
}
CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, CMakeRunConfiguration *source) :
RunConfiguration(parent, source),
m_buildSystemTarget(source->m_buildSystemTarget),
m_executable(source->m_executable),
m_title(source->m_title)
void CMakeRunConfiguration::initialize(Core::Id id, const QString &target,
const Utils::FileName &workingDirectory, const QString &title)
{
ctor();
RunConfiguration::initialize(id);
m_buildSystemTarget = target;
m_executable = target;
m_title = title;
extraAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(workingDirectory);
setDefaultDisplayName(defaultDisplayName());
}
void CMakeRunConfiguration::ctor()
void CMakeRunConfiguration::copyFrom(const CMakeRunConfiguration *source)
{
RunConfiguration::copyFrom(source);
m_buildSystemTarget = source->m_buildSystemTarget;
m_executable = source->m_executable;
m_title = source->m_title;
setDefaultDisplayName(defaultDisplayName());
}
@@ -256,7 +257,7 @@ RunConfiguration *CMakeRunConfigurationFactory::doCreate(Target *parent, Core::I
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
const QString title(buildTargetFromId(id));
const CMakeBuildTarget &ct = project->buildTargetForTitle(title);
return new CMakeRunConfiguration(parent, id, title, ct.workingDirectory, ct.title);
return createHelper<CMakeRunConfiguration>(parent, id, title, ct.workingDirectory, ct.title);
}
bool CMakeRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
@@ -270,8 +271,7 @@ RunConfiguration *CMakeRunConfigurationFactory::clone(Target *parent, RunConfigu
{
if (!canClone(parent, source))
return 0;
CMakeRunConfiguration *crc(static_cast<CMakeRunConfiguration *>(source));
return new CMakeRunConfiguration(parent, crc);
return cloneHelper<CMakeRunConfiguration>(parent, source);
}
bool CMakeRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
@@ -284,7 +284,7 @@ bool CMakeRunConfigurationFactory::canRestore(Target *parent, const QVariantMap
RunConfiguration *CMakeRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
{
const Core::Id id = idFromMap(map);
return new CMakeRunConfiguration(parent, id, buildTargetFromId(id), Utils::FileName(), QString());
return createHelper<CMakeRunConfiguration>(parent, id, buildTargetFromId(id), Utils::FileName(), QString());
}
QString CMakeRunConfigurationFactory::buildTargetFromId(Core::Id id)

View File

@@ -35,11 +35,10 @@ class CMakeRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
friend class CMakeRunConfigurationWidget;
friend class CMakeRunConfigurationFactory;
friend class ProjectExplorer::IRunConfigurationFactory;
public:
CMakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &target,
const Utils::FileName &workingDirectory, const QString &title);
explicit CMakeRunConfiguration(ProjectExplorer::Target *target);
ProjectExplorer::Runnable runnable() const override;
QWidget *createConfigurationWidget() override;
@@ -55,18 +54,19 @@ public:
QString buildSystemTarget() const final { return m_buildSystemTarget; }
protected:
CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source);
private:
void initialize(Core::Id id, const QString &target,
const Utils::FileName &workingDirectory, const QString &title);
void copyFrom(const CMakeRunConfiguration *source);
bool fromMap(const QVariantMap &map) override;
QString defaultDisplayName() const;
void updateEnabledState() final;
private:
QString baseWorkingDirectory() const;
void ctor();
const QString m_buildSystemTarget;
QString m_buildSystemTarget;
QString m_executable;
QString m_title;
};

View File

@@ -502,7 +502,7 @@ Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString *
continue;
}
if (!t->activeRunConfiguration())
t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
t->addRunConfiguration(IRunConfigurationFactory::createHelper<CustomExecutableRunConfiguration>(t));
}
m_activeTarget = activeTarget();

View File

@@ -94,30 +94,34 @@ private:
QComboBox *m_deviceTypeComboBox;
};
IosRunConfiguration::IosRunConfiguration(Target *parent, Core::Id id, const FileName &path)
: RunConfiguration(parent, id)
, m_profilePath(path)
IosRunConfiguration::IosRunConfiguration(Target *target)
: RunConfiguration(target)
{
addExtraAspect(new ArgumentsAspect(this, QLatin1String("Ios.run_arguments")));
init();
}
addExtraAspect(new ArgumentsAspect(this, "Ios.run_arguments"));
IosRunConfiguration::IosRunConfiguration(Target *parent, IosRunConfiguration *source)
: RunConfiguration(parent, source)
, m_profilePath(source->m_profilePath)
{
init();
}
void IosRunConfiguration::init()
{
updateDisplayNames();
connect(DeviceManager::instance(), &DeviceManager::updated,
this, &IosRunConfiguration::deviceChanges);
connect(KitManager::instance(), &KitManager::kitsChanged,
this, &IosRunConfiguration::deviceChanges);
}
void IosRunConfiguration::initialize(Core::Id id, const FileName &path)
{
RunConfiguration::initialize(id);
m_profilePath = path;
updateDisplayNames();
}
void IosRunConfiguration::copyFrom(const IosRunConfiguration *source)
{
RunConfiguration::copyFrom(source);
m_profilePath = source->m_profilePath;
updateDisplayNames();
}
void IosRunConfiguration::deviceChanges() {
updateDisplayNames();
updateEnabledState();

View File

@@ -44,10 +44,9 @@ class IosRunConfigurationWidget;
class IosRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
friend class IosRunConfigurationFactory;
public:
IosRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const Utils::FileName &path);
explicit IosRunConfiguration(ProjectExplorer::Target *target);
QWidget *createConfigurationWidget() override;
Utils::OutputFormatter *createOutputFormatter() const override;
@@ -67,15 +66,15 @@ public:
QString buildSystemTarget() const final;
protected:
IosRunConfiguration(ProjectExplorer::Target *parent, IosRunConfiguration *source);
signals:
void localExecutableChanged();
private:
friend class ProjectExplorer::IRunConfigurationFactory;
void initialize(Core::Id id, const Utils::FileName &path);
void copyFrom(const IosRunConfiguration *source);
void deviceChanges();
void init();
friend class IosRunConfigurationWidget;
void updateDisplayNames();
void updateEnabledState() final;

View File

@@ -108,8 +108,7 @@ RunConfiguration *IosRunConfigurationFactory::clone(Target *parent, RunConfigura
if (!canClone(parent, source))
return 0;
IosRunConfiguration *old = qobject_cast<IosRunConfiguration *>(source);
return new IosRunConfiguration(parent, old);
return cloneHelper<IosRunConfiguration>(parent, source);
}
bool IosRunConfigurationFactory::canHandle(Target *t) const
@@ -133,13 +132,13 @@ QList<RunConfiguration *> IosRunConfigurationFactory::runConfigurationsForNode(T
RunConfiguration *IosRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
return new IosRunConfiguration(parent, id, pathFromId(id));
return createHelper<IosRunConfiguration>(parent, id, pathFromId(id));
}
RunConfiguration *IosRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
{
Core::Id id = ProjectExplorer::idFromMap(map);
return new IosRunConfiguration(parent, id, pathFromId(id));
return createHelper<IosRunConfiguration>(parent, id, pathFromId(id));
}
} // namespace Internal

View File

@@ -44,9 +44,8 @@ using namespace Utils;
namespace Nim {
NimRunConfiguration::NimRunConfiguration(Target *parent, Core::Id id)
: RunConfiguration(parent, id)
, m_buildConfiguration(nullptr)
NimRunConfiguration::NimRunConfiguration(Target *target)
: RunConfiguration(target)
, m_workingDirectoryAspect(new WorkingDirectoryAspect(this, Nim::Constants::C_NIMRUNCONFIGURATION_WORKINGDIRECTORYASPECT_ID))
, m_argumentAspect(new ArgumentsAspect(this, Nim::Constants::C_NIMRUNCONFIGURATION_ARGUMENTASPECT_ID))
, m_terminalAspect(new TerminalAspect(this, Nim::Constants::C_NIMRUNCONFIGURATION_TERMINALASPECT_ID))
@@ -62,9 +61,8 @@ NimRunConfiguration::NimRunConfiguration(Target *parent, Core::Id id)
setDefaultDisplayName(tr(Constants::C_NIMRUNCONFIGURATION_DEFAULT_DISPLAY));
// Connect target signals
connect(this->target(), &Target::activeBuildConfigurationChanged,
connect(target, &Target::activeBuildConfigurationChanged,
this, &NimRunConfiguration::updateConfiguration);
updateConfiguration();
}

View File

@@ -43,7 +43,7 @@ class NimRunConfiguration : public ProjectExplorer::RunConfiguration
Q_OBJECT
public:
NimRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
explicit NimRunConfiguration(ProjectExplorer::Target *target);
QWidget *createConfigurationWidget() override;
ProjectExplorer::Runnable runnable() const override;
@@ -65,7 +65,7 @@ private:
void setActiveBuildConfiguration(NimBuildConfiguration *activeBuildConfiguration);
QString m_executable;
NimBuildConfiguration *m_buildConfiguration;
NimBuildConfiguration *m_buildConfiguration = nullptr;
ProjectExplorer::WorkingDirectoryAspect* m_workingDirectoryAspect;
ProjectExplorer::ArgumentsAspect* m_argumentAspect;
ProjectExplorer::TerminalAspect* m_terminalAspect;

View File

@@ -80,7 +80,8 @@ RunConfiguration *NimRunConfigurationFactory::clone(Target *parent, RunConfigura
{
QTC_ASSERT(parent, return nullptr);
QTC_ASSERT(product, return nullptr);
std::unique_ptr<NimRunConfiguration> result(new NimRunConfiguration(parent, Constants::C_NIMRUNCONFIGURATION_ID));
std::unique_ptr<NimRunConfiguration> result(
createHelper<NimRunConfiguration>(parent, Constants::C_NIMRUNCONFIGURATION_ID));
return result->fromMap(product->toMap()) ? result.release() : nullptr;
}
@@ -94,14 +95,13 @@ bool NimRunConfigurationFactory::canHandle(Target *parent) const
RunConfiguration *NimRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
Q_UNUSED(id);
return new NimRunConfiguration(parent, id);
return createHelper<NimRunConfiguration>(parent, id);
}
RunConfiguration *NimRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
{
Q_UNUSED(map);
auto result = new NimRunConfiguration(parent, idFromMap(map));
auto result = createHelper<NimRunConfiguration>(parent, idFromMap(map));
result->fromMap(map);
return result;
}

View File

@@ -52,9 +52,10 @@ static const char BUILDDIRECTORY_KEY[] = "ProjectExplorer.BuildConfiguration.Bui
namespace ProjectExplorer {
BuildConfiguration::BuildConfiguration(Target *target, Core::Id id) :
ProjectConfiguration(target, id),
ProjectConfiguration(target),
m_clearSystemEnvironment(false)
{
initialize(id);
Q_ASSERT(target);
auto bsl = new BuildStepList(this, Core::Id(Constants::BUILDSTEPS_BUILD));
//: Display name of the build build step list. Used as part of the labels in the project window.
@@ -76,11 +77,12 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id) :
}
BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *source) :
ProjectConfiguration(target, source),
ProjectConfiguration(target),
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_buildDirectory(source->m_buildDirectory)
{
copyFrom(source);
Q_ASSERT(target);
// Do not clone stepLists here, do that in the derived constructor instead
// otherwise BuildStepFactories might reject to set up a BuildStep for us

View File

@@ -112,15 +112,17 @@ static const char buildStepEnabledKey[] = "ProjectExplorer.BuildStep.Enabled";
using namespace ProjectExplorer;
BuildStep::BuildStep(BuildStepList *bsl, Core::Id id) :
ProjectConfiguration(bsl, id), m_enabled(true)
ProjectConfiguration(bsl), m_enabled(true)
{
initialize(id);
Q_ASSERT(bsl);
ctor();
}
BuildStep::BuildStep(BuildStepList *bsl, BuildStep *bs) :
ProjectConfiguration(bsl, bs), m_enabled(bs->m_enabled)
ProjectConfiguration(bsl), m_enabled(bs->m_enabled)
{
copyFrom(bs);
Q_ASSERT(bsl);
setDisplayName(bs->displayName());
ctor();

View File

@@ -99,7 +99,7 @@ signals:
private:
void ctor();
bool m_enabled;
bool m_enabled = true;
};
class PROJECTEXPLORER_EXPORT BuildStepInfo

View File

@@ -45,14 +45,16 @@ const char STEPS_PREFIX[] = "ProjectExplorer.BuildStepList.Step.";
} // namespace
BuildStepList::BuildStepList(QObject *parent, Core::Id id) :
ProjectConfiguration(parent, id)
ProjectConfiguration(parent)
{
Q_ASSERT(parent);
initialize(id);
}
BuildStepList::BuildStepList(QObject *parent, BuildStepList *source) :
ProjectConfiguration(parent, source)
ProjectConfiguration(parent)
{
copyFrom(source);
setDisplayName(source->displayName());
Q_ASSERT(parent);
// do not clone the steps here:

View File

@@ -82,32 +82,32 @@ private:
CustomExecutableConfigurationWidget *m_widget;
};
void CustomExecutableRunConfiguration::ctor()
{
setDefaultDisplayName(defaultDisplayName());
}
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *parent) :
RunConfiguration(parent, CUSTOM_EXECUTABLE_ID)
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *target)
: RunConfiguration(target)
{
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new ArgumentsAspect(this, "ProjectExplorer.CustomExecutableRunConfiguration.Arguments"));
addExtraAspect(new TerminalAspect(this, "ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"));
if (parent->activeBuildConfiguration())
}
void CustomExecutableRunConfiguration::initialize()
{
RunConfiguration::initialize(CUSTOM_EXECUTABLE_ID);
if (target()->activeBuildConfiguration())
m_workingDirectory = Constants::DEFAULT_WORKING_DIR;
else
m_workingDirectory = Constants::DEFAULT_WORKING_DIR_ALTERNATE;
ctor();
setDefaultDisplayName(defaultDisplayName());
}
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *parent,
CustomExecutableRunConfiguration *source) :
RunConfiguration(parent, source),
m_executable(source->m_executable),
m_workingDirectory(source->m_workingDirectory)
void CustomExecutableRunConfiguration::copyFrom(const CustomExecutableRunConfiguration *source)
{
ctor();
RunConfiguration::copyFrom(source);
m_executable = source->m_executable;
m_workingDirectory = source->m_workingDirectory;
setDefaultDisplayName(defaultDisplayName());
}
// Note: Qt4Project deletes all empty customexecrunconfigs for which isConfigured() == false.
@@ -336,7 +336,7 @@ RunConfiguration *
CustomExecutableRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
Q_UNUSED(id);
return new CustomExecutableRunConfiguration(parent);
return createHelper<CustomExecutableRunConfiguration>(parent);
}
bool CustomExecutableRunConfigurationFactory::canRestore(Target *parent,
@@ -352,7 +352,7 @@ RunConfiguration *
CustomExecutableRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
{
Q_UNUSED(map);
return new CustomExecutableRunConfiguration(parent);
return createHelper<CustomExecutableRunConfiguration>(parent);
}
bool CustomExecutableRunConfigurationFactory::canClone(Target *parent,
@@ -366,7 +366,7 @@ CustomExecutableRunConfigurationFactory::clone(Target *parent, RunConfiguration
{
if (!canClone(parent, source))
return 0;
return new CustomExecutableRunConfiguration(parent, static_cast<CustomExecutableRunConfiguration*>(source));
return cloneHelper<CustomExecutableRunConfiguration>(parent, source);
}
bool CustomExecutableRunConfigurationFactory::canHandle(Target *parent) const

View File

@@ -35,17 +35,15 @@ class CustomExecutableDialog;
namespace Internal { class CustomExecutableConfigurationWidget; }
class CustomExecutableRunConfigurationFactory;
class PROJECTEXPLORER_EXPORT CustomExecutableRunConfiguration : public RunConfiguration
{
Q_OBJECT
// the configuration widget needs to setExecutable setWorkingDirectory and setCommandLineArguments
friend class Internal::CustomExecutableConfigurationWidget;
friend class CustomExecutableRunConfigurationFactory;
friend class ProjectExplorer::IRunConfigurationFactory;
public:
explicit CustomExecutableRunConfiguration(Target *parent);
explicit CustomExecutableRunConfiguration(Target *target);
~CustomExecutableRunConfiguration() override;
/**
@@ -68,8 +66,8 @@ signals:
void changed();
protected:
CustomExecutableRunConfiguration(Target *parent,
CustomExecutableRunConfiguration *source);
void initialize();
void copyFrom(const CustomExecutableRunConfiguration *source);
virtual bool fromMap(const QVariantMap &map) override;
QString defaultDisplayName() const;

View File

@@ -41,8 +41,9 @@ const char BUILD_STEP_LIST_PREFIX[] = "ProjectExplorer.BuildConfiguration.BuildS
const char DEFAULT_DEPLOYCONFIGURATION_ID[] = "ProjectExplorer.DefaultDeployConfiguration";
DeployConfiguration::DeployConfiguration(Target *target, Core::Id id) :
ProjectConfiguration(target, id)
ProjectConfiguration(target)
{
ProjectConfiguration::initialize(id);
Q_ASSERT(target);
m_stepList = new BuildStepList(this, Core::Id(Constants::BUILDSTEPS_DEPLOY));
//: Display name of the deploy build step list. Used as part of the labels in the project window.
@@ -53,8 +54,9 @@ DeployConfiguration::DeployConfiguration(Target *target, Core::Id id) :
}
DeployConfiguration::DeployConfiguration(Target *target, DeployConfiguration *source) :
ProjectConfiguration(target, source)
ProjectConfiguration(target)
{
ProjectConfiguration::copyFrom(source);
Q_ASSERT(target);
// Do not clone stepLists here, do that in the derived constructor instead
// otherwise BuildStepFactories might reject to set up a BuildStep for us

View File

@@ -31,16 +31,21 @@ const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
const char DEFAULT_DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName";
ProjectConfiguration::ProjectConfiguration(QObject *parent, Core::Id id) : QObject(parent),
m_id(id)
{ setObjectName(id.toString()); }
ProjectConfiguration::ProjectConfiguration(QObject *parent)
: QObject(parent)
{}
ProjectConfiguration::ProjectConfiguration(QObject *parent, const ProjectConfiguration *source) :
QObject(parent),
m_id(source->m_id),
m_defaultDisplayName(source->m_defaultDisplayName)
void ProjectConfiguration::initialize(Core::Id id)
{
m_id = id;
setObjectName(id.toString());
}
void ProjectConfiguration::copyFrom(const ProjectConfiguration *source)
{
Q_ASSERT(source);
m_id = source->m_id;
m_defaultDisplayName = source->m_defaultDisplayName;
m_displayName = tr("Clone of %1").arg(source->displayName());
}
@@ -129,15 +134,15 @@ bool StatefulProjectConfiguration::isEnabled() const
return m_isEnabled;
}
StatefulProjectConfiguration::StatefulProjectConfiguration(QObject *parent, Core::Id id) :
ProjectConfiguration(parent, id)
StatefulProjectConfiguration::StatefulProjectConfiguration(QObject *parent) :
ProjectConfiguration(parent)
{ }
StatefulProjectConfiguration::StatefulProjectConfiguration(QObject *parent,
const StatefulProjectConfiguration *source) :
ProjectConfiguration(parent, source),
m_isEnabled(source->m_isEnabled)
{ }
void StatefulProjectConfiguration::copyFrom(const StatefulProjectConfiguration *source)
{
ProjectConfiguration::copyFrom(source);
m_isEnabled = source->m_isEnabled;
}
void StatefulProjectConfiguration::setEnabled(bool enabled)
{

View File

@@ -74,8 +74,9 @@ signals:
void toolTipChanged();
protected:
ProjectConfiguration(QObject *parent, Core::Id id);
ProjectConfiguration(QObject *parent, const ProjectConfiguration *source);
ProjectConfiguration(QObject *parent);
void initialize(Core::Id id);
void copyFrom(const ProjectConfiguration *source);
private:
Core::Id m_id;
@@ -100,8 +101,8 @@ signals:
void enabledChanged();
protected:
StatefulProjectConfiguration(QObject *parent, Core::Id id);
StatefulProjectConfiguration(QObject *parent, const StatefulProjectConfiguration *source);
StatefulProjectConfiguration(QObject *parent);
void copyFrom(const StatefulProjectConfiguration *source);
void setEnabled(bool enabled);

View File

@@ -189,26 +189,40 @@ void IRunConfigurationAspect::resetProjectToGlobalSettings()
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
RunConfiguration::RunConfiguration(Target *target, Core::Id id) :
StatefulProjectConfiguration(target, id)
RunConfiguration::RunConfiguration(Target *target)
: StatefulProjectConfiguration(target)
{
Q_ASSERT(target);
ctor();
for (const AspectFactory &factory : theAspectFactories)
addExtraAspect(factory(this));
}
connect(target->project(), &Project::parsingStarted,
this, [this]() { updateEnabledState(); });
connect(target->project(), &Project::parsingFinished,
this, [this]() { updateEnabledState(); });
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
StatefulProjectConfiguration(target, source)
{
Q_ASSERT(target);
ctor();
foreach (IRunConfigurationAspect *aspect, source->m_aspects) {
IRunConfigurationAspect *clone = aspect->clone(this);
if (clone)
m_aspects.append(clone);
}
connect(target, &Target::addedRunConfiguration,
this, [this](const RunConfiguration *rc) {
if (rc == this)
updateEnabledState();
});
connect(this, &RunConfiguration::enabledChanged,
this, &RunConfiguration::requestRunActionsUpdate);
Utils::MacroExpander *expander = macroExpander();
expander->setDisplayName(tr("Run Settings"));
expander->setAccumulating(true);
expander->registerSubProvider([target] {
BuildConfiguration *bc = target->activeBuildConfiguration();
return bc ? bc->macroExpander() : target->macroExpander();
});
expander->registerPrefix("CurrentRun:Env", tr("Variables in the current run environment"),
[this](const QString &var) {
const auto envAspect = extraAspect<EnvironmentAspect>();
return envAspect ? envAspect->environment().value(var) : QString();
});
expander->registerVariable(Constants::VAR_CURRENTRUN_NAME,
QCoreApplication::translate("ProjectExplorer", "The currently active run configuration's name."),
[this] { return displayName(); }, false);
}
RunConfiguration::~RunConfiguration()
@@ -216,6 +230,25 @@ RunConfiguration::~RunConfiguration()
qDeleteAll(m_aspects);
}
void RunConfiguration::initialize(Core::Id id)
{
StatefulProjectConfiguration::initialize(id);
for (const AspectFactory &factory : theAspectFactories)
addExtraAspect(factory(this));
}
void RunConfiguration::copyFrom(const RunConfiguration *source)
{
StatefulProjectConfiguration::copyFrom(source);
foreach (IRunConfigurationAspect *aspect, source->m_aspects) {
IRunConfigurationAspect *clone = aspect->clone(this);
if (clone)
m_aspects.append(clone);
}
}
bool RunConfiguration::isActive() const
{
return target()->isActive() && target()->activeRunConfiguration() == this;
@@ -248,39 +281,6 @@ void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect)
m_aspects += aspect;
}
void RunConfiguration::ctor()
{
connect(target()->project(), &Project::parsingStarted,
this, [this]() { updateEnabledState(); });
connect(target()->project(), &Project::parsingFinished,
this, [this]() { updateEnabledState(); });
connect(target(), &Target::addedRunConfiguration,
this, [this](const RunConfiguration *rc) {
if (rc == this)
updateEnabledState();
});
connect(this, &RunConfiguration::enabledChanged,
this, &RunConfiguration::requestRunActionsUpdate);
Utils::MacroExpander *expander = macroExpander();
expander->setDisplayName(tr("Run Settings"));
expander->setAccumulating(true);
expander->registerSubProvider([this]() -> Utils::MacroExpander * {
BuildConfiguration *bc = target()->activeBuildConfiguration();
return bc ? bc->macroExpander() : target()->macroExpander();
});
expander->registerPrefix("CurrentRun:Env", tr("Variables in the current run environment"),
[this](const QString &var) {
const auto envAspect = extraAspect<EnvironmentAspect>();
return envAspect ? envAspect->environment().value(var) : QString();
});
expander->registerVariable(Constants::VAR_CURRENTRUN_NAME,
QCoreApplication::translate("ProjectExplorer", "The currently active run configuration's name."),
[this] { return displayName(); }, false);
}
/*!
* Returns the RunConfiguration of the currently active target
* of the startup project, if such exists, or \c nullptr otherwise.

View File

@@ -259,8 +259,11 @@ signals:
void configurationFinished();
protected:
RunConfiguration(Target *parent, Core::Id id);
RunConfiguration(Target *parent, RunConfiguration *source);
friend class IRunConfigurationFactory;
RunConfiguration(Target *target);
void initialize(Core::Id id);
void copyFrom(const RunConfiguration *source);
/// convenience function to get current build configuration.
BuildConfiguration *activeBuildConfiguration() const;
@@ -268,8 +271,6 @@ protected:
virtual void updateEnabledState();
private:
void ctor();
static void addAspectFactory(const AspectFactory &aspectFactory);
QList<IRunConfigurationAspect *> m_aspects;
@@ -297,6 +298,20 @@ public:
static IRunConfigurationFactory *find(Target *parent, RunConfiguration *rc);
static QList<IRunConfigurationFactory *> find(Target *parent);
template <class RunConfig, typename ...Args>
static RunConfig *createHelper(Target *target, Args ...args) {
auto runConfig = new RunConfig(target);
runConfig->initialize(args...);
return runConfig;
}
template <class RunConfig>
static RunConfig *cloneHelper(Target *target, const RunConfiguration *source) {
auto runConfig = new RunConfig(target);
runConfig->copyFrom(static_cast<const RunConfig *>(source));
return runConfig;
}
signals:
void availableCreationIdsChanged();

View File

@@ -115,9 +115,10 @@ QList<DeployConfigurationFactory *> TargetPrivate::deployFactories() const
}
Target::Target(Project *project, Kit *k) :
ProjectConfiguration(project, k->id()),
ProjectConfiguration(project),
d(new TargetPrivate(k))
{
initialize(k->id());
QTC_CHECK(d->m_kit);
connect(DeviceManager::instance(), &DeviceManager::updated, this, &Target::updateDeviceState);

View File

@@ -151,7 +151,7 @@ class PythonRunConfiguration : public RunConfiguration
Q_PROPERTY(QString arguments READ arguments)
public:
PythonRunConfiguration(Target *parent, Core::Id id);
explicit PythonRunConfiguration(Target *target);
QWidget *createConfigurationWidget() override;
QVariantMap toMap() const override;
@@ -165,8 +165,10 @@ public:
void setInterpreter(const QString &interpreter) { m_interpreter = interpreter; }
private:
friend class PythonRunConfigurationFactory;
PythonRunConfiguration(Target *parent, PythonRunConfiguration *source);
friend class ProjectExplorer::IRunConfigurationFactory;
void initialize(Core::Id id);
void copyFrom(const PythonRunConfiguration *source);
QString defaultDisplayName() const;
QString m_interpreter;
@@ -175,26 +177,31 @@ private:
////////////////////////////////////////////////////////////////
PythonRunConfiguration::PythonRunConfiguration(Target *parent, Core::Id id) :
RunConfiguration(parent, id),
m_mainScript(scriptFromId(id))
PythonRunConfiguration::PythonRunConfiguration(Target *target)
: RunConfiguration(target)
{
Environment sysEnv = Environment::systemEnvironment();
const QString exec = sysEnv.searchInPath("python").toString();
m_interpreter = exec.isEmpty() ? "python" : exec;
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new ArgumentsAspect(this, "PythonEditor.RunConfiguration.Arguments"));
addExtraAspect(new TerminalAspect(this, "PythonEditor.RunConfiguration.UseTerminal"));
setDefaultDisplayName(defaultDisplayName());
}
PythonRunConfiguration::PythonRunConfiguration(Target *parent, PythonRunConfiguration *source) :
RunConfiguration(parent, source),
m_interpreter(source->interpreter()),
m_mainScript(source->m_mainScript)
void PythonRunConfiguration::initialize(Core::Id id)
{
setDefaultDisplayName(defaultDisplayName());
RunConfiguration::initialize(id);
m_mainScript = scriptFromId(id);
Environment sysEnv = Environment::systemEnvironment();
const QString exec = sysEnv.searchInPath("python").toString();
m_interpreter = exec.isEmpty() ? "python" : exec;
}
void PythonRunConfiguration::copyFrom(const PythonRunConfiguration *source)
{
RunConfiguration::copyFrom(source);
m_interpreter = source->interpreter();
m_mainScript = source->m_mainScript;
}
QVariantMap PythonRunConfiguration::toMap() const
@@ -324,7 +331,7 @@ public:
{
if (!canClone(parent, source))
return 0;
return new PythonRunConfiguration(parent, static_cast<PythonRunConfiguration*>(source));
return cloneHelper<PythonRunConfiguration>(parent, source);
}
private:
@@ -332,13 +339,12 @@ private:
RunConfiguration *doCreate(Target *parent, Core::Id id) override
{
return new PythonRunConfiguration(parent, id);
return createHelper<PythonRunConfiguration>(parent, id);
}
RunConfiguration *doRestore(Target *parent, const QVariantMap &map) override
{
Core::Id id(idFromMap(map));
return new PythonRunConfiguration(parent, id);
return createHelper<PythonRunConfiguration>(parent, idFromMap(map));
}
};
@@ -575,7 +581,7 @@ Project::RestoreResult PythonProject::fromMap(const QVariantMap &map, QString *e
}
}
if (!alreadyPresent)
t->addRunConfiguration(new PythonRunConfiguration(t, id));
t->addRunConfiguration(IRunConfigurationFactory::createHelper<PythonRunConfiguration>(t, id));
}
}
}

View File

@@ -107,44 +107,22 @@ const qbs::ProductData findProduct(const qbs::ProjectData &pro, const QString &u
// QbsRunConfiguration:
// --------------------------------------------------------------------
QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
RunConfiguration(parent, id),
m_uniqueProductName(uniqueProductNameFromId(id)),
m_currentInstallStep(0),
m_currentBuildStepList(0)
QbsRunConfiguration::QbsRunConfiguration(Target *target)
: RunConfiguration(target)
{
auto * const envAspect = new LocalEnvironmentAspect(this,
auto envAspect = new LocalEnvironmentAspect(this,
[](RunConfiguration *rc, Environment &env) {
static_cast<QbsRunConfiguration *>(rc)->addToBaseEnvironment(env);
}
);
});
addExtraAspect(envAspect);
connect(static_cast<QbsProject *>(parent->project()), &Project::parsingFinished, this,
connect(static_cast<QbsProject *>(target->project()), &Project::parsingFinished, this,
[envAspect]() { envAspect->buildEnvironmentHasChanged(); });
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qbs.RunConfiguration.CommandLineArguments")));
addExtraAspect(new WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory")));
addExtraAspect(new ArgumentsAspect(this, "Qbs.RunConfiguration.CommandLineArguments"));
addExtraAspect(new WorkingDirectoryAspect(this, "Qbs.RunConfiguration.WorkingDirectory"));
addExtraAspect(new TerminalAspect(this,
QStringLiteral("Qbs.RunConfiguration.UseTerminal"),
isConsoleApplication()));
addExtraAspect(new TerminalAspect(this, "Qbs.RunConfiguration.UseTerminal", isConsoleApplication()));
ctor();
}
QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) :
RunConfiguration(parent, source),
m_uniqueProductName(source->m_uniqueProductName),
m_currentInstallStep(0), // no need to copy this, we will get if from the DC anyway.
m_currentBuildStepList(0) // ditto
{
ctor();
}
void QbsRunConfiguration::ctor()
{
setDefaultDisplayName(defaultDisplayName());
QbsProject *project = static_cast<QbsProject *>(target()->project());
QbsProject *project = static_cast<QbsProject *>(target->project());
connect(project, &Project::parsingFinished, this, [this](bool success) {
auto terminalAspect = extraAspect<TerminalAspect>();
if (success && !terminalAspect->isUserSet())
@@ -157,8 +135,29 @@ void QbsRunConfiguration::ctor()
}
);
connect(target(), &Target::activeDeployConfigurationChanged,
connect(target, &Target::activeDeployConfigurationChanged,
this, &QbsRunConfiguration::installStepChanged);
}
void QbsRunConfiguration::initialize(Core::Id id)
{
m_uniqueProductName = uniqueProductNameFromId(id);
ctor();
}
void QbsRunConfiguration::copyFrom(const QbsRunConfiguration *source)
{
RunConfiguration::copyFrom(source);
m_uniqueProductName = source->m_uniqueProductName;
m_currentInstallStep = nullptr; // no need to copy this, we will get if from the DC anyway.
m_currentBuildStepList = nullptr; // ditto
ctor();
}
void QbsRunConfiguration::ctor()
{
setDefaultDisplayName(defaultDisplayName());
installStepChanged();
}
@@ -377,7 +376,7 @@ bool QbsRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
RunConfiguration *QbsRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
return new QbsRunConfiguration(parent, id);
return createHelper<QbsRunConfiguration>(parent, id);
}
bool QbsRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
@@ -389,7 +388,7 @@ bool QbsRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &m
RunConfiguration *QbsRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
{
return new QbsRunConfiguration(parent, idFromMap(map));
return createHelper<QbsRunConfiguration>(parent, idFromMap(map));
}
bool QbsRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
@@ -401,8 +400,7 @@ RunConfiguration *QbsRunConfigurationFactory::clone(Target *parent, RunConfigura
{
if (!canClone(parent, source))
return 0;
QbsRunConfiguration *old = static_cast<QbsRunConfiguration *>(source);
return new QbsRunConfiguration(parent, old);
return cloneHelper<QbsRunConfiguration>(parent, source);
}
QList<Core::Id> QbsRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const

View File

@@ -31,27 +31,14 @@
#include <QLabel>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QCheckBox;
class QLineEdit;
class QRadioButton;
class QComboBox;
QT_END_NAMESPACE
namespace qbs { class InstallOptions; }
namespace Utils { class PathChooser; }
namespace ProjectExplorer { class BuildStepList; }
namespace QbsProjectManager {
class QbsProject;
namespace Internal {
class QbsInstallStep;
class QbsRunConfigurationFactory;
class QbsRunConfiguration : public ProjectExplorer::RunConfiguration
{
@@ -59,10 +46,10 @@ class QbsRunConfiguration : public ProjectExplorer::RunConfiguration
// to change the display name and arguments and set the userenvironmentchanges
friend class QbsRunConfigurationWidget;
friend class QbsRunConfigurationFactory;
friend class ProjectExplorer::IRunConfigurationFactory;
public:
QbsRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
explicit QbsRunConfiguration(ProjectExplorer::Target *target);
QWidget *createConfigurationWidget() override;
@@ -81,10 +68,11 @@ signals:
void targetInformationChanged();
void usingDyldImageSuffixChanged(bool);
protected:
QbsRunConfiguration(ProjectExplorer::Target *parent, QbsRunConfiguration *source);
private:
void initialize(Core::Id id);
void copyFrom(const QbsRunConfiguration *source);
void installStepChanged();
void installStepToBeRemoved(int pos);
QString baseWorkingDirectory() const;
@@ -96,8 +84,8 @@ private:
QString m_uniqueProductName;
QbsInstallStep *m_currentInstallStep; // We do not take ownership!
ProjectExplorer::BuildStepList *m_currentBuildStepList; // We do not take ownership!
QbsInstallStep *m_currentInstallStep = nullptr; // We do not take ownership!
ProjectExplorer::BuildStepList *m_currentBuildStepList = nullptr; // We do not take ownership!
};
class QbsRunConfigurationWidget : public QWidget

View File

@@ -54,17 +54,23 @@ static QString pathFromId(const Core::Id id)
return id.suffixAfter(ANDROID_RC_ID_PREFIX);
}
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, Core::Id id, const Utils::FileName &path)
: AndroidRunConfiguration(parent, id)
, m_proFilePath(path)
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *target)
: AndroidRunConfiguration(target)
{}
void QmakeAndroidRunConfiguration::initialize(Core::Id id, const Utils::FileName &path)
{
AndroidRunConfiguration::initialize(id);
m_proFilePath = path;
ctor();
}
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, QmakeAndroidRunConfiguration *source)
: AndroidRunConfiguration(parent, source)
, m_proFilePath(source->m_proFilePath)
void QmakeAndroidRunConfiguration::copyFrom(const QmakeAndroidRunConfiguration *source)
{
AndroidRunConfiguration::copyFrom(source);
m_proFilePath = source->m_proFilePath;
ctor();
}

View File

@@ -40,11 +40,9 @@ namespace Internal {
class QmakeAndroidRunConfiguration : public Android::AndroidRunConfiguration
{
Q_OBJECT
friend class QmakeAndroidRunConfigurationFactory;
public:
QmakeAndroidRunConfiguration(ProjectExplorer::Target *parent, Core::Id id,
const Utils::FileName &path = Utils::FileName());
explicit QmakeAndroidRunConfiguration(ProjectExplorer::Target *target);
Utils::FileName proFilePath() const;
@@ -52,14 +50,15 @@ public:
QString buildSystemTarget() const final;
protected:
QmakeAndroidRunConfiguration(ProjectExplorer::Target *parent, QmakeAndroidRunConfiguration *source);
private:
friend class ProjectExplorer::IRunConfigurationFactory;
void initialize(Core::Id id, const Utils::FileName &path = Utils::FileName());
void copyFrom(const QmakeAndroidRunConfiguration *source);
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
QString defaultDisplayName();
private:
QmakeProjectManager::QmakeProject *qmakeProject() const;
void ctor();

View File

@@ -93,8 +93,8 @@ QList<Core::Id> QmakeAndroidRunConfigurationFactory::availableCreationIds(Target
RunConfiguration *QmakeAndroidRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
if (parent->project()->rootProjectNode())
return new QmakeAndroidRunConfiguration(parent, id, pathFromId(id));
return new QmakeAndroidRunConfiguration(parent, id);
return createHelper<QmakeAndroidRunConfiguration>(parent, id, pathFromId(id));
return createHelper<QmakeAndroidRunConfiguration>(parent, id);
}
RunConfiguration *QmakeAndroidRunConfigurationFactory::doRestore(Target *parent,
@@ -102,17 +102,15 @@ RunConfiguration *QmakeAndroidRunConfigurationFactory::doRestore(Target *parent,
{
Core::Id id = ProjectExplorer::idFromMap(map);
if (parent->project()->rootProjectNode())
return new QmakeAndroidRunConfiguration(parent, id);
return new QmakeAndroidRunConfiguration(parent, id);
return createHelper<QmakeAndroidRunConfiguration>(parent, id);
return createHelper<QmakeAndroidRunConfiguration>(parent, id);
}
RunConfiguration *QmakeAndroidRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
{
if (!canClone(parent, source))
return 0;
QmakeAndroidRunConfiguration *old = static_cast<QmakeAndroidRunConfiguration *>(source);
return new QmakeAndroidRunConfiguration(parent, old);
return cloneHelper<QmakeAndroidRunConfiguration>(parent, source);
}
bool QmakeAndroidRunConfigurationFactory::canHandle(Target *t) const

View File

@@ -76,27 +76,32 @@ static Utils::FileName pathFromId(Core::Id id)
// QmakeRunConfiguration
//
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Core::Id id) :
RunConfiguration(parent, id),
m_proFilePath(pathFromId(id))
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target)
: RunConfiguration(target)
{
addExtraAspect(new LocalEnvironmentAspect(this, [](RunConfiguration *rc, Environment &env) {
static_cast<DesktopQmakeRunConfiguration *>(rc)->addToBaseEnvironment(env);
}));
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments")));
addExtraAspect(new TerminalAspect(this, QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.UseTerminal")));
addExtraAspect(new WorkingDirectoryAspect(this,
QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory")));
addExtraAspect(new ArgumentsAspect(this, "Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"));
addExtraAspect(new TerminalAspect(this, "Qt4ProjectManager.Qt4RunConfiguration.UseTerminal"));
addExtraAspect(new WorkingDirectoryAspect(this, "Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"));
}
void DesktopQmakeRunConfiguration::initialize(Core::Id id)
{
RunConfiguration::initialize(id);
m_proFilePath = pathFromId(id);
ctor();
}
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, DesktopQmakeRunConfiguration *source) :
RunConfiguration(parent, source),
m_proFilePath(source->m_proFilePath),
m_isUsingDyldImageSuffix(source->m_isUsingDyldImageSuffix),
m_isUsingLibrarySearchPath(source->m_isUsingLibrarySearchPath)
void DesktopQmakeRunConfiguration::copyFrom(const DesktopQmakeRunConfiguration *source)
{
RunConfiguration::copyFrom(source);
m_proFilePath = source->m_proFilePath;
m_isUsingDyldImageSuffix = source->m_isUsingDyldImageSuffix;
m_isUsingLibrarySearchPath = source->m_isUsingLibrarySearchPath;
ctor();
}
@@ -464,7 +469,7 @@ bool DesktopQmakeRunConfigurationFactory::canCreate(Target *parent, Core::Id id)
RunConfiguration *DesktopQmakeRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
return new DesktopQmakeRunConfiguration(parent, id);
return createHelper<DesktopQmakeRunConfiguration>(parent, id);
}
bool DesktopQmakeRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
@@ -476,7 +481,7 @@ bool DesktopQmakeRunConfigurationFactory::canRestore(Target *parent, const QVari
RunConfiguration *DesktopQmakeRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
{
return new DesktopQmakeRunConfiguration(parent, idFromMap(map));
return createHelper<DesktopQmakeRunConfiguration>(parent, idFromMap(map));
}
bool DesktopQmakeRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
@@ -488,8 +493,7 @@ RunConfiguration *DesktopQmakeRunConfigurationFactory::clone(Target *parent, Run
{
if (!canClone(parent, source))
return 0;
DesktopQmakeRunConfiguration *old = static_cast<DesktopQmakeRunConfiguration *>(source);
return new DesktopQmakeRunConfiguration(parent, old);
return cloneHelper<DesktopQmakeRunConfiguration>(parent, source);
}
QList<Core::Id> DesktopQmakeRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const

View File

@@ -53,10 +53,10 @@ class DesktopQmakeRunConfiguration : public ProjectExplorer::RunConfiguration
Q_OBJECT
// to change the display name and arguments and set the userenvironmentchanges
friend class DesktopQmakeRunConfigurationWidget;
friend class DesktopQmakeRunConfigurationFactory;
friend class ProjectExplorer::IRunConfigurationFactory;
public:
DesktopQmakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
explicit DesktopQmakeRunConfiguration(ProjectExplorer::Target *target);
QWidget *createConfigurationWidget() override;
@@ -88,7 +88,9 @@ signals:
void effectiveTargetInformationChanged();
protected:
DesktopQmakeRunConfiguration(ProjectExplorer::Target *parent, DesktopQmakeRunConfiguration *source);
void initialize(Core::Id id);
void copyFrom(const DesktopQmakeRunConfiguration *source);
bool fromMap(const QVariantMap &map) override;
private:

View File

@@ -51,13 +51,43 @@ namespace QmlProjectManager {
const char M_CURRENT_FILE[] = "CurrentFile";
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent, Id id) :
RunConfiguration(parent, id),
m_scriptFile(QLatin1String(M_CURRENT_FILE))
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target)
: RunConfiguration(target)
{
addExtraAspect(new QmlProjectEnvironmentAspect(this));
ctor();
// reset default settings in constructor
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
this, &QmlProjectRunConfiguration::changeCurrentFile);
connect(EditorManager::instance(), &EditorManager::currentDocumentStateChanged,
this, [this] { changeCurrentFile(); });
connect(target, &Target::kitChanged,
this, &QmlProjectRunConfiguration::updateEnabledState);
}
void QmlProjectRunConfiguration::initialize(Id id)
{
RunConfiguration::initialize(id);
m_scriptFile = M_CURRENT_FILE;
if (id == Constants::QML_SCENE_RC_ID)
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
else
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
updateEnabledState();
}
void QmlProjectRunConfiguration::copyFrom(const QmlProjectRunConfiguration *source)
{
RunConfiguration::copyFrom(source);
m_currentFileFilename = source->m_currentFileFilename;
m_mainScriptFilename = source->m_mainScriptFilename;
m_scriptFile = source->m_scriptFile;
m_qmlViewerArgs = source->m_qmlViewerArgs;
updateEnabledState();
}
Runnable QmlProjectRunConfiguration::runnable() const
@@ -72,17 +102,6 @@ Runnable QmlProjectRunConfiguration::runnable() const
return r;
}
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent,
QmlProjectRunConfiguration *source) :
RunConfiguration(parent, source),
m_currentFileFilename(source->m_currentFileFilename),
m_mainScriptFilename(source->m_mainScriptFilename),
m_scriptFile(source->m_scriptFile),
m_qmlViewerArgs(source->m_qmlViewerArgs)
{
ctor();
}
QString QmlProjectRunConfiguration::disabledReason() const
{
if (mainScript().isEmpty())
@@ -92,24 +111,6 @@ QString QmlProjectRunConfiguration::disabledReason() const
return RunConfiguration::disabledReason();
}
void QmlProjectRunConfiguration::ctor()
{
// reset default settings in constructor
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
this, &QmlProjectRunConfiguration::changeCurrentFile);
connect(EditorManager::instance(), &EditorManager::currentDocumentStateChanged,
this, [this] { changeCurrentFile(); });
connect(target(), &Target::kitChanged,
this, &QmlProjectRunConfiguration::updateEnabledState);
if (id() == Constants::QML_SCENE_RC_ID)
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
else
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
updateEnabledState();
}
QString QmlProjectRunConfiguration::executable() const
{
QtSupport::BaseQtVersion *version = qtVersion();

View File

@@ -40,20 +40,17 @@ namespace QtSupport { class BaseQtVersion; }
namespace QmlProjectManager {
class QmlProject;
namespace Internal {
class QmlProjectRunConfigurationFactory;
class QmlProjectRunConfigurationWidget;
}
namespace Internal { class QmlProjectRunConfigurationWidget; }
class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
friend class Internal::QmlProjectRunConfigurationFactory;
friend class ProjectExplorer::IRunConfigurationFactory;
friend class Internal::QmlProjectRunConfigurationWidget;
friend class QmlProject; // to call updateEnabled()
public:
QmlProjectRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
explicit QmlProjectRunConfiguration(ProjectExplorer::Target *target);
ProjectExplorer::Runnable runnable() const override;
@@ -79,13 +76,10 @@ public:
signals:
void scriptSourceChanged();
protected:
QmlProjectRunConfiguration(ProjectExplorer::Target *parent,
QmlProjectRunConfiguration *source);
virtual bool fromMap(const QVariantMap &map) override;
private:
void ctor();
void initialize(Core::Id id);
void copyFrom(const QmlProjectRunConfiguration *source);
virtual bool fromMap(const QVariantMap &map) override;
void changeCurrentFile(Core::IEditor* = 0);
void updateEnabledState() final;

View File

@@ -104,7 +104,7 @@ bool QmlProjectRunConfigurationFactory::canCreate(ProjectExplorer::Target *paren
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, Core::Id id)
{
return new QmlProjectRunConfiguration(parent, id);
return createHelper<QmlProjectRunConfiguration>(parent, id);
}
bool QmlProjectRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
@@ -115,7 +115,7 @@ bool QmlProjectRunConfigurationFactory::canRestore(ProjectExplorer::Target *pare
ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::doRestore(ProjectExplorer::Target *parent,
const QVariantMap &map)
{
return new QmlProjectRunConfiguration(parent, ProjectExplorer::idFromMap(map));
return createHelper<QmlProjectRunConfiguration>(parent, ProjectExplorer::idFromMap(map));
}
bool QmlProjectRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
@@ -128,7 +128,7 @@ ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::clone(Proj
{
if (!canClone(parent, source))
return 0;
return new QmlProjectRunConfiguration(parent, qobject_cast<QmlProjectRunConfiguration *>(source));
return cloneHelper<QmlProjectRunConfiguration>(parent, source);
}
bool QmlProjectRunConfigurationFactory::canHandle(ProjectExplorer::Target *parent) const

View File

@@ -41,14 +41,19 @@ namespace Internal {
const char QtLibPathKey[] = "Qt4ProjectManager.QnxRunConfiguration.QtLibPath";
QnxRunConfiguration::QnxRunConfiguration(Target *parent, Core::Id id, const QString &targetName)
: RemoteLinuxRunConfiguration(parent, id, targetName)
QnxRunConfiguration::QnxRunConfiguration(Target *target)
: RemoteLinuxRunConfiguration(target)
{}
void QnxRunConfiguration::initialize(Core::Id id, const QString &targetName)
{
RemoteLinuxRunConfiguration::initialize(id, targetName);
}
QnxRunConfiguration::QnxRunConfiguration(Target *parent, QnxRunConfiguration *source)
: RemoteLinuxRunConfiguration(parent, source), m_qtLibPath(source->m_qtLibPath)
void QnxRunConfiguration::copyFrom(const QnxRunConfiguration *source)
{
RemoteLinuxRunConfiguration::copyFrom(source);
m_qtLibPath = source->m_qtLibPath;
}
Runnable QnxRunConfiguration::runnable() const

View File

@@ -35,8 +35,7 @@ class QnxRunConfiguration : public RemoteLinux::RemoteLinuxRunConfiguration
Q_OBJECT
public:
QnxRunConfiguration(ProjectExplorer::Target *parent, Core::Id id,
const QString &targetName);
explicit QnxRunConfiguration(ProjectExplorer::Target *target);
ProjectExplorer::Runnable runnable() const override;
@@ -44,9 +43,11 @@ public:
QVariantMap toMap() const override;
private:
friend class QnxRunConfigurationFactory;
friend class ProjectExplorer::IRunConfigurationFactory;
void copyFrom(const QnxRunConfiguration *source);
void initialize(Core::Id id, const QString &targetName);
QnxRunConfiguration(ProjectExplorer::Target *parent, QnxRunConfiguration *source);
bool fromMap(const QVariantMap &map) override;
QString m_qtLibPath;

View File

@@ -91,7 +91,7 @@ ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::doCreate(ProjectE
QTC_ASSERT(project, return nullptr);
for (const QmakeProjectManager::QmakeProFile *file : project->applicationProFiles()) {
if (file->filePath() == projectFilePath)
return new QnxRunConfiguration(parent, id, file->targetInformation().target);
return createHelper<QnxRunConfiguration>(parent, id, file->targetInformation().target);
}
QTC_CHECK(false);
return nullptr;
@@ -107,7 +107,7 @@ ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::doRestore(Project
const QVariantMap &map)
{
Q_UNUSED(map);
return new QnxRunConfiguration(parent, Core::Id(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX), QString());
return createHelper<QnxRunConfiguration>(parent, Constants::QNX_QNX_RUNCONFIGURATION_PREFIX, QString());
}
bool QnxRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
@@ -120,8 +120,7 @@ ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::clone(ProjectExpl
if (!canClone(parent, source))
return 0;
QnxRunConfiguration *old = static_cast<QnxRunConfiguration *>(source);
return new QnxRunConfiguration(parent, old);
return cloneHelper<QnxRunConfiguration>(parent, source);
}
bool QnxRunConfigurationFactory::canHandle(ProjectExplorer::Target *t) const

View File

@@ -96,21 +96,29 @@ private:
Ui::RemoteLinuxCustomRunConfigurationWidget m_ui;
};
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(ProjectExplorer::Target *parent)
: RunConfiguration(parent, runConfigId())
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target)
: RunConfiguration(target)
{
init();
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
}
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(ProjectExplorer::Target *parent,
RemoteLinuxCustomRunConfiguration *source)
: RunConfiguration(parent, source)
, m_localExecutable(source->m_localExecutable)
, m_remoteExecutable(source->m_remoteExecutable)
, m_arguments(source->m_arguments)
, m_workingDirectory(source->m_workingDirectory)
void RemoteLinuxCustomRunConfiguration::initialize()
{
init();
RunConfiguration::initialize(runConfigId());
setDefaultDisplayName(runConfigDefaultDisplayName());
}
void RemoteLinuxCustomRunConfiguration::copyFrom(const RemoteLinuxCustomRunConfiguration *source)
{
RunConfiguration::copyFrom(source);
m_localExecutable = source->m_localExecutable;
m_remoteExecutable = source->m_remoteExecutable;
m_arguments = source->m_arguments;
m_workingDirectory = source->m_workingDirectory;
setDefaultDisplayName(runConfigDefaultDisplayName());
}
bool RemoteLinuxCustomRunConfiguration::isConfigured() const
@@ -167,12 +175,6 @@ QString RemoteLinuxCustomRunConfiguration::runConfigDefaultDisplayName()
return tr("Custom Executable (on Remote Generic Linux Host)");
}
void RemoteLinuxCustomRunConfiguration::init()
{
setDefaultDisplayName(runConfigDefaultDisplayName());
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
}
static QString localExeKey()
{
return QLatin1String("RemoteLinux.CustomRunConfig.LocalExecutable");

View File

@@ -34,9 +34,10 @@ class RemoteLinuxCustomRunConfiguration : public ProjectExplorer::RunConfigurati
{
Q_OBJECT
public:
RemoteLinuxCustomRunConfiguration(ProjectExplorer::Target *parent);
RemoteLinuxCustomRunConfiguration(ProjectExplorer::Target *parent,
RemoteLinuxCustomRunConfiguration *source);
explicit RemoteLinuxCustomRunConfiguration(ProjectExplorer::Target *target);
void initialize();
void copyFrom(const RemoteLinuxCustomRunConfiguration *source);
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
@@ -57,8 +58,6 @@ public:
static QString runConfigDefaultDisplayName();
private:
void init();
QString m_localExecutable;
QString m_remoteExecutable;
QString m_arguments;

View File

@@ -51,26 +51,12 @@ const char WorkingDirectoryKey[] = "RemoteLinux.RunConfig.WorkingDirectory";
} // anonymous namespace
class RemoteLinuxRunConfigurationPrivate {
class RemoteLinuxRunConfigurationPrivate
{
public:
RemoteLinuxRunConfigurationPrivate(const QString &targetName)
: targetName(targetName),
useAlternateRemoteExecutable(false)
{
}
RemoteLinuxRunConfigurationPrivate(const RemoteLinuxRunConfigurationPrivate *other)
: targetName(other->targetName),
arguments(other->arguments),
useAlternateRemoteExecutable(other->useAlternateRemoteExecutable),
alternateRemoteExecutable(other->alternateRemoteExecutable),
workingDirectory(other->workingDirectory)
{
}
QString targetName;
QString arguments;
bool useAlternateRemoteExecutable;
bool useAlternateRemoteExecutable = false;
QString alternateRemoteExecutable;
QString workingDirectory;
};
@@ -79,20 +65,35 @@ public:
using namespace Internal;
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *parent, Core::Id id,
const QString &targetName)
: RunConfiguration(parent, id),
d(new RemoteLinuxRunConfigurationPrivate(targetName))
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target)
: RunConfiguration(target), d(new RemoteLinuxRunConfigurationPrivate)
{
init();
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
connect(target, &Target::deploymentDataChanged,
this, &RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated);
connect(target, &Target::applicationTargetsChanged,
this, &RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated);
// Handles device changes, etc.
connect(target, &Target::kitChanged,
this, &RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated);
}
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *parent,
RemoteLinuxRunConfiguration *source)
: RunConfiguration(parent, source),
d(new RemoteLinuxRunConfigurationPrivate(source->d))
void RemoteLinuxRunConfiguration::initialize(Core::Id id, const QString &targetName)
{
init();
RunConfiguration::initialize(id);
d->targetName = targetName;
setDefaultDisplayName(defaultDisplayName());
}
void RemoteLinuxRunConfiguration::copyFrom(const RemoteLinuxRunConfiguration *source)
{
RunConfiguration::copyFrom(source);
*d = *source->d;
setDefaultDisplayName(defaultDisplayName());
}
RemoteLinuxRunConfiguration::~RemoteLinuxRunConfiguration()
@@ -100,21 +101,6 @@ RemoteLinuxRunConfiguration::~RemoteLinuxRunConfiguration()
delete d;
}
void RemoteLinuxRunConfiguration::init()
{
setDefaultDisplayName(defaultDisplayName());
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
connect(target(), &Target::deploymentDataChanged,
this, &RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated);
connect(target(), &Target::applicationTargetsChanged,
this, &RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated);
// Handles device changes, etc.
connect(target(), &Target::kitChanged,
this, &RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated);
}
QWidget *RemoteLinuxRunConfiguration::createConfigurationWidget()
{
return new RemoteLinuxRunConfigurationWidget(this);

View File

@@ -34,21 +34,16 @@
namespace RemoteLinux {
class RemoteLinuxRunConfigurationWidget;
namespace Internal {
class RemoteLinuxRunConfigurationPrivate;
class RemoteLinuxRunConfigurationFactory;
} // namespace Internal
namespace Internal { class RemoteLinuxRunConfigurationPrivate; }
class REMOTELINUX_EXPORT RemoteLinuxRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
Q_DISABLE_COPY(RemoteLinuxRunConfiguration)
friend class Internal::RemoteLinuxRunConfigurationFactory;
friend class RemoteLinuxRunConfigurationWidget;
friend class ProjectExplorer::IRunConfigurationFactory;
public:
RemoteLinuxRunConfiguration(ProjectExplorer::Target *parent, Core::Id id,
const QString &targetName);
explicit RemoteLinuxRunConfiguration(ProjectExplorer::Target *target);
~RemoteLinuxRunConfiguration() override;
QWidget *createConfigurationWidget() override;
@@ -79,14 +74,14 @@ signals:
void targetInformationChanged() const;
protected:
RemoteLinuxRunConfiguration(ProjectExplorer::Target *parent,
RemoteLinuxRunConfiguration *source);
void initialize(Core::Id id, const QString &targetName);
void copyFrom(const RemoteLinuxRunConfiguration *source);
bool fromMap(const QVariantMap &map) override;
QString defaultDisplayName();
private:
void handleBuildSystemDataUpdated();
void init();
Internal::RemoteLinuxRunConfigurationPrivate * const d;
};

View File

@@ -107,27 +107,25 @@ QString RemoteLinuxRunConfigurationFactory::displayNameForId(Core::Id id) const
RunConfiguration *RemoteLinuxRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
if (id == RemoteLinuxCustomRunConfiguration::runConfigId())
return new RemoteLinuxCustomRunConfiguration(parent);
return new RemoteLinuxRunConfiguration(parent, id, stringFromId(id));
return createHelper<RemoteLinuxCustomRunConfiguration>(parent);
return createHelper<RemoteLinuxRunConfiguration>(parent, id, stringFromId(id));
}
RunConfiguration *RemoteLinuxRunConfigurationFactory::doRestore(Target *parent,
const QVariantMap &map)
{
if (idFromMap(map) == RemoteLinuxCustomRunConfiguration::runConfigId())
return new RemoteLinuxCustomRunConfiguration(parent);
return new RemoteLinuxRunConfiguration(parent,
Core::Id(RemoteLinuxRunConfiguration::IdPrefix), QString());
return createHelper<RemoteLinuxCustomRunConfiguration>(parent);
return createHelper<RemoteLinuxRunConfiguration>(parent, RemoteLinuxRunConfiguration::IdPrefix, QString());
}
RunConfiguration *RemoteLinuxRunConfigurationFactory::clone(Target *parent,
RunConfiguration *source)
{
QTC_ASSERT(canClone(parent, source), return 0);
if (RemoteLinuxCustomRunConfiguration *old = qobject_cast<RemoteLinuxCustomRunConfiguration *>(source))
return new RemoteLinuxCustomRunConfiguration(parent, old);
RemoteLinuxRunConfiguration *old = static_cast<RemoteLinuxRunConfiguration *>(source);
return new RemoteLinuxRunConfiguration(parent, old);
if (qobject_cast<RemoteLinuxCustomRunConfiguration *>(source))
return cloneHelper<RemoteLinuxCustomRunConfiguration>(parent, source);
return cloneHelper<RemoteLinuxRunConfiguration>(parent, source);
}
bool RemoteLinuxRunConfigurationFactory::canHandle(const Target *target) const

View File

@@ -44,14 +44,16 @@ static QString pathFromId(Core::Id id)
return id.suffixAfter(Constants::WINRT_RC_PREFIX);
}
WinRtRunConfiguration::WinRtRunConfiguration(ProjectExplorer::Target *parent, Core::Id id)
: RunConfiguration(parent, id)
, m_proFilePath(pathFromId(id))
, m_uninstallAfterStop(false)
WinRtRunConfiguration::WinRtRunConfiguration(ProjectExplorer::Target *target)
: RunConfiguration(target)
{
setDisplayName(tr("Run App Package"));
addExtraAspect(new ProjectExplorer::ArgumentsAspect(this,
QLatin1String("WinRtRunConfigurationArgumentsId")));
addExtraAspect(new ProjectExplorer::ArgumentsAspect(this, "WinRtRunConfigurationArgumentsId"));
}
void WinRtRunConfiguration::initialize(Core::Id id)
{
m_proFilePath = pathFromId(id);
}
QWidget *WinRtRunConfiguration::createConfigurationWidget()

View File

@@ -35,7 +35,7 @@ class WinRtRunConfiguration : public ProjectExplorer::RunConfiguration
Q_OBJECT
public:
explicit WinRtRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
explicit WinRtRunConfiguration(ProjectExplorer::Target *target);
QWidget *createConfigurationWidget() override;
QVariantMap toMap() const override;
@@ -53,8 +53,11 @@ signals:
void uninstallAfterStopChanged(bool);
private:
friend class ProjectExplorer::IRunConfigurationFactory;
void initialize(Core::Id id);
QString m_proFilePath;
bool m_uninstallAfterStop;
bool m_uninstallAfterStop = false;
};
} // namespace Internal

View File

@@ -81,7 +81,7 @@ bool WinRtRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
RunConfiguration *WinRtRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
return new WinRtRunConfiguration(parent, id);
return createHelper<WinRtRunConfiguration>(parent, id);
}
bool WinRtRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
@@ -94,9 +94,7 @@ bool WinRtRunConfigurationFactory::canRestore(Target *parent, const QVariantMap
RunConfiguration *WinRtRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
{
RunConfiguration *config = new WinRtRunConfiguration(parent, idFromMap(map));
config->fromMap(map);
return config;
return createHelper<WinRtRunConfiguration>(parent, idFromMap(map));
}
bool WinRtRunConfigurationFactory::canClone(Target *parent, RunConfiguration *product) const