QtSupport: Add setting for arbitrary features for a Qt version

Change-Id: I9cd296316bd100d6f867ca7bffefb9676dc66c09
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Tim Jenssen
2018-01-15 13:58:46 +01:00
committed by Thomas Hartmann
parent 6f5f07d2e4
commit 4f537a5ea3
3 changed files with 19 additions and 4 deletions

View File

@@ -70,6 +70,7 @@ using namespace Utils;
static const char QTVERSIONAUTODETECTED[] = "isAutodetected"; static const char QTVERSIONAUTODETECTED[] = "isAutodetected";
static const char QTVERSIONAUTODETECTIONSOURCE[] = "autodetectionSource"; static const char QTVERSIONAUTODETECTIONSOURCE[] = "autodetectionSource";
static const char QTVERSION_OVERRIDE_FEATURES[] = "overrideFeatures";
static const char QTVERSIONQMAKEPATH[] = "QMakePath"; static const char QTVERSIONQMAKEPATH[] = "QMakePath";
static const char QTVERSIONSOURCEPATH[] = "SourcePath"; static const char QTVERSIONSOURCEPATH[] = "SourcePath";
@@ -227,6 +228,7 @@ BaseQtVersion::BaseQtVersion(const BaseQtVersion &other) :
m_qtConfigValues(other.m_qtConfigValues), m_qtConfigValues(other.m_qtConfigValues),
m_unexpandedDisplayName(other.m_unexpandedDisplayName), m_unexpandedDisplayName(other.m_unexpandedDisplayName),
m_autodetectionSource(other.m_autodetectionSource), m_autodetectionSource(other.m_autodetectionSource),
m_overrideFeatures(other.m_overrideFeatures),
m_sourcePath(other.m_sourcePath), m_sourcePath(other.m_sourcePath),
m_mkspec(other.m_mkspec), m_mkspec(other.m_mkspec),
m_mkspecFullPath(other.m_mkspecFullPath), m_mkspecFullPath(other.m_mkspecFullPath),
@@ -662,6 +664,7 @@ void BaseQtVersion::fromMap(const QVariantMap &map)
m_isAutodetected = map.value(QTVERSIONAUTODETECTED).toBool(); m_isAutodetected = map.value(QTVERSIONAUTODETECTED).toBool();
if (m_isAutodetected) if (m_isAutodetected)
m_autodetectionSource = map.value(QTVERSIONAUTODETECTIONSOURCE).toString(); m_autodetectionSource = map.value(QTVERSIONAUTODETECTIONSOURCE).toString();
m_overrideFeatures = Core::Id::fromStringList(map.value(QTVERSION_OVERRIDE_FEATURES).toStringList());
QString string = map.value(QTVERSIONQMAKEPATH).toString(); QString string = map.value(QTVERSIONQMAKEPATH).toString();
if (string.startsWith('~')) if (string.startsWith('~'))
string.remove(0, 1).prepend(QDir::homePath()); string.remove(0, 1).prepend(QDir::homePath());
@@ -688,6 +691,9 @@ QVariantMap BaseQtVersion::toMap() const
result.insert(QTVERSIONAUTODETECTED, isAutodetected()); result.insert(QTVERSIONAUTODETECTED, isAutodetected());
if (isAutodetected()) if (isAutodetected())
result.insert(QTVERSIONAUTODETECTIONSOURCE, autodetectionSource()); result.insert(QTVERSIONAUTODETECTIONSOURCE, autodetectionSource());
if (!m_overrideFeatures.isEmpty())
result.insert(QTVERSION_OVERRIDE_FEATURES, Core::Id::toStringList(m_overrideFeatures));
result.insert(QTVERSIONQMAKEPATH, qmakeCommand().toString()); result.insert(QTVERSIONQMAKEPATH, qmakeCommand().toString());
return result; return result;
} }
@@ -1359,6 +1365,13 @@ void BaseQtVersion::populateQmlFileFinder(FileInProjectFinder *finder, const Tar
finder->setAdditionalSearchDirectories(additionalSearchDirectories); finder->setAdditionalSearchDirectories(additionalSearchDirectories);
} }
QSet<Id> BaseQtVersion::features() const
{
if (m_overrideFeatures.isEmpty())
return availableFeatures();
return m_overrideFeatures;
}
void BaseQtVersion::addToEnvironment(const Kit *k, Environment &env) const void BaseQtVersion::addToEnvironment(const Kit *k, Environment &env) const
{ {
Q_UNUSED(k); Q_UNUSED(k);

View File

@@ -205,7 +205,6 @@ public:
static QString defaultUnexpandedDisplayName(const Utils::FileName &qmakePath, static QString defaultUnexpandedDisplayName(const Utils::FileName &qmakePath,
bool fromPath = false); bool fromPath = false);
virtual QSet<Core::Id> availableFeatures() const;
virtual QSet<Core::Id> targetDeviceTypes() const = 0; virtual QSet<Core::Id> targetDeviceTypes() const = 0;
virtual QList<ProjectExplorer::Task> validateKit(const ProjectExplorer::Kit *k); virtual QList<ProjectExplorer::Task> validateKit(const ProjectExplorer::Kit *k);
@@ -237,7 +236,9 @@ public:
static void populateQmlFileFinder(Utils::FileInProjectFinder *finder, static void populateQmlFileFinder(Utils::FileInProjectFinder *finder,
const ProjectExplorer::Target *target); const ProjectExplorer::Target *target);
QSet<Core::Id> features() const;
protected: protected:
virtual QSet<Core::Id> availableFeatures() const;
BaseQtVersion(); BaseQtVersion();
BaseQtVersion(const Utils::FileName &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); BaseQtVersion(const Utils::FileName &path, bool isAutodetected = false, const QString &autodetectionSource = QString());
BaseQtVersion(const BaseQtVersion &other); BaseQtVersion(const BaseQtVersion &other);
@@ -294,6 +295,7 @@ private:
QString m_unexpandedDisplayName; QString m_unexpandedDisplayName;
QString m_autodetectionSource; QString m_autodetectionSource;
QSet<Core::Id> m_overrideFeatures;
mutable Utils::FileName m_sourcePath; mutable Utils::FileName m_sourcePath;
mutable Utils::FileName m_qtSources; mutable Utils::FileName m_qtSources;

View File

@@ -231,7 +231,7 @@ Kit::Predicate QtKitInformation::qtVersionPredicate(const QSet<Core::Id> &requir
return false; return false;
if (max.majorVersion > -1 && current > max) if (max.majorVersion > -1 && current > max)
return false; return false;
return version->availableFeatures().contains(required); return version->features().contains(required);
}; };
} }
@@ -244,7 +244,7 @@ QSet<Core::Id> QtKitInformation::supportedPlatforms(const Kit *k) const
QSet<Core::Id> QtKitInformation::availableFeatures(const Kit *k) const QSet<Core::Id> QtKitInformation::availableFeatures(const Kit *k) const
{ {
BaseQtVersion *version = QtKitInformation::qtVersion(k); BaseQtVersion *version = QtKitInformation::qtVersion(k);
return version ? version->availableFeatures() : QSet<Core::Id>(); return version ? version->features() : QSet<Core::Id>();
} }
} // namespace QtSupport } // namespace QtSupport