From 64a4154596390ddc5a116be0e01c3df3064dec34 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 21 Jan 2022 13:42:08 +0100 Subject: [PATCH] ProjectExplorer: Add convenience method ToolChain::isSdkProvided() Change-Id: I4f8bfcfbd5baef8210a41f6ccc878b0454e4697b Reviewed-by: hjk Reviewed-by: --- src/plugins/projectexplorer/toolchain.h | 1 + src/plugins/projectexplorer/toolchainoptionspage.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/toolchain.h b/src/plugins/projectexplorer/toolchain.h index 82e9b299f27..8a82c178cf6 100644 --- a/src/plugins/projectexplorer/toolchain.h +++ b/src/plugins/projectexplorer/toolchain.h @@ -100,6 +100,7 @@ public: void setDisplayName(const QString &name); bool isAutoDetected() const; + bool isSdkProvided() const { return detection() == AutoDetectionFromSdk; } Detection detection() const; QString detectionSource() const; diff --git a/src/plugins/projectexplorer/toolchainoptionspage.cpp b/src/plugins/projectexplorer/toolchainoptionspage.cpp index f00043fb192..642629191ca 100644 --- a/src/plugins/projectexplorer/toolchainoptionspage.cpp +++ b/src/plugins/projectexplorer/toolchainoptionspage.cpp @@ -222,7 +222,7 @@ public: if (item->level() != 3) return; const auto tcItem = static_cast(item); - if (tcItem->toolChain->detection() != ToolChain::AutoDetectionFromSdk) + if (!tcItem->toolChain->isSdkProvided()) itemsToRemove << tcItem; }); for (ToolChainTreeItem * const tcItem : qAsConst(itemsToRemove)) @@ -403,12 +403,10 @@ void ToolChainOptionsWidget::redetectToolchains() if (item->level() != 3) return; const auto tcItem = static_cast(item); - if (tcItem->toolChain->isAutoDetected() - && tcItem->toolChain->detection() != ToolChain::AutoDetectionFromSdk) { + if (tcItem->toolChain->isAutoDetected() && !tcItem->toolChain->isSdkProvided()) itemsToRemove << tcItem; - } else { + else knownTcs << tcItem->toolChain; - } }); Toolchains toAdd; QSet toDelete; @@ -551,7 +549,7 @@ void ToolChainOptionsWidget::updateState() if (ToolChainTreeItem *item = currentTreeItem()) { ToolChain *tc = item->toolChain; canCopy = tc->isValid(); - canDelete = tc->detection() != ToolChain::AutoDetectionFromSdk; + canDelete = !tc->isSdkProvided(); } m_cloneButton->setEnabled(canCopy);