From 28f6fec97dc0799707a5104672f1d5da9122ccdb Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 15 Jan 2013 16:11:50 +0100 Subject: [PATCH] Features: Use Core::Id as base Change-Id: Iab812778f8f924638224ec343cadac70e8854e4f Reviewed-by: Thomas Hartmann --- src/plugins/coreplugin/featureprovider.h | 17 ++----- .../customwizard/customwizardparameters.cpp | 46 ++++++++++--------- .../qmlapplicationwizard.cpp | 11 ++--- .../wizards/qtquickappwizard.cpp | 2 +- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/plugins/coreplugin/featureprovider.h b/src/plugins/coreplugin/featureprovider.h index 7313bbf9690..3f2b1056c7c 100644 --- a/src/plugins/coreplugin/featureprovider.h +++ b/src/plugins/coreplugin/featureprovider.h @@ -38,11 +38,6 @@ #include #include - -namespace Utils { -class AbstractMacroExpander; -} - namespace Core { class CORE_EXPORT FeatureSet; @@ -61,10 +56,8 @@ public: class CORE_EXPORT Feature : public Id { -friend class FeatureSet; public: - Feature(const char *name) : Id(QByteArray(name)) {} - explicit Feature(const QString &name) : Id(name) {} + Feature(Id id) : Id(id) {} }; class CORE_EXPORT FeatureSet : private QSet @@ -72,12 +65,10 @@ class CORE_EXPORT FeatureSet : private QSet public: FeatureSet() {} - FeatureSet(const Feature &feature) + FeatureSet(Core::Id id) { - if (feature.toString().isEmpty()) - return; - - insert(feature); + if (id.isValid()) + insert(id); } FeatureSet(const FeatureSet &other) : QSet(other) {} diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp index bd6d56e8165..c95f3c970a7 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp @@ -52,6 +52,8 @@ enum { debug = 0 }; +using namespace Core; + static const char customWizardElementC[] = "wizard"; static const char iconElementC[] = "icon"; static const char descriptionElementC[] = "description"; @@ -271,8 +273,8 @@ static inline bool assignLanguageElementText(QXmlStreamReader &reader, // as an exercise to the reader. static inline bool assignLanguageElementText(QXmlStreamReader &reader, const QString &desiredLanguage, - Core::BaseFileWizardParameters *bp, - void (Core::BaseFileWizardParameters::*setter)(const QString &)) + BaseFileWizardParameters *bp, + void (BaseFileWizardParameters::*setter)(const QString &)) { const QStringRef elementLanguage = reader.attributes().value(QLatin1String(langAttributeC)); if (elementLanguage.isEmpty()) { @@ -295,7 +297,7 @@ static bool parseCustomProjectElement(QXmlStreamReader &reader, const QString &configFileFullPath, const QString &language, CustomWizardParameters *p, - Core::BaseFileWizardParameters *bp) + BaseFileWizardParameters *bp) { const QStringRef elementName = reader.name(); if (elementName == QLatin1String(iconElementC)) { @@ -311,17 +313,17 @@ static bool parseCustomProjectElement(QXmlStreamReader &reader, } if (elementName == QLatin1String(descriptionElementC)) { assignLanguageElementText(reader, language, bp, - &Core::BaseFileWizardParameters::setDescription); + &BaseFileWizardParameters::setDescription); return true; } if (elementName == QLatin1String(displayNameElementC)) { assignLanguageElementText(reader, language, bp, - &Core::BaseFileWizardParameters::setDisplayName); + &BaseFileWizardParameters::setDisplayName); return true; } if (elementName == QLatin1String(displayCategoryElementC)) { assignLanguageElementText(reader, language, bp, - &Core::BaseFileWizardParameters::setDisplayCategory); + &BaseFileWizardParameters::setDisplayCategory); return true; } if (elementName == QLatin1String(fieldPageTitleElementC)) { @@ -473,38 +475,38 @@ static ParseState nextClosingState(ParseState in, const QStringRef &name) } // Parse kind attribute -static inline Core::IWizard::WizardKind kindAttribute(const QXmlStreamReader &r) +static inline IWizard::WizardKind kindAttribute(const QXmlStreamReader &r) { const QStringRef value = r.attributes().value(QLatin1String(kindAttributeC)); if (!value.isEmpty()) { if (value == QLatin1String("file")) - return Core::IWizard::FileWizard; + return IWizard::FileWizard; if (value == QLatin1String("class")) - return Core::IWizard::ClassWizard; + return IWizard::ClassWizard; } - return Core::IWizard::ProjectWizard; + return IWizard::ProjectWizard; } -static inline Core::FeatureSet requiredFeatures(const QXmlStreamReader &reader) +static inline FeatureSet requiredFeatures(const QXmlStreamReader &reader) { - Core::FeatureSet r; + FeatureSet r; QString value = reader.attributes().value(QLatin1String(featuresRequiredC)).toString(); QStringList stringList = value.split(QLatin1Char(','), QString::SkipEmptyParts); - Core::FeatureSet features; + FeatureSet features; foreach (const QString &string, stringList) { - Core::Feature feature(string); + Feature feature(Id::fromString(string)); features |= feature; } return features; } -static inline Core::IWizard::WizardFlags wizardFlags(const QXmlStreamReader &reader) +static inline IWizard::WizardFlags wizardFlags(const QXmlStreamReader &reader) { - Core::IWizard::WizardFlags flags; + IWizard::WizardFlags flags; QString value = reader.attributes().value(QLatin1String(platformIndependentC)).toString(); if (!value.isEmpty() && value == QLatin1String("true")) - flags |= Core::IWizard::PlatformIndependent; + flags |= IWizard::PlatformIndependent; return flags; } @@ -549,7 +551,7 @@ static inline QString attributeValue(const QXmlStreamReader &r, const char *name // Return locale language attribute "de_UTF8" -> "de", empty string for "C" static inline QString languageSetting() { - QString name = Core::ICore::userInterfaceLanguage(); + QString name = ICore::userInterfaceLanguage(); const int underScorePos = name.indexOf(QLatin1Char('_')); if (underScorePos != -1) name.truncate(underScorePos); @@ -577,7 +579,7 @@ GeneratorScriptArgument::GeneratorScriptArgument(const QString &v) : CustomWizardParameters::ParseResult CustomWizardParameters::parse(QIODevice &device, const QString &configFileFullPath, - Core::BaseFileWizardParameters *bp, + BaseFileWizardParameters *bp, QString *errorMessage) { int comboEntryCount = 0; @@ -586,7 +588,7 @@ CustomWizardParameters::ParseResult ParseState state = ParseBeginning; clear(); bp->clear(); - bp->setKind(Core::IWizard::ProjectWizard); + bp->setKind(IWizard::ProjectWizard); const QString language = languageSetting(); CustomWizardField field; do { @@ -729,7 +731,7 @@ CustomWizardParameters::ParseResult CustomWizardParameters::ParseResult CustomWizardParameters::parse(const QString &configFileFullPath, - Core::BaseFileWizardParameters *bp, + BaseFileWizardParameters *bp, QString *errorMessage) { QFile configFile(configFileFullPath); @@ -994,7 +996,7 @@ void CustomWizardContext::reset() { // Basic replacement fields: Suffixes. baseReplacements.clear(); - const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase(); + const MimeDatabase *mdb = ICore::mimeDatabase(); baseReplacements.insert(QLatin1String("CppSourceSuffix"), mdb->preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE))); baseReplacements.insert(QLatin1String("CppHeaderSuffix"), diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp b/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp index 1239c197f11..65334391fe1 100644 --- a/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp +++ b/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp @@ -49,12 +49,12 @@ #include "qmlproject.h" #include -#include #include -#include #include +#include #include #include +#include using namespace Core; using namespace ExtensionSystem; @@ -99,9 +99,9 @@ void QmlApplicationWizard::createInstances(ExtensionSystem::IPlugin *plugin) QStringList stringList = templateInfo.featuresRequired.split(QLatin1Char(','), QString::SkipEmptyParts);; - Core::FeatureSet features; + FeatureSet features; foreach (const QString &string, stringList) { - Core::Feature feature(string.trimmed()); + Feature feature(Id::fromString(string.trimmed())); features |= feature; } @@ -126,8 +126,7 @@ BaseFileWizardParameters QmlApplicationWizard::parameters() } QWizard *QmlApplicationWizard::createWizardDialog(QWidget *parent, - const Core::WizardDialogParameters &wizardDialogParameters - ) const + const WizardDialogParameters &wizardDialogParameters) const { QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(m_qmlApp, parent, wizardDialogParameters); diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp index c681240d738..93ca78d9da3 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp @@ -166,7 +166,7 @@ void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin) "platform.\n\nRequires Qt 4.7.4 or newer, and the " "component set installed for your Qt version.")); parameter.setRequiredFeatures(basicFeatures | Core::Feature(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_MEEGO) - | QtSupport::Constants::FEATURE_QT_QUICK_1_1); + | Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_1_1)); list << parameter; parameter = base;