forked from qt-creator/qt-creator
Features: Use Core::Id as base
Change-Id: Iab812778f8f924638224ec343cadac70e8854e4f Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -38,11 +38,6 @@
|
|||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
class AbstractMacroExpander;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class CORE_EXPORT FeatureSet;
|
class CORE_EXPORT FeatureSet;
|
||||||
@@ -61,10 +56,8 @@ public:
|
|||||||
|
|
||||||
class CORE_EXPORT Feature : public Id
|
class CORE_EXPORT Feature : public Id
|
||||||
{
|
{
|
||||||
friend class FeatureSet;
|
|
||||||
public:
|
public:
|
||||||
Feature(const char *name) : Id(QByteArray(name)) {}
|
Feature(Id id) : Id(id) {}
|
||||||
explicit Feature(const QString &name) : Id(name) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CORE_EXPORT FeatureSet : private QSet<Feature>
|
class CORE_EXPORT FeatureSet : private QSet<Feature>
|
||||||
@@ -72,12 +65,10 @@ class CORE_EXPORT FeatureSet : private QSet<Feature>
|
|||||||
public:
|
public:
|
||||||
FeatureSet() {}
|
FeatureSet() {}
|
||||||
|
|
||||||
FeatureSet(const Feature &feature)
|
FeatureSet(Core::Id id)
|
||||||
{
|
{
|
||||||
if (feature.toString().isEmpty())
|
if (id.isValid())
|
||||||
return;
|
insert(id);
|
||||||
|
|
||||||
insert(feature);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FeatureSet(const FeatureSet &other) : QSet<Feature>(other) {}
|
FeatureSet(const FeatureSet &other) : QSet<Feature>(other) {}
|
||||||
|
@@ -52,6 +52,8 @@
|
|||||||
|
|
||||||
enum { debug = 0 };
|
enum { debug = 0 };
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
static const char customWizardElementC[] = "wizard";
|
static const char customWizardElementC[] = "wizard";
|
||||||
static const char iconElementC[] = "icon";
|
static const char iconElementC[] = "icon";
|
||||||
static const char descriptionElementC[] = "description";
|
static const char descriptionElementC[] = "description";
|
||||||
@@ -271,8 +273,8 @@ static inline bool assignLanguageElementText(QXmlStreamReader &reader,
|
|||||||
// as an exercise to the reader.
|
// as an exercise to the reader.
|
||||||
static inline bool assignLanguageElementText(QXmlStreamReader &reader,
|
static inline bool assignLanguageElementText(QXmlStreamReader &reader,
|
||||||
const QString &desiredLanguage,
|
const QString &desiredLanguage,
|
||||||
Core::BaseFileWizardParameters *bp,
|
BaseFileWizardParameters *bp,
|
||||||
void (Core::BaseFileWizardParameters::*setter)(const QString &))
|
void (BaseFileWizardParameters::*setter)(const QString &))
|
||||||
{
|
{
|
||||||
const QStringRef elementLanguage = reader.attributes().value(QLatin1String(langAttributeC));
|
const QStringRef elementLanguage = reader.attributes().value(QLatin1String(langAttributeC));
|
||||||
if (elementLanguage.isEmpty()) {
|
if (elementLanguage.isEmpty()) {
|
||||||
@@ -295,7 +297,7 @@ static bool parseCustomProjectElement(QXmlStreamReader &reader,
|
|||||||
const QString &configFileFullPath,
|
const QString &configFileFullPath,
|
||||||
const QString &language,
|
const QString &language,
|
||||||
CustomWizardParameters *p,
|
CustomWizardParameters *p,
|
||||||
Core::BaseFileWizardParameters *bp)
|
BaseFileWizardParameters *bp)
|
||||||
{
|
{
|
||||||
const QStringRef elementName = reader.name();
|
const QStringRef elementName = reader.name();
|
||||||
if (elementName == QLatin1String(iconElementC)) {
|
if (elementName == QLatin1String(iconElementC)) {
|
||||||
@@ -311,17 +313,17 @@ static bool parseCustomProjectElement(QXmlStreamReader &reader,
|
|||||||
}
|
}
|
||||||
if (elementName == QLatin1String(descriptionElementC)) {
|
if (elementName == QLatin1String(descriptionElementC)) {
|
||||||
assignLanguageElementText(reader, language, bp,
|
assignLanguageElementText(reader, language, bp,
|
||||||
&Core::BaseFileWizardParameters::setDescription);
|
&BaseFileWizardParameters::setDescription);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (elementName == QLatin1String(displayNameElementC)) {
|
if (elementName == QLatin1String(displayNameElementC)) {
|
||||||
assignLanguageElementText(reader, language, bp,
|
assignLanguageElementText(reader, language, bp,
|
||||||
&Core::BaseFileWizardParameters::setDisplayName);
|
&BaseFileWizardParameters::setDisplayName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (elementName == QLatin1String(displayCategoryElementC)) {
|
if (elementName == QLatin1String(displayCategoryElementC)) {
|
||||||
assignLanguageElementText(reader, language, bp,
|
assignLanguageElementText(reader, language, bp,
|
||||||
&Core::BaseFileWizardParameters::setDisplayCategory);
|
&BaseFileWizardParameters::setDisplayCategory);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (elementName == QLatin1String(fieldPageTitleElementC)) {
|
if (elementName == QLatin1String(fieldPageTitleElementC)) {
|
||||||
@@ -473,38 +475,38 @@ static ParseState nextClosingState(ParseState in, const QStringRef &name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse kind attribute
|
// 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));
|
const QStringRef value = r.attributes().value(QLatin1String(kindAttributeC));
|
||||||
if (!value.isEmpty()) {
|
if (!value.isEmpty()) {
|
||||||
if (value == QLatin1String("file"))
|
if (value == QLatin1String("file"))
|
||||||
return Core::IWizard::FileWizard;
|
return IWizard::FileWizard;
|
||||||
if (value == QLatin1String("class"))
|
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();
|
QString value = reader.attributes().value(QLatin1String(featuresRequiredC)).toString();
|
||||||
QStringList stringList = value.split(QLatin1Char(','), QString::SkipEmptyParts);
|
QStringList stringList = value.split(QLatin1Char(','), QString::SkipEmptyParts);
|
||||||
Core::FeatureSet features;
|
FeatureSet features;
|
||||||
foreach (const QString &string, stringList) {
|
foreach (const QString &string, stringList) {
|
||||||
Core::Feature feature(string);
|
Feature feature(Id::fromString(string));
|
||||||
features |= feature;
|
features |= feature;
|
||||||
}
|
}
|
||||||
return features;
|
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();
|
QString value = reader.attributes().value(QLatin1String(platformIndependentC)).toString();
|
||||||
|
|
||||||
if (!value.isEmpty() && value == QLatin1String("true"))
|
if (!value.isEmpty() && value == QLatin1String("true"))
|
||||||
flags |= Core::IWizard::PlatformIndependent;
|
flags |= IWizard::PlatformIndependent;
|
||||||
|
|
||||||
return flags;
|
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"
|
// Return locale language attribute "de_UTF8" -> "de", empty string for "C"
|
||||||
static inline QString languageSetting()
|
static inline QString languageSetting()
|
||||||
{
|
{
|
||||||
QString name = Core::ICore::userInterfaceLanguage();
|
QString name = ICore::userInterfaceLanguage();
|
||||||
const int underScorePos = name.indexOf(QLatin1Char('_'));
|
const int underScorePos = name.indexOf(QLatin1Char('_'));
|
||||||
if (underScorePos != -1)
|
if (underScorePos != -1)
|
||||||
name.truncate(underScorePos);
|
name.truncate(underScorePos);
|
||||||
@@ -577,7 +579,7 @@ GeneratorScriptArgument::GeneratorScriptArgument(const QString &v) :
|
|||||||
CustomWizardParameters::ParseResult
|
CustomWizardParameters::ParseResult
|
||||||
CustomWizardParameters::parse(QIODevice &device,
|
CustomWizardParameters::parse(QIODevice &device,
|
||||||
const QString &configFileFullPath,
|
const QString &configFileFullPath,
|
||||||
Core::BaseFileWizardParameters *bp,
|
BaseFileWizardParameters *bp,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
int comboEntryCount = 0;
|
int comboEntryCount = 0;
|
||||||
@@ -586,7 +588,7 @@ CustomWizardParameters::ParseResult
|
|||||||
ParseState state = ParseBeginning;
|
ParseState state = ParseBeginning;
|
||||||
clear();
|
clear();
|
||||||
bp->clear();
|
bp->clear();
|
||||||
bp->setKind(Core::IWizard::ProjectWizard);
|
bp->setKind(IWizard::ProjectWizard);
|
||||||
const QString language = languageSetting();
|
const QString language = languageSetting();
|
||||||
CustomWizardField field;
|
CustomWizardField field;
|
||||||
do {
|
do {
|
||||||
@@ -729,7 +731,7 @@ CustomWizardParameters::ParseResult
|
|||||||
|
|
||||||
CustomWizardParameters::ParseResult
|
CustomWizardParameters::ParseResult
|
||||||
CustomWizardParameters::parse(const QString &configFileFullPath,
|
CustomWizardParameters::parse(const QString &configFileFullPath,
|
||||||
Core::BaseFileWizardParameters *bp,
|
BaseFileWizardParameters *bp,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
QFile configFile(configFileFullPath);
|
QFile configFile(configFileFullPath);
|
||||||
@@ -994,7 +996,7 @@ void CustomWizardContext::reset()
|
|||||||
{
|
{
|
||||||
// Basic replacement fields: Suffixes.
|
// Basic replacement fields: Suffixes.
|
||||||
baseReplacements.clear();
|
baseReplacements.clear();
|
||||||
const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase();
|
const MimeDatabase *mdb = ICore::mimeDatabase();
|
||||||
baseReplacements.insert(QLatin1String("CppSourceSuffix"),
|
baseReplacements.insert(QLatin1String("CppSourceSuffix"),
|
||||||
mdb->preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)));
|
mdb->preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)));
|
||||||
baseReplacements.insert(QLatin1String("CppHeaderSuffix"),
|
baseReplacements.insert(QLatin1String("CppHeaderSuffix"),
|
||||||
|
@@ -49,12 +49,12 @@
|
|||||||
#include "qmlproject.h"
|
#include "qmlproject.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QUrl>
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace ExtensionSystem;
|
using namespace ExtensionSystem;
|
||||||
@@ -99,9 +99,9 @@ void QmlApplicationWizard::createInstances(ExtensionSystem::IPlugin *plugin)
|
|||||||
|
|
||||||
QStringList stringList =
|
QStringList stringList =
|
||||||
templateInfo.featuresRequired.split(QLatin1Char(','), QString::SkipEmptyParts);;
|
templateInfo.featuresRequired.split(QLatin1Char(','), QString::SkipEmptyParts);;
|
||||||
Core::FeatureSet features;
|
FeatureSet features;
|
||||||
foreach (const QString &string, stringList) {
|
foreach (const QString &string, stringList) {
|
||||||
Core::Feature feature(string.trimmed());
|
Feature feature(Id::fromString(string.trimmed()));
|
||||||
features |= feature;
|
features |= feature;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,8 +126,7 @@ BaseFileWizardParameters QmlApplicationWizard::parameters()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWizard *QmlApplicationWizard::createWizardDialog(QWidget *parent,
|
QWizard *QmlApplicationWizard::createWizardDialog(QWidget *parent,
|
||||||
const Core::WizardDialogParameters &wizardDialogParameters
|
const WizardDialogParameters &wizardDialogParameters) const
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(m_qmlApp,
|
QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(m_qmlApp,
|
||||||
parent, wizardDialogParameters);
|
parent, wizardDialogParameters);
|
||||||
|
@@ -166,7 +166,7 @@ void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin)
|
|||||||
"platform.\n\nRequires <b>Qt 4.7.4</b> or newer, and the "
|
"platform.\n\nRequires <b>Qt 4.7.4</b> or newer, and the "
|
||||||
"component set installed for your Qt version."));
|
"component set installed for your Qt version."));
|
||||||
parameter.setRequiredFeatures(basicFeatures | Core::Feature(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_MEEGO)
|
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;
|
list << parameter;
|
||||||
|
|
||||||
parameter = base;
|
parameter = base;
|
||||||
|
Reference in New Issue
Block a user