forked from qt-creator/qt-creator
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 <christian.kandeler@qt.io>
This commit is contained in:
@@ -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);
|
||||
// <Compatibility with QtC 4.2>
|
||||
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
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user