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

View File

@@ -48,9 +48,7 @@ public:
{ {
clear(); clear();
const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit); if (const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit)) {
if (!device)
return;
const Utils::FilePath rootPath = device->rootPath(); const Utils::FilePath rootPath = device->rootPath();
const QList<DebuggerItem> debuggersForBuildDevice const QList<DebuggerItem> debuggersForBuildDevice
= Utils::filtered(DebuggerItemManager::debuggers(), [&](const DebuggerItem &item) { = Utils::filtered(DebuggerItemManager::debuggers(), [&](const DebuggerItem &item) {
@@ -60,6 +58,7 @@ public:
}); });
for (const DebuggerItem &item : debuggersForBuildDevice) for (const DebuggerItem &item : debuggersForBuildDevice)
rootItem()->appendChild(new DebuggerTreeItem(item, false)); 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,13 +40,10 @@ public:
{ {
clear(); clear();
if (const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit)) {
const Toolchains ltcList = ToolchainManager::toolchains( const Toolchains ltcList = ToolchainManager::toolchains(
[this](const Toolchain *tc) { return m_category.contains(tc->language()); }); [this](const Toolchain *tc) { return m_category.contains(tc->language()); });
IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit); const Toolchains toolchainsForBuildDevice
if (!device)
return;
const QList<Toolchain *> toolchainsForBuildDevice
= Utils::filtered(ltcList, [device](Toolchain *tc) { = Utils::filtered(ltcList, [device](Toolchain *tc) {
return tc->compilerCommand().isSameDevice(device->rootPath()); return tc->compilerCommand().isSameDevice(device->rootPath());
}); });
@@ -54,6 +51,7 @@ public:
toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister); toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister);
for (const ToolchainBundle &b : bundlesForBuildDevice) for (const ToolchainBundle &b : bundlesForBuildDevice)
rootItem()->appendChild(new ToolchainTreeItem(b)); rootItem()->appendChild(new ToolchainTreeItem(b));
}
rootItem()->appendChild(new ToolchainTreeItem); rootItem()->appendChild(new ToolchainTreeItem);
} }

View File

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