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