ProjectExplorer: Add convenience method ToolChain::isSdkProvided()

Change-Id: I4f8bfcfbd5baef8210a41f6ccc878b0454e4697b
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christian Kandeler
2022-01-21 13:42:08 +01:00
parent da225e0784
commit 64a4154596
2 changed files with 5 additions and 6 deletions

View File

@@ -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;

View File

@@ -222,7 +222,7 @@ public:
if (item->level() != 3)
return;
const auto tcItem = static_cast<ToolChainTreeItem *>(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<ToolChainTreeItem *>(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<ToolChain *> 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);