forked from qt-creator/qt-creator
CMakeProjectManager: Hide kit aspect factory implementation
Also avoid re-instantiation of factories in the build configurations. Closer to the setups of the other kit aspect(factories). Change-Id: I1b74a68287b63ee94ff18106d3a00b23624a601b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -215,7 +215,9 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
||||
m_kitConfiguration = new QPushButton(Tr::tr("Kit Configuration"));
|
||||
m_kitConfiguration->setToolTip(Tr::tr("Edit the current kit's CMake configuration."));
|
||||
m_kitConfiguration->setFixedWidth(m_kitConfiguration->sizeHint().width());
|
||||
connect(m_kitConfiguration, &QPushButton::clicked, this, [this] { kitCMakeConfiguration(); });
|
||||
connect(m_kitConfiguration, &QPushButton::clicked,
|
||||
this, &CMakeBuildSettingsWidget::kitCMakeConfiguration,
|
||||
Qt::QueuedConnection);
|
||||
|
||||
m_filterEdit = new FancyLineEdit;
|
||||
m_filterEdit->setPlaceholderText(Tr::tr("Filter"));
|
||||
@@ -646,18 +648,14 @@ void CMakeBuildSettingsWidget::kitCMakeConfiguration()
|
||||
m_buildConfig->kit()->unblockNotification();
|
||||
});
|
||||
|
||||
CMakeKitAspectFactory kitAspectFactory;
|
||||
CMakeGeneratorKitAspectFactory generatorAspectFactory;
|
||||
CMakeConfigurationKitAspectFactory configurationKitAspectFactory;
|
||||
|
||||
Layouting::Grid grid;
|
||||
KitAspect *widget = kitAspectFactory.createKitAspect(m_buildConfig->kit());
|
||||
KitAspect *widget = CMakeKitAspect::createKitAspect(m_buildConfig->kit());
|
||||
widget->setParent(dialog);
|
||||
widget->addToLayoutWithLabel(grid, dialog);
|
||||
widget = generatorAspectFactory.createKitAspect(m_buildConfig->kit());
|
||||
widget = CMakeGeneratorKitAspect::createKitAspect(m_buildConfig->kit());
|
||||
widget->setParent(dialog);
|
||||
widget->addToLayoutWithLabel(grid, dialog);
|
||||
widget = configurationKitAspectFactory.createKitAspect(m_buildConfig->kit());
|
||||
widget = CMakeConfigurationKitAspect::createKitAspect(m_buildConfig->kit());
|
||||
widget->setParent(dialog);
|
||||
widget->addToLayoutWithLabel(grid, dialog);
|
||||
grid.attachTo(dialog);
|
||||
|
@@ -63,6 +63,60 @@ static Id defaultCMakeToolId()
|
||||
return defaultTool ? defaultTool->id() : Id();
|
||||
}
|
||||
|
||||
// Factories
|
||||
|
||||
class CMakeKitAspectFactory : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeKitAspectFactory();
|
||||
|
||||
// KitAspect interface
|
||||
Tasks validate(const Kit *k) const final;
|
||||
void setup(Kit *k) final;
|
||||
void fix(Kit *k) final;
|
||||
ItemList toUserOutput(const Kit *k) const final;
|
||||
KitAspect *createKitAspect(Kit *k) const final;
|
||||
|
||||
void addToMacroExpander(Kit *k, Utils::MacroExpander *expander) const final;
|
||||
|
||||
QSet<Utils::Id> availableFeatures(const Kit *k) const final;
|
||||
};
|
||||
|
||||
class CMakeGeneratorKitAspectFactory : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeGeneratorKitAspectFactory();
|
||||
|
||||
Tasks validate(const Kit *k) const final;
|
||||
void setup(Kit *k) final;
|
||||
void fix(Kit *k) final;
|
||||
void upgrade(Kit *k) final;
|
||||
ItemList toUserOutput(const Kit *k) const final;
|
||||
KitAspect *createKitAspect(Kit *k) const final;
|
||||
void addToBuildEnvironment(const Kit *k, Utils::Environment &env) const final;
|
||||
|
||||
private:
|
||||
QVariant defaultValue(const Kit *k) const;
|
||||
};
|
||||
|
||||
class CMakeConfigurationKitAspectFactory : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeConfigurationKitAspectFactory();
|
||||
|
||||
// KitAspect interface
|
||||
Tasks validate(const Kit *k) const final;
|
||||
void setup(Kit *k) final;
|
||||
void fix(Kit *k) final;
|
||||
ItemList toUserOutput(const Kit *k) const final;
|
||||
KitAspect *createKitAspect(Kit *k) const final;
|
||||
|
||||
private:
|
||||
QVariant defaultValue(const Kit *k) const;
|
||||
};
|
||||
|
||||
// Implementations
|
||||
|
||||
class CMakeKitAspectImpl final : public KitAspect
|
||||
{
|
||||
public:
|
||||
@@ -602,7 +656,7 @@ QStringList CMakeGeneratorKitAspect::generatorArguments(const Kit *k)
|
||||
return result;
|
||||
}
|
||||
|
||||
CMakeConfig CMakeGeneratorKitAspect::generatorCMakeConfig(const ProjectExplorer::Kit *k)
|
||||
CMakeConfig CMakeGeneratorKitAspect::generatorCMakeConfig(const Kit *k)
|
||||
{
|
||||
CMakeConfig config;
|
||||
|
||||
@@ -1028,14 +1082,14 @@ void CMakeConfigurationKitAspect::setConfiguration(Kit *k, const CMakeConfig &co
|
||||
k->setValue(CONFIGURATION_ID, tmp);
|
||||
}
|
||||
|
||||
QString CMakeConfigurationKitAspect::additionalConfiguration(const ProjectExplorer::Kit *k)
|
||||
QString CMakeConfigurationKitAspect::additionalConfiguration(const Kit *k)
|
||||
{
|
||||
if (!k)
|
||||
return QString();
|
||||
return k->value(ADDITIONAL_CONFIGURATION_ID).toString();
|
||||
}
|
||||
|
||||
void CMakeConfigurationKitAspect::setAdditionalConfiguration(ProjectExplorer::Kit *k, const QString &config)
|
||||
void CMakeConfigurationKitAspect::setAdditionalConfiguration(Kit *k, const QString &config)
|
||||
{
|
||||
if (!k)
|
||||
return;
|
||||
@@ -1095,7 +1149,7 @@ void CMakeConfigurationKitAspect::setCMakePreset(Kit *k, const QString &presetNa
|
||||
setConfiguration(k, config);
|
||||
}
|
||||
|
||||
CMakeConfigItem CMakeConfigurationKitAspect::cmakePresetConfigItem(const ProjectExplorer::Kit *k)
|
||||
CMakeConfigItem CMakeConfigurationKitAspect::cmakePresetConfigItem(const Kit *k)
|
||||
{
|
||||
const CMakeConfig config = configuration(k);
|
||||
return Utils::findOrDefault(config, [](const CMakeConfigItem &item) {
|
||||
@@ -1230,4 +1284,25 @@ KitAspect *CMakeConfigurationKitAspectFactory::createKitAspect(Kit *k) const
|
||||
return new CMakeConfigurationKitAspectWidget(k, this);
|
||||
}
|
||||
|
||||
// Factory instances;
|
||||
|
||||
const CMakeKitAspectFactory theCMakeKitAspectFactory;
|
||||
const CMakeGeneratorKitAspectFactory theCMakeGeneratorKitAspectFactory;
|
||||
const CMakeConfigurationKitAspectFactory theCMakeConfigurationKitAspectFactory;
|
||||
|
||||
KitAspect *CMakeKitAspect::createKitAspect(Kit *k)
|
||||
{
|
||||
return theCMakeKitAspectFactory.createKitAspect(k);
|
||||
}
|
||||
|
||||
KitAspect *CMakeGeneratorKitAspect::createKitAspect(Kit *k)
|
||||
{
|
||||
return theCMakeGeneratorKitAspectFactory.createKitAspect(k);
|
||||
}
|
||||
|
||||
KitAspect *CMakeConfigurationKitAspect::createKitAspect(Kit *k)
|
||||
{
|
||||
return theCMakeConfigurationKitAspectFactory.createKitAspect(k);
|
||||
}
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
@@ -22,23 +22,8 @@ public:
|
||||
static CMakeTool *cmakeTool(const ProjectExplorer::Kit *k);
|
||||
static void setCMakeTool(ProjectExplorer::Kit *k, const Utils::Id id);
|
||||
static QString msgUnsupportedVersion(const QByteArray &versionString);
|
||||
};
|
||||
|
||||
class CMAKE_EXPORT CMakeKitAspectFactory : public ProjectExplorer::KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeKitAspectFactory();
|
||||
|
||||
// KitAspect interface
|
||||
ProjectExplorer::Tasks validate(const ProjectExplorer::Kit *k) const final;
|
||||
void setup(ProjectExplorer::Kit *k) final;
|
||||
void fix(ProjectExplorer::Kit *k) final;
|
||||
ItemList toUserOutput(const ProjectExplorer::Kit *k) const final;
|
||||
ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k) const final;
|
||||
|
||||
void addToMacroExpander(ProjectExplorer::Kit *k, Utils::MacroExpander *expander) const final;
|
||||
|
||||
QSet<Utils::Id> availableFeatures(const ProjectExplorer::Kit *k) const final;
|
||||
static ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k);
|
||||
};
|
||||
|
||||
class CMAKE_EXPORT CMakeGeneratorKitAspect
|
||||
@@ -57,23 +42,8 @@ public:
|
||||
static QStringList generatorArguments(const ProjectExplorer::Kit *k);
|
||||
static CMakeConfig generatorCMakeConfig(const ProjectExplorer::Kit *k);
|
||||
static bool isMultiConfigGenerator(const ProjectExplorer::Kit *k);
|
||||
};
|
||||
|
||||
class CMAKE_EXPORT CMakeGeneratorKitAspectFactory : public ProjectExplorer::KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeGeneratorKitAspectFactory();
|
||||
|
||||
ProjectExplorer::Tasks validate(const ProjectExplorer::Kit *k) const final;
|
||||
void setup(ProjectExplorer::Kit *k) final;
|
||||
void fix(ProjectExplorer::Kit *k) final;
|
||||
void upgrade(ProjectExplorer::Kit *k) final;
|
||||
ItemList toUserOutput(const ProjectExplorer::Kit *k) const final;
|
||||
ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k) const final;
|
||||
void addToBuildEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const final;
|
||||
|
||||
private:
|
||||
QVariant defaultValue(const ProjectExplorer::Kit *k) const;
|
||||
static ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k);
|
||||
};
|
||||
|
||||
class CMAKE_EXPORT CMakeConfigurationKitAspect
|
||||
@@ -94,22 +64,8 @@ public:
|
||||
|
||||
static void setCMakePreset(ProjectExplorer::Kit *k, const QString &presetName);
|
||||
static CMakeConfigItem cmakePresetConfigItem(const ProjectExplorer::Kit *k);
|
||||
};
|
||||
|
||||
class CMAKE_EXPORT CMakeConfigurationKitAspectFactory : public ProjectExplorer::KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeConfigurationKitAspectFactory();
|
||||
|
||||
// KitAspect interface
|
||||
ProjectExplorer::Tasks validate(const ProjectExplorer::Kit *k) const final;
|
||||
void setup(ProjectExplorer::Kit *k) final;
|
||||
void fix(ProjectExplorer::Kit *k) final;
|
||||
ItemList toUserOutput(const ProjectExplorer::Kit *k) const final;
|
||||
ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k) const final;
|
||||
|
||||
private:
|
||||
QVariant defaultValue(const ProjectExplorer::Kit *k) const;
|
||||
static ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k);
|
||||
};
|
||||
|
||||
} // CMakeProjectManager
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include "cmakeeditor.h"
|
||||
#include "cmakeformatter.h"
|
||||
#include "cmakeinstallstep.h"
|
||||
#include "cmakekitaspect.h"
|
||||
#include "cmakelocatorfilter.h"
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
@@ -62,9 +61,6 @@ public:
|
||||
CMakeBuildTargetFilter cMakeBuildTargetFilter;
|
||||
CMakeOpenTargetFilter cMakeOpenTargetFilter;
|
||||
|
||||
CMakeKitAspectFactory cmakeKitAspectFactory;
|
||||
CMakeGeneratorKitAspectFactory cmakeGeneratorKitAspectFactory;
|
||||
CMakeConfigurationKitAspectFactory cmakeConfigurationKitAspectFactory;
|
||||
CMakeFormatter cmakeFormatter;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user