From 3f4d45532dc0d2df4cc92eb937c56281e76f04a2 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 12 Jul 2021 14:19:23 +0200 Subject: [PATCH] ProjectExplorer: Introduce a QString Toolchain::detectionSource Would be useful to link auto-detected items to the source of their detection and later automatic removal when the source vanishes. This is bit more fine grained than the existing detection() and mimics what QtVersion, Debugger and CMake have. Change-Id: I2fae95e7e3c2e8191e9ff4cc7f36dc3fde86cf18 Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/toolchain.cpp | 14 ++++++++++++++ src/plugins/projectexplorer/toolchain.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index 98df39036a9..ab53717e80c 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -44,6 +44,7 @@ using namespace Utils; static const char ID_KEY[] = "ProjectExplorer.ToolChain.Id"; static const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ToolChain.DisplayName"; static const char AUTODETECT_KEY[] = "ProjectExplorer.ToolChain.Autodetect"; +static const char DETECTION_SOURCE_KEY[] = "ProjectExplorer.ToolChain.DetectionSource"; static const char LANGUAGE_KEY_V1[] = "ProjectExplorer.ToolChain.Language"; // For QtCreator <= 4.2 static const char LANGUAGE_KEY_V2[] = "ProjectExplorer.ToolChain.LanguageV2"; // For QtCreator > 4.2 @@ -82,6 +83,7 @@ public: Utils::Id m_typeId; Utils::Id m_language; Detection m_detection = ToolChain::UninitializedDetection; + QString m_detectionSource; ToolChain::MacrosCache m_predefinedMacrosCache; ToolChain::HeaderPathsCache m_headerPathsCache; @@ -173,6 +175,11 @@ ToolChain::Detection ToolChain::detection() const return d->m_detection; } +QString ToolChain::detectionSource() const +{ + return d->m_detectionSource; +} + QByteArray ToolChain::id() const { return d->m_id; @@ -252,6 +259,7 @@ QVariantMap ToolChain::toMap() const result.insert(QLatin1String(ID_KEY), idToSave); result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName()); result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected()); + result.insert(QLatin1String(DETECTION_SOURCE_KEY), d->m_detectionSource); // int oldLanguageId = -1; if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID) @@ -282,6 +290,11 @@ void ToolChain::setDetection(ToolChain::Detection de) d->m_detection = de; } +void ToolChain::setDetectionSource(const QString &source) +{ + d->m_detectionSource = source; +} + QString ToolChain::typeDisplayName() const { return d->m_typeDisplayName; @@ -353,6 +366,7 @@ bool ToolChain::fromMap(const QVariantMap &data) const bool autoDetect = data.value(QLatin1String(AUTODETECT_KEY), false).toBool(); d->m_detection = autoDetect ? AutoDetection : ManualDetection; + d->m_detectionSource = data.value(DETECTION_SOURCE_KEY).toString(); if (data.contains(LANGUAGE_KEY_V2)) { // remove hack to trim language id in 4.4: This is to fix up broken language diff --git a/src/plugins/projectexplorer/toolchain.h b/src/plugins/projectexplorer/toolchain.h index 2c2a3c68b72..b3ad1484c58 100644 --- a/src/plugins/projectexplorer/toolchain.h +++ b/src/plugins/projectexplorer/toolchain.h @@ -100,6 +100,7 @@ public: bool isAutoDetected() const; Detection detection() const; + QString detectionSource() const; QByteArray id() const; @@ -165,6 +166,7 @@ public: void setLanguage(Utils::Id language); void setDetection(Detection d); + void setDetectionSource(const QString &source); static Utils::LanguageVersion cxxLanguageVersion(const QByteArray &cplusplusMacroValue); static Utils::LanguageVersion languageVersion(const Utils::Id &language, const Macros ¯os);