Commit 05117213 authored by Tobias Hunger's avatar Tobias Hunger

Core: Make Id and Feature more separate

Remove Id from the public interfaces of Feature and FeatureSet and
disallow implicit conversions from Id to Feature.

Change-Id: I33ba692ce82552f0c2b867c6c57b9c8547264243
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent 60a8442d
......@@ -55,32 +55,30 @@ public:
class CORE_EXPORT Feature : public Id
{
public:
Feature(Id id) : Id(id) {}
Feature() = default;
template <int N> Feature(const char(&ch)[N]) : Id(ch) { }
static Feature fromString(const QString &str) { return Feature(Id::fromString(str)); }
static Feature fromName(const QByteArray &ba) { return Feature(Id::fromName(ba)); }
private:
explicit Feature(const Id id) : Id(id) { }
};
class CORE_EXPORT FeatureSet : private QSet<Feature>
{
public:
FeatureSet() {}
FeatureSet(Id id)
explicit FeatureSet(Feature id)
{
if (id.isValid())
insert(id);
}
FeatureSet(const FeatureSet &other) : QSet<Feature>(other) {}
FeatureSet &operator=(const FeatureSet &other)
{
QSet<Feature>::operator=(other);
return *this;
}
FeatureSet() = default;
FeatureSet(const FeatureSet &other) = default;
FeatureSet &operator=(const FeatureSet &other) = default;
bool isEmpty() const
{
return QSet<Feature>::isEmpty();
}
using QSet<Feature>::isEmpty;
bool contains(const Feature &feature) const
{
......@@ -144,7 +142,7 @@ public:
{
FeatureSet features;
foreach (const QString &i, list)
features |= Feature(Id::fromString(i));
features |= Feature::fromString(i);
return features;
}
};
......
......@@ -43,7 +43,7 @@ namespace Internal {
FormClassWizard::FormClassWizard()
{
setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QWIDGETS));
setRequiredFeatures(Core::FeatureSet(QtSupport::Constants::FEATURE_QWIDGETS));
}
QString FormClassWizard::headerSuffix() const
......
......@@ -461,10 +461,8 @@ static inline FeatureSet readRequiredFeatures(const QXmlStreamReader &reader)
QString value = reader.attributes().value(QLatin1String(featuresRequiredC)).toString();
QStringList stringList = value.split(QLatin1Char(','), QString::SkipEmptyParts);
FeatureSet features;
foreach (const QString &string, stringList) {
Feature feature(Id::fromString(string));
features |= feature;
}
foreach (const QString &string, stringList)
features |= Feature::fromString(string);
return features;
}
......
......@@ -167,7 +167,7 @@ QVector<JsonKitsPage::ConditionalFeature> JsonKitsPage::parseFeatures(const QVar
foreach (const QVariant &element, data.toList()) {
if (element.type() == QVariant::String) {
result.append({ Id::fromString(element.toString()), QVariant(true) });
result.append({ Feature::fromString(element.toString()), QVariant(true) });
} else if (element.type() == QVariant::Map) {
const QVariantMap obj = element.toMap();
const QString feature = obj.value(QLatin1String(KEY_FEATURE)).toString();
......@@ -177,7 +177,7 @@ QVector<JsonKitsPage::ConditionalFeature> JsonKitsPage::parseFeatures(const QVar
return QVector<ConditionalFeature>();
}
result.append({ Id::fromString(feature), obj.value(QLatin1String(KEY_CONDITION), true) });
result.append({ Feature::fromString(feature), obj.value(QLatin1String(KEY_CONDITION), true) });
} else {
if (errorMessage)
*errorMessage = tr("Feature list element is not a string or object.");
......
......@@ -57,7 +57,7 @@ public:
class ConditionalFeature {
public:
ConditionalFeature() : feature(Core::Id()) { }
ConditionalFeature() = default;
ConditionalFeature(const Core::Feature &f, const QVariant &c) : feature(f), condition(c)
{ }
......
......@@ -346,7 +346,7 @@ Core::FeatureSet DeviceTypeKitInformation::availableFeatures(const Kit *k) const
Core::Id id = DeviceTypeKitInformation::deviceTypeId(k);
Core::FeatureSet result;
if (id.isValid())
result |= Core::Feature(Core::Id::fromString(QString::fromLatin1("DeviceType.") + id.toString()));
result |= Core::Feature::fromString(QString::fromLatin1("DeviceType.") + id.toString());
return result;
}
......
......@@ -52,7 +52,7 @@ CustomWidgetWizard::CustomWidgetWizard()
setDisplayName(tr("Qt Custom Designer Widget"));
setDescription(tr("Creates a Qt Custom Designer Widget or a Custom Widget Collection."));
setIcon(QIcon(QLatin1String(":/wizards/images/gui.png")));
setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QWIDGETS));
setRequiredFeatures(Core::FeatureSet(QtSupport::Constants::FEATURE_QWIDGETS));
}
Core::BaseFileWizard *CustomWidgetWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const
......
......@@ -83,7 +83,7 @@ GuiAppWizard::GuiAppWizard()
"Includes a Qt Designer-based main window.\n\n"
"Preselects a desktop Qt for building the application if available."));
setIcon(QIcon(QLatin1String(":/wizards/images/gui.png")));
setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QWIDGETS));
setRequiredFeatures(Core::FeatureSet(QtSupport::Constants::FEATURE_QWIDGETS));
}
Core::BaseFileWizard *GuiAppWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const
......
......@@ -56,7 +56,7 @@ LibraryWizard::LibraryWizard()
"<li>a shared C++ library for use with <tt>QPluginLoader</tt> and runtime (Plugins)</li>"
"<li>a shared or static C++ library for use with another project at linktime</li></ul>"));
setIcon(QIcon(QLatin1String(":/wizards/images/lib.png")));
setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT));
setRequiredFeatures(Core::FeatureSet(QtSupport::Constants::FEATURE_QT));
}
Core::BaseFileWizard *LibraryWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const
......
......@@ -51,7 +51,7 @@ SubdirsProjectWizard::SubdirsProjectWizard()
setDescription(tr("Creates a qmake-based subdirs project. This allows you to group "
"your projects in a tree structure."));
setIcon(QIcon(QLatin1String(":/wizards/images/gui.png")));
setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT));
setRequiredFeatures(Core::FeatureSet(QtSupport::Constants::FEATURE_QT));
}
Core::BaseFileWizard *SubdirsProjectWizard::create(QWidget *parent,
......
......@@ -102,9 +102,9 @@ FeatureSet QtVersionNumber::features() const
result |= Feature(Constants::FEATURE_QT);
if (majorVersion >= 0) {
QString featureMajor = QString::fromLatin1(Constants::FEATURE_QT) + QString::number(majorVersion);
result |= Feature(Id::fromString(featureMajor));
result |= Feature::fromString(featureMajor);
for (int i = 0; i <= minorVersion; ++i)
result |= Feature(Id::fromString(featureMajor + QLatin1Char('.') + QString::number(i)));
result |= Feature::fromString(featureMajor + QLatin1Char('.') + QString::number(i));
}
return result;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment