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

View File

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

View File

@@ -164,7 +164,10 @@ void KitAspect::refresh()
la.spec.resetModel();
la.comboBox->model()->sort(0);
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);
}
}

View File

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

View File

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