forked from qt-creator/qt-creator
TargetSetupPage: Work for projects without BuildConfiguration
Change-Id: Ie145bc3c87f01326a25e75f5c80a4d05da58bf6b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -842,6 +842,9 @@ void Project::setup(QList<const BuildInfo *> infoList)
|
||||
toRegister << t;
|
||||
}
|
||||
|
||||
if (!info->factory())
|
||||
continue;
|
||||
|
||||
BuildConfiguration *bc = info->factory()->create(t, info);
|
||||
if (!bc)
|
||||
continue;
|
||||
|
||||
@@ -552,19 +552,23 @@ TargetSetupWidget *TargetSetupPage::addWidget(Kit *k)
|
||||
if (!k || (m_requiredPredicate && !m_requiredPredicate(k)))
|
||||
return nullptr;
|
||||
|
||||
IBuildConfigurationFactory *factory
|
||||
const IBuildConfigurationFactory *const factory
|
||||
= IBuildConfigurationFactory::find(k, m_projectPath);
|
||||
if (!factory)
|
||||
return nullptr;
|
||||
const QList<BuildInfo *> infoList = [this, k, factory]() {
|
||||
if (factory)
|
||||
return factory->availableSetups(k, m_projectPath);
|
||||
|
||||
QList<BuildInfo *> infoList = factory->availableSetups(k, m_projectPath);
|
||||
TargetSetupWidget *widget = infoList.isEmpty() ? nullptr : new TargetSetupWidget(k, m_projectPath, infoList);
|
||||
if (!widget)
|
||||
return nullptr;
|
||||
BuildInfo *info = new BuildInfo(nullptr);
|
||||
info->kitId = k->id();
|
||||
return QList<BuildInfo *>({info});
|
||||
}();
|
||||
|
||||
// Not all projects have BuildConfigurations, that is perfectly fine.
|
||||
TargetSetupWidget *widget = new TargetSetupWidget(k, m_projectPath);
|
||||
|
||||
m_baseLayout->removeWidget(m_importWidget);
|
||||
foreach (QWidget *widget, m_potentialWidgets)
|
||||
m_baseLayout->removeWidget(widget);
|
||||
foreach (QWidget *potentialWidget, m_potentialWidgets)
|
||||
m_baseLayout->removeWidget(potentialWidget);
|
||||
m_baseLayout->removeItem(m_spacer);
|
||||
|
||||
widget->setKitSelected(m_preferredPredicate && m_preferredPredicate(k));
|
||||
|
||||
@@ -56,9 +56,7 @@ namespace Internal {
|
||||
// TargetSetupWidget
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
TargetSetupWidget::TargetSetupWidget(Kit *k,
|
||||
const QString &projectPath,
|
||||
const QList<BuildInfo *> &infoList) :
|
||||
TargetSetupWidget::TargetSetupWidget(Kit *k, const QString &projectPath) :
|
||||
m_kit(k)
|
||||
{
|
||||
Q_ASSERT(m_kit);
|
||||
@@ -98,9 +96,6 @@ TargetSetupWidget::TargetSetupWidget(Kit *k,
|
||||
widget->setEnabled(false);
|
||||
m_detailsWidget->setWidget(widget);
|
||||
|
||||
foreach (BuildInfo *info, infoList)
|
||||
addBuildInfo(info, false);
|
||||
|
||||
setProjectPath(projectPath);
|
||||
|
||||
connect(m_detailsWidget, &Utils::DetailsWidget::checked,
|
||||
@@ -142,6 +137,8 @@ void TargetSetupWidget::setKitSelected(bool b)
|
||||
|
||||
void TargetSetupWidget::addBuildInfo(BuildInfo *info, bool isImport)
|
||||
{
|
||||
QTC_ASSERT(info && info->kitId == m_kit->id(), return);
|
||||
|
||||
if (isImport && !m_haveImported) {
|
||||
// disable everything on first import
|
||||
for (BuildInfoStore &store : m_infoStore) {
|
||||
@@ -160,6 +157,7 @@ void TargetSetupWidget::addBuildInfo(BuildInfo *info, bool isImport)
|
||||
store.isEnabled = true;
|
||||
++m_selected;
|
||||
|
||||
if (info->factory()) {
|
||||
store.checkbox = new QCheckBox;
|
||||
store.checkbox->setText(info->displayName);
|
||||
store.checkbox->setChecked(store.isEnabled);
|
||||
@@ -180,6 +178,7 @@ void TargetSetupWidget::addBuildInfo(BuildInfo *info, bool isImport)
|
||||
|
||||
connect(store.checkbox, &QAbstractButton::toggled, this, &TargetSetupWidget::checkBoxToggled);
|
||||
connect(store.pathChooser, &Utils::PathChooser::rawPathChanged, this, &TargetSetupWidget::pathChanged);
|
||||
}
|
||||
|
||||
store.hasIssues = false;
|
||||
m_infoStore.emplace_back(std::move(store));
|
||||
@@ -218,15 +217,7 @@ void TargetSetupWidget::setProjectPath(const QString &projectPath)
|
||||
m_projectPath = projectPath;
|
||||
clear();
|
||||
|
||||
IBuildConfigurationFactory *factory
|
||||
= IBuildConfigurationFactory::find(m_kit, projectPath);
|
||||
|
||||
if (!factory)
|
||||
return;
|
||||
|
||||
QList<BuildInfo *> infoList
|
||||
= factory->availableSetups(m_kit, projectPath);
|
||||
foreach (BuildInfo *info, infoList)
|
||||
for (BuildInfo *info : buildInfoList(m_kit, projectPath))
|
||||
addBuildInfo(info, false);
|
||||
}
|
||||
|
||||
@@ -235,6 +226,18 @@ void TargetSetupWidget::expandWidget()
|
||||
m_detailsWidget->setState(Utils::DetailsWidget::Expanded);
|
||||
}
|
||||
|
||||
QList<BuildInfo *> TargetSetupWidget::buildInfoList(const Kit *k, const QString &projectPath)
|
||||
{
|
||||
const IBuildConfigurationFactory *const factory
|
||||
= IBuildConfigurationFactory::find(k, projectPath);
|
||||
if (factory)
|
||||
return factory->availableSetups(k, projectPath);
|
||||
|
||||
BuildInfo *info = new BuildInfo(nullptr);
|
||||
info->kitId = k->id();
|
||||
return QList<BuildInfo *>({info});
|
||||
}
|
||||
|
||||
void TargetSetupWidget::handleKitUpdate(Kit *k)
|
||||
{
|
||||
if (k != m_kit)
|
||||
@@ -304,15 +307,17 @@ void TargetSetupWidget::reportIssues(int index)
|
||||
QTC_ASSERT(index >= 0 && index < size, return);
|
||||
|
||||
BuildInfoStore &store = m_infoStore[static_cast<size_t>(index)];
|
||||
if (store.issuesLabel) {
|
||||
QPair<Task::TaskType, QString> issues = findIssues(store.buildInfo);
|
||||
store.issuesLabel->setText(issues.second);
|
||||
store.hasIssues = issues.first != Task::Unknown;
|
||||
store.issuesLabel->setVisible(store.hasIssues);
|
||||
}
|
||||
}
|
||||
|
||||
QPair<Task::TaskType, QString> TargetSetupWidget::findIssues(const BuildInfo *info)
|
||||
{
|
||||
if (m_projectPath.isEmpty())
|
||||
if (m_projectPath.isEmpty() || !info->factory())
|
||||
return qMakePair(Task::Unknown, QString());
|
||||
|
||||
QString buildDir = info->buildDirectory.toString();
|
||||
|
||||
@@ -58,8 +58,7 @@ class TargetSetupWidget : public QWidget
|
||||
|
||||
public:
|
||||
TargetSetupWidget(Kit *k,
|
||||
const QString &projectPath,
|
||||
const QList<BuildInfo *> &infoList);
|
||||
const QString &projectPath);
|
||||
|
||||
Kit *kit();
|
||||
void clearKit();
|
||||
@@ -77,6 +76,8 @@ signals:
|
||||
void selectedToggled() const;
|
||||
|
||||
private:
|
||||
static QList<BuildInfo *> buildInfoList(const Kit *k, const QString &projectPath);
|
||||
|
||||
void handleKitUpdate(ProjectExplorer::Kit *k);
|
||||
|
||||
void checkBoxToggled(bool b);
|
||||
|
||||
Reference in New Issue
Block a user