ProjectExplorer: Fix UI of various kit aspects

... when there is no value compatible with the current build device.
The combo box was missing the "none" entry in that case.
Amends db11237dd5.

Task-number: QTCREATORBUG-26870
Change-Id: I195b13026ac299d57287772040c1fc78ab9289d2
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2024-12-10 15:13:40 +01:00
parent e8383bc3b2
commit 248cd3ce08
5 changed files with 45 additions and 47 deletions

View File

@@ -80,16 +80,15 @@ public:
{ {
clear(); clear();
const IDevice::ConstPtr dev = BuildDeviceKitAspect::device(&m_kit); if (const IDevice::ConstPtr dev = BuildDeviceKitAspect::device(&m_kit)) {
if (!dev) const FilePath rootPath = dev->rootPath();
return; const QList<CMakeTool *> toolsForBuildDevice
const FilePath rootPath = dev->rootPath(); = Utils::filtered(CMakeToolManager::cmakeTools(), [rootPath](CMakeTool *item) {
const QList<CMakeTool *> toolsForBuildDevice return item->cmakeExecutable().isSameDevice(rootPath);
= Utils::filtered(CMakeToolManager::cmakeTools(), [rootPath](CMakeTool *item) { });
return item->cmakeExecutable().isSameDevice(rootPath); for (CMakeTool *item : toolsForBuildDevice)
}); rootItem()->appendChild(new CMakeToolTreeItem(item, false));
for (CMakeTool *item : toolsForBuildDevice) }
rootItem()->appendChild(new CMakeToolTreeItem(item, false));
rootItem()->appendChild(new CMakeToolTreeItem); // The "none" item. rootItem()->appendChild(new CMakeToolTreeItem); // The "none" item.
} }

View File

@@ -48,18 +48,17 @@ public:
{ {
clear(); clear();
const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit); if (const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit)) {
if (!device) const Utils::FilePath rootPath = device->rootPath();
return; const QList<DebuggerItem> debuggersForBuildDevice
const Utils::FilePath rootPath = device->rootPath(); = Utils::filtered(DebuggerItemManager::debuggers(), [&](const DebuggerItem &item) {
const QList<DebuggerItem> debuggersForBuildDevice if (item.isGeneric())
= Utils::filtered(DebuggerItemManager::debuggers(), [&](const DebuggerItem &item) { return device->id() != ProjectExplorer::Constants::DESKTOP_DEVICE_ID;
if (item.isGeneric()) return item.command().isSameDevice(rootPath);
return device->id() != ProjectExplorer::Constants::DESKTOP_DEVICE_ID; });
return item.command().isSameDevice(rootPath); for (const DebuggerItem &item : debuggersForBuildDevice)
}); rootItem()->appendChild(new DebuggerTreeItem(item, false));
for (const DebuggerItem &item : debuggersForBuildDevice) }
rootItem()->appendChild(new DebuggerTreeItem(item, false));
DebuggerItem noneItem; DebuggerItem noneItem;
noneItem.setUnexpandedDisplayName(Tr::tr("None")); noneItem.setUnexpandedDisplayName(Tr::tr("None"));
rootItem()->appendChild(new DebuggerTreeItem(noneItem, false)); rootItem()->appendChild(new DebuggerTreeItem(noneItem, false));

View File

@@ -164,7 +164,10 @@ void KitAspect::refresh()
la.spec.resetModel(); la.spec.resetModel();
la.comboBox->model()->sort(0); la.comboBox->model()->sort(0);
const QVariant itemId = la.spec.getter(*kit()); const QVariant itemId = la.spec.getter(*kit());
la.comboBox->setCurrentIndex(la.comboBox->findData(itemId, IdRole)); int idx = la.comboBox->findData(itemId, IdRole);
if (idx == -1)
idx = la.comboBox->count() - 1;
la.comboBox->setCurrentIndex(idx);
la.comboBox->setEnabled(!d->readOnly && la.comboBox->count() > 1); la.comboBox->setEnabled(!d->readOnly && la.comboBox->count() > 1);
} }
} }

View File

@@ -40,20 +40,18 @@ public:
{ {
clear(); clear();
const Toolchains ltcList = ToolchainManager::toolchains( if (const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit)) {
[this](const Toolchain *tc) { return m_category.contains(tc->language()); }); const Toolchains ltcList = ToolchainManager::toolchains(
IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit); [this](const Toolchain *tc) { return m_category.contains(tc->language()); });
if (!device) const Toolchains toolchainsForBuildDevice
return; = Utils::filtered(ltcList, [device](Toolchain *tc) {
return tc->compilerCommand().isSameDevice(device->rootPath());
const QList<Toolchain *> toolchainsForBuildDevice });
= Utils::filtered(ltcList, [device](Toolchain *tc) { const QList<ToolchainBundle> bundlesForBuildDevice = ToolchainBundle::collectBundles(
return tc->compilerCommand().isSameDevice(device->rootPath()); toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister);
}); for (const ToolchainBundle &b : bundlesForBuildDevice)
const QList<ToolchainBundle> bundlesForBuildDevice = ToolchainBundle::collectBundles( rootItem()->appendChild(new ToolchainTreeItem(b));
toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister); }
for (const ToolchainBundle &b : bundlesForBuildDevice)
rootItem()->appendChild(new ToolchainTreeItem(b));
rootItem()->appendChild(new ToolchainTreeItem); rootItem()->appendChild(new ToolchainTreeItem);
} }

View File

@@ -49,16 +49,15 @@ public:
{ {
clear(); clear();
const IDevice::ConstPtr device = BuildDeviceKitAspect::device(&m_kit); if (const IDevice::ConstPtr device = BuildDeviceKitAspect::device(&m_kit)) {
if (!device) const FilePath deviceRoot = device->rootPath();
return; const QtVersions versionsForBuildDevice = QtVersionManager::versions(
const FilePath deviceRoot = device->rootPath(); [&deviceRoot](const QtVersion *qt) {
const QtVersions versionsForBuildDevice = QtVersionManager::versions( return qt->qmakeFilePath().isSameDevice(deviceRoot);
[&deviceRoot](const QtVersion *qt) { });
return qt->qmakeFilePath().isSameDevice(deviceRoot); for (QtVersion *v : versionsForBuildDevice)
}); rootItem()->appendChild(new QtVersionItem(v->uniqueId()));
for (QtVersion *v : versionsForBuildDevice) }
rootItem()->appendChild(new QtVersionItem(v->uniqueId()));
rootItem()->appendChild(new QtVersionItem(-1)); // The "No Qt" entry. rootItem()->appendChild(new QtVersionItem(-1)); // The "No Qt" entry.
} }