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 = new QPushButton(Tr::tr("Kit Configuration"));
|
||||||
m_kitConfiguration->setToolTip(Tr::tr("Edit the current kit's CMake configuration."));
|
m_kitConfiguration->setToolTip(Tr::tr("Edit the current kit's CMake configuration."));
|
||||||
m_kitConfiguration->setFixedWidth(m_kitConfiguration->sizeHint().width());
|
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 = new FancyLineEdit;
|
||||||
m_filterEdit->setPlaceholderText(Tr::tr("Filter"));
|
m_filterEdit->setPlaceholderText(Tr::tr("Filter"));
|
||||||
@@ -646,18 +648,14 @@ void CMakeBuildSettingsWidget::kitCMakeConfiguration()
|
|||||||
m_buildConfig->kit()->unblockNotification();
|
m_buildConfig->kit()->unblockNotification();
|
||||||
});
|
});
|
||||||
|
|
||||||
CMakeKitAspectFactory kitAspectFactory;
|
|
||||||
CMakeGeneratorKitAspectFactory generatorAspectFactory;
|
|
||||||
CMakeConfigurationKitAspectFactory configurationKitAspectFactory;
|
|
||||||
|
|
||||||
Layouting::Grid grid;
|
Layouting::Grid grid;
|
||||||
KitAspect *widget = kitAspectFactory.createKitAspect(m_buildConfig->kit());
|
KitAspect *widget = CMakeKitAspect::createKitAspect(m_buildConfig->kit());
|
||||||
widget->setParent(dialog);
|
widget->setParent(dialog);
|
||||||
widget->addToLayoutWithLabel(grid, dialog);
|
widget->addToLayoutWithLabel(grid, dialog);
|
||||||
widget = generatorAspectFactory.createKitAspect(m_buildConfig->kit());
|
widget = CMakeGeneratorKitAspect::createKitAspect(m_buildConfig->kit());
|
||||||
widget->setParent(dialog);
|
widget->setParent(dialog);
|
||||||
widget->addToLayoutWithLabel(grid, dialog);
|
widget->addToLayoutWithLabel(grid, dialog);
|
||||||
widget = configurationKitAspectFactory.createKitAspect(m_buildConfig->kit());
|
widget = CMakeConfigurationKitAspect::createKitAspect(m_buildConfig->kit());
|
||||||
widget->setParent(dialog);
|
widget->setParent(dialog);
|
||||||
widget->addToLayoutWithLabel(grid, dialog);
|
widget->addToLayoutWithLabel(grid, dialog);
|
||||||
grid.attachTo(dialog);
|
grid.attachTo(dialog);
|
||||||
|
@@ -63,6 +63,60 @@ static Id defaultCMakeToolId()
|
|||||||
return defaultTool ? defaultTool->id() : Id();
|
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
|
class CMakeKitAspectImpl final : public KitAspect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -602,7 +656,7 @@ QStringList CMakeGeneratorKitAspect::generatorArguments(const Kit *k)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeConfig CMakeGeneratorKitAspect::generatorCMakeConfig(const ProjectExplorer::Kit *k)
|
CMakeConfig CMakeGeneratorKitAspect::generatorCMakeConfig(const Kit *k)
|
||||||
{
|
{
|
||||||
CMakeConfig config;
|
CMakeConfig config;
|
||||||
|
|
||||||
@@ -1028,14 +1082,14 @@ void CMakeConfigurationKitAspect::setConfiguration(Kit *k, const CMakeConfig &co
|
|||||||
k->setValue(CONFIGURATION_ID, tmp);
|
k->setValue(CONFIGURATION_ID, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMakeConfigurationKitAspect::additionalConfiguration(const ProjectExplorer::Kit *k)
|
QString CMakeConfigurationKitAspect::additionalConfiguration(const Kit *k)
|
||||||
{
|
{
|
||||||
if (!k)
|
if (!k)
|
||||||
return QString();
|
return QString();
|
||||||
return k->value(ADDITIONAL_CONFIGURATION_ID).toString();
|
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)
|
if (!k)
|
||||||
return;
|
return;
|
||||||
@@ -1095,7 +1149,7 @@ void CMakeConfigurationKitAspect::setCMakePreset(Kit *k, const QString &presetNa
|
|||||||
setConfiguration(k, config);
|
setConfiguration(k, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeConfigItem CMakeConfigurationKitAspect::cmakePresetConfigItem(const ProjectExplorer::Kit *k)
|
CMakeConfigItem CMakeConfigurationKitAspect::cmakePresetConfigItem(const Kit *k)
|
||||||
{
|
{
|
||||||
const CMakeConfig config = configuration(k);
|
const CMakeConfig config = configuration(k);
|
||||||
return Utils::findOrDefault(config, [](const CMakeConfigItem &item) {
|
return Utils::findOrDefault(config, [](const CMakeConfigItem &item) {
|
||||||
@@ -1230,4 +1284,25 @@ KitAspect *CMakeConfigurationKitAspectFactory::createKitAspect(Kit *k) const
|
|||||||
return new CMakeConfigurationKitAspectWidget(k, this);
|
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
|
} // namespace CMakeProjectManager
|
||||||
|
@@ -22,23 +22,8 @@ public:
|
|||||||
static CMakeTool *cmakeTool(const ProjectExplorer::Kit *k);
|
static CMakeTool *cmakeTool(const ProjectExplorer::Kit *k);
|
||||||
static void setCMakeTool(ProjectExplorer::Kit *k, const Utils::Id id);
|
static void setCMakeTool(ProjectExplorer::Kit *k, const Utils::Id id);
|
||||||
static QString msgUnsupportedVersion(const QByteArray &versionString);
|
static QString msgUnsupportedVersion(const QByteArray &versionString);
|
||||||
};
|
|
||||||
|
|
||||||
class CMAKE_EXPORT CMakeKitAspectFactory : public ProjectExplorer::KitAspectFactory
|
static ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k);
|
||||||
{
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMAKE_EXPORT CMakeGeneratorKitAspect
|
class CMAKE_EXPORT CMakeGeneratorKitAspect
|
||||||
@@ -57,23 +42,8 @@ public:
|
|||||||
static QStringList generatorArguments(const ProjectExplorer::Kit *k);
|
static QStringList generatorArguments(const ProjectExplorer::Kit *k);
|
||||||
static CMakeConfig generatorCMakeConfig(const ProjectExplorer::Kit *k);
|
static CMakeConfig generatorCMakeConfig(const ProjectExplorer::Kit *k);
|
||||||
static bool isMultiConfigGenerator(const ProjectExplorer::Kit *k);
|
static bool isMultiConfigGenerator(const ProjectExplorer::Kit *k);
|
||||||
};
|
|
||||||
|
|
||||||
class CMAKE_EXPORT CMakeGeneratorKitAspectFactory : public ProjectExplorer::KitAspectFactory
|
static ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k);
|
||||||
{
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMAKE_EXPORT CMakeConfigurationKitAspect
|
class CMAKE_EXPORT CMakeConfigurationKitAspect
|
||||||
@@ -94,22 +64,8 @@ public:
|
|||||||
|
|
||||||
static void setCMakePreset(ProjectExplorer::Kit *k, const QString &presetName);
|
static void setCMakePreset(ProjectExplorer::Kit *k, const QString &presetName);
|
||||||
static CMakeConfigItem cmakePresetConfigItem(const ProjectExplorer::Kit *k);
|
static CMakeConfigItem cmakePresetConfigItem(const ProjectExplorer::Kit *k);
|
||||||
};
|
|
||||||
|
|
||||||
class CMAKE_EXPORT CMakeConfigurationKitAspectFactory : public ProjectExplorer::KitAspectFactory
|
static ProjectExplorer::KitAspect *createKitAspect(ProjectExplorer::Kit *k);
|
||||||
{
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // CMakeProjectManager
|
} // CMakeProjectManager
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#include "cmakeeditor.h"
|
#include "cmakeeditor.h"
|
||||||
#include "cmakeformatter.h"
|
#include "cmakeformatter.h"
|
||||||
#include "cmakeinstallstep.h"
|
#include "cmakeinstallstep.h"
|
||||||
#include "cmakekitaspect.h"
|
|
||||||
#include "cmakelocatorfilter.h"
|
#include "cmakelocatorfilter.h"
|
||||||
#include "cmakeproject.h"
|
#include "cmakeproject.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
@@ -62,9 +61,6 @@ public:
|
|||||||
CMakeBuildTargetFilter cMakeBuildTargetFilter;
|
CMakeBuildTargetFilter cMakeBuildTargetFilter;
|
||||||
CMakeOpenTargetFilter cMakeOpenTargetFilter;
|
CMakeOpenTargetFilter cMakeOpenTargetFilter;
|
||||||
|
|
||||||
CMakeKitAspectFactory cmakeKitAspectFactory;
|
|
||||||
CMakeGeneratorKitAspectFactory cmakeGeneratorKitAspectFactory;
|
|
||||||
CMakeConfigurationKitAspectFactory cmakeConfigurationKitAspectFactory;
|
|
||||||
CMakeFormatter cmakeFormatter;
|
CMakeFormatter cmakeFormatter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user