Features: Use Core::Id as base

Change-Id: Iab812778f8f924638224ec343cadac70e8854e4f
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
hjk
2013-01-15 16:11:50 +01:00
parent 2ab6416a34
commit 28f6fec97d
4 changed files with 34 additions and 42 deletions

View File

@@ -38,11 +38,6 @@
#include <QSet>
#include <QStringList>
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<Feature>
@@ -72,12 +65,10 @@ class CORE_EXPORT FeatureSet : private QSet<Feature>
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<Feature>(other) {}

View File

@@ -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"),

View File

@@ -49,12 +49,12 @@
#include "qmlproject.h"
#include <QCoreApplication>
#include <QFileInfo>
#include <QDirIterator>
#include <QUrl>
#include <QFileDialog>
#include <QFileInfo>
#include <QIcon>
#include <QMessageBox>
#include <QUrl>
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);

View File

@@ -166,7 +166,7 @@ void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin)
"platform.\n\nRequires <b>Qt 4.7.4</b> 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;