ProjectExplorer: Filter kit aspects by build device

That is, do not offer toolchains, debuggers etc that do not match the
kit's build device.

Change-Id: I041ba9fd18ab553d9b2219116d87493e30f60aac
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Christian Kandeler
2024-08-29 12:47:02 +02:00
parent f5e9ae47b3
commit 842776fb62
4 changed files with 29 additions and 75 deletions

View File

@@ -163,29 +163,18 @@ private:
IDeviceConstPtr device = BuildDeviceKitAspect::device(kit()); IDeviceConstPtr device = BuildDeviceKitAspect::device(kit());
const FilePath rootPath = device->rootPath(); const FilePath rootPath = device->rootPath();
const auto list = CMakeToolManager::cmakeTools(); const QList<CMakeTool *> toolsForBuildDevice
= Utils::filtered(CMakeToolManager::cmakeTools(), [rootPath](CMakeTool *item) {
return item->cmakeExecutable().isSameDevice(rootPath);
});
m_comboBox->setEnabled(!list.isEmpty()); m_comboBox->setEnabled(!toolsForBuildDevice.isEmpty());
if (toolsForBuildDevice.isEmpty()) {
if (list.isEmpty()) {
m_comboBox->addItem(Tr::tr("<No CMake Tool available>"), Id().toSetting()); m_comboBox->addItem(Tr::tr("<No CMake Tool available>"), Id().toSetting());
return; return;
} }
const QList<CMakeTool *> same = Utils::filtered(list, [rootPath](CMakeTool *item) { for (CMakeTool *item : toolsForBuildDevice)
return item->cmakeExecutable().isSameDevice(rootPath);
});
const QList<CMakeTool *> other = Utils::filtered(list, [rootPath](CMakeTool *item) {
return !item->cmakeExecutable().isSameDevice(rootPath);
});
for (CMakeTool *item : same)
m_comboBox->addItem(item->displayName(), item->id().toSetting());
if (!same.isEmpty() && !other.isEmpty())
m_comboBox->insertSeparator(m_comboBox->count());
for (CMakeTool *item : other)
m_comboBox->addItem(item->displayName(), item->id().toSetting()); m_comboBox->addItem(item->displayName(), item->id().toSetting());
CMakeTool *tool = CMakeKitAspect::cmakeTool(m_kit); CMakeTool *tool = CMakeKitAspect::cmakeTool(m_kit);

View File

@@ -86,22 +86,12 @@ private:
IDeviceConstPtr device = BuildDeviceKitAspect::device(kit()); IDeviceConstPtr device = BuildDeviceKitAspect::device(kit());
const Utils::FilePath path = device->rootPath(); const Utils::FilePath path = device->rootPath();
const QList<DebuggerItem> list = DebuggerItemManager::debuggers();
const QList<DebuggerItem> same = Utils::filtered(list, [path](const DebuggerItem &item) { const QList<DebuggerItem> debuggersForBuildDevice
return item.command().isSameDevice(path); = Utils::filtered(DebuggerItemManager::debuggers(), [path](const DebuggerItem &item) {
}); return item.command().isSameDevice(path);
const QList<DebuggerItem> other = Utils::filtered(list, [path](const DebuggerItem &item) { });
return !item.command().isSameDevice(path); for (const DebuggerItem &item : debuggersForBuildDevice)
});
for (const DebuggerItem &item : same)
m_comboBox->addItem(item.displayName(), item.id());
if (!same.isEmpty() && !other.isEmpty())
m_comboBox->insertSeparator(m_comboBox->count());
for (const DebuggerItem &item : other)
m_comboBox->addItem(item.displayName(), item.id()); m_comboBox->addItem(item.displayName(), item.id());
const DebuggerItem *item = DebuggerKitAspect::debugger(m_kit); const DebuggerItem *item = DebuggerKitAspect::debugger(m_kit);

View File

@@ -264,24 +264,13 @@ private:
cb->clear(); cb->clear();
cb->addItem(Tr::tr("<No compiler>"), QByteArray()); cb->addItem(Tr::tr("<No compiler>"), QByteArray());
const QList<Toolchain *> same = Utils::filtered(ltcList, [device](Toolchain *tc) { const QList<Toolchain *> toolchainsForBuildDevice
return tc->compilerCommand().isSameDevice(device->rootPath()); = Utils::filtered(ltcList, [device](Toolchain *tc) {
}); return tc->compilerCommand().isSameDevice(device->rootPath());
const QList<Toolchain *> other = Utils::filtered(ltcList, [device](Toolchain *tc) { });
return !tc->compilerCommand().isSameDevice(device->rootPath()); const QList<ToolchainBundle> bundlesForBuildDevice = ToolchainBundle::collectBundles(
}); toolchainsForBuildDevice, ToolchainBundle::AutoRegister::On);
for (const ToolchainBundle &b : bundlesForBuildDevice)
const QList<ToolchainBundle> sameBundles
= ToolchainBundle::collectBundles(same, ToolchainBundle::AutoRegister::On);
const QList<ToolchainBundle> otherBundles
= ToolchainBundle::collectBundles(other, ToolchainBundle::AutoRegister::On);
for (const ToolchainBundle &b : sameBundles)
cb->addItem(b.displayName(), b.bundleId().toSetting());
if (!sameBundles.isEmpty() && !otherBundles.isEmpty())
cb->insertSeparator(cb->count());
for (const ToolchainBundle &b : otherBundles)
cb->addItem(b.displayName(), b.bundleId().toSetting()); cb->addItem(b.displayName(), b.bundleId().toSetting());
cb->setEnabled(cb->count() > 1 && !m_isReadOnly); cb->setEnabled(cb->count() > 1 && !m_isReadOnly);
@@ -290,15 +279,12 @@ private:
Toolchain * const currentTc = ToolchainKitAspect::toolchain(m_kit, lang); Toolchain * const currentTc = ToolchainKitAspect::toolchain(m_kit, lang);
if (!currentTc) if (!currentTc)
continue; continue;
for (const QList<ToolchainBundle> &bundles : {sameBundles, otherBundles}) for (const ToolchainBundle &b : bundlesForBuildDevice) {
for (const ToolchainBundle &b : bundles) { if (b.bundleId() == currentTc->bundleId()) {
if (b.bundleId() == currentTc->bundleId()) { currentBundleId = b.bundleId();
currentBundleId = b.bundleId(); break;
break;
}
if (currentBundleId.isValid())
break;
} }
}
if (currentBundleId.isValid()) if (currentBundleId.isValid())
break; break;
} }

View File

@@ -77,24 +77,13 @@ private:
IDeviceConstPtr device = BuildDeviceKitAspect::device(kit()); IDeviceConstPtr device = BuildDeviceKitAspect::device(kit());
const FilePath deviceRoot = device->rootPath(); const FilePath deviceRoot = device->rootPath();
const QtVersions versions = QtVersionManager::versions(); const QList<QtVersion *> versionsForBuildDevice
= Utils::filtered(QtVersionManager::versions(), [device](QtVersion *qt) {
return qt->qmakeFilePath().isSameDevice(device->rootPath());
});
const QList<QtVersion *> same = Utils::filtered(versions, [device](QtVersion *qt) { for (QtVersion *item : versionsForBuildDevice)
return qt->qmakeFilePath().isSameDevice(device->rootPath());
});
const QList<QtVersion *> other = Utils::filtered(versions, [device](QtVersion *qt) {
return !qt->qmakeFilePath().isSameDevice(device->rootPath());
});
for (QtVersion *item : same)
m_combo->addItem(item->displayName(), item->uniqueId()); m_combo->addItem(item->displayName(), item->uniqueId());
if (!same.isEmpty() && !other.isEmpty())
m_combo->insertSeparator(m_combo->count());
for (QtVersion *item : other)
m_combo->addItem(item->displayName(), item->uniqueId());
m_combo->setCurrentIndex(findQtVersion(QtKitAspect::qtVersionId(m_kit))); m_combo->setCurrentIndex(findQtVersion(QtKitAspect::qtVersionId(m_kit)));
} }