QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
if (type) {
- QString typeName = QLatin1String(type->qmlTypeName());
+ QString typeName = type->qmlTypeName();
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1);
} else {
QDeclarativeScript::Object *root = v->object;
QDeclarativeScript::Object *component = pool->New<Object>();
component->type = componentTypeRef();
- component->typeName = "Qt/Component";
+ component->typeName = QStringLiteral("Qt/Component");
component->metatype = &QDeclarativeComponent::staticMetaObject;
component->location = root->location;
QDeclarativeScript::Value *componentValue = pool->New<Value>();
buildDynamicMeta(baseObj, ForceCreation);
v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
} else {
- COMPILE_EXCEPTION(v, tr("\"%1\" cannot operate on \"%2\"").arg(QString::fromUtf8(v->object->typeName)).arg(prop->name().toString()));
+ COMPILE_EXCEPTION(v, tr("\"%1\" cannot operate on \"%2\"").arg(v->object->typeName).arg(prop->name().toString()));
}
return true;
unit->imports().resolveType(typeName, &type, 0, 0, 0, 0);
//handle enums on value types (where obj->typeName is empty)
- QByteArray objTypeName = obj->typeName;
+ QString objTypeName = obj->typeName;
if (objTypeName.isEmpty()) {
QDeclarativeType *objType = toQmlType(obj);
if (objType)
return -1;
}
-const QMetaObject *QDeclarativeCompiler::resolveType(const QByteArray& name) const
+const QMetaObject *QDeclarativeCompiler::resolveType(const QString& name) const
{
QDeclarativeType *qmltype = 0;
- if (!unit->imports().resolveType(QString::fromUtf8(name), &qmltype, 0, 0, 0, 0))
+ if (!unit->imports().resolveType(name, &qmltype, 0, 0, 0, 0))
return 0;
if (!qmltype)
return 0;
static bool isSignalPropertyName(const QHashedStringRef &);
int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum
- const QMetaObject *resolveType(const QByteArray& name) const; // for QDeclarativeCustomParser::resolveType
+ const QMetaObject *resolveType(const QString& name) const; // for QDeclarativeCustomParser::resolveType
int rewriteBinding(const QString& expression, const QString& name); // for QDeclarativeCustomParser::rewriteBinding
private:
static const QChar underscore(QLatin1Char('_'));
static const QChar asterisk(QLatin1Char('*'));
QDeclarativeType *type = QDeclarativeMetaType::qmlType(metaObject);
- QString typeName = type ? QLatin1String(type->qmlTypeName()) : QLatin1String(metaObject->className());
+ QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(metaObject->className());
if (!type) {
//### optimize further?
int marker = typeName.indexOf(qmlMarker);
if (marker != -1 && marker < typeName.count() - 1) {
if (typeName[marker + 1] == underscore) {
const QString className = typeName.left(marker) + asterisk;
- type = QDeclarativeMetaType::qmlType(QMetaType::type(className.toLatin1()));
+ type = QDeclarativeMetaType::qmlType(QMetaType::type(className.toUtf8()));
if (type)
- typeName = QLatin1String(type->qmlTypeName());
+ typeName = type->qmlTypeName();
}
}
}
QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeScript::Property *p)
{
QDeclarativeCustomParserProperty prop;
- prop.d->name = p->name().toUtf8();
+ prop.d->name = p->name().toString();
prop.d->isList = p->values.isMany();
prop.d->location = p->location.start;
delete d; d = 0;
}
-QByteArray QDeclarativeCustomParserNode::name() const
+QString QDeclarativeCustomParserNode::name() const
{
return d->name;
}
delete d; d = 0;
}
-QByteArray QDeclarativeCustomParserProperty::name() const
+QString QDeclarativeCustomParserProperty::name() const
{
return d->name;
}
Resolves \a name to a type, or 0 if it is not a type. This can be used
to type-check object nodes.
*/
-const QMetaObject *QDeclarativeCustomParser::resolveType(const QByteArray& name) const
+const QMetaObject *QDeclarativeCustomParser::resolveType(const QString& name) const
{
return compiler->resolveType(name);
}
used to construct the binding later. \a name
is used as the name of the rewritten function.
*/
-QDeclarativeBinding::Identifier QDeclarativeCustomParser::rewriteBinding(const QString& expression, const QByteArray& name)
+QDeclarativeBinding::Identifier QDeclarativeCustomParser::rewriteBinding(const QString& expression, const QString& name)
{
return compiler->rewriteBinding(expression, name);
}
QDeclarativeCustomParserProperty &operator=(const QDeclarativeCustomParserProperty &);
~QDeclarativeCustomParserProperty();
- QByteArray name() const;
+ QString name() const;
QDeclarativeScript::Location location() const;
bool isList() const;
QDeclarativeCustomParserNode &operator=(const QDeclarativeCustomParserNode &);
~QDeclarativeCustomParserNode();
- QByteArray name() const;
+ QString name() const;
QDeclarativeScript::Location location() const;
QList<QDeclarativeCustomParserProperty> properties() const;
int evaluateEnum(const QByteArray&) const;
- const QMetaObject *resolveType(const QByteArray&) const;
+ const QMetaObject *resolveType(const QString&) const;
- QDeclarativeBinding::Identifier rewriteBinding(const QString&, const QByteArray&);
+ QDeclarativeBinding::Identifier rewriteBinding(const QString&, const QString&);
private:
QList<QDeclarativeError> exceptions;
class QDeclarativeCustomParserNodePrivate
{
public:
- QByteArray name;
+ QString name;
QList<QDeclarativeCustomParserProperty> properties;
QDeclarativeScript::Location location;
QDeclarativeCustomParserPropertyPrivate()
: isList(false) {}
- QByteArray name;
+ QString name;
bool isList;
QDeclarativeScript::Location location;
QList<QVariant> values;
QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
continue;
}
- Component entry(sections[1].toUtf8(), sections[2], -1, -1);
+ Component entry(sections[1], sections[2], -1, -1);
entry.internal = true;
_components.append(entry);
} else if (sections[0] == QLatin1String("typeinfo")) {
} else if (sectionCount == 2) {
// No version specified (should only be used for relative qmldir files)
- const Component entry(sections[0].toUtf8(), sections[1], -1, -1);
+ const Component entry(sections[0], sections[1], -1, -1);
_components.append(entry);
} else if (sectionCount == 3) {
const QString &version = sections[1];
const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber);
if (validVersionNumber) {
- const Component entry(sections[0].toUtf8(), sections[2], majorVersion, minorVersion);
+ const Component entry(sections[0], sections[2], majorVersion, minorVersion);
_components.append(entry);
}
Component()
: majorVersion(0), minorVersion(0), internal(false) {}
- Component(const QByteArray &typeName, const QString &fileName, int majorVersion, int minorVersion)
+ Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
: typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
internal(false) {}
- QByteArray typeName;
+ QString typeName;
QString fileName;
int majorVersion;
int minorVersion;
if (QDeclarativeDebugService::isDebuggingEnabled()) {
QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Creating);
QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
- QString typeName = type ? QLatin1String(type->qmlTypeName()) : QString::fromLatin1(object->metaObject()->className());
+ QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(object->metaObject()->className());
QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, typeName);
if (data->outerContext)
QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Creating, data->outerContext->url, data->lineNumber);
if (overloadError) {
if (hasCopied) raw->release();
- error.setDescription(QLatin1String("Type ") + QString::fromUtf8(type->qmlTypeName()) + QLatin1String(" ") + QString::number(type->majorVersion()) + QLatin1String(".") + QString::number(minorVersion) + QLatin1String(" contains an illegal property \"") + overloadName + QLatin1String("\". This is an error in the type's implementation."));
+ error.setDescription(QLatin1String("Type ") + type->qmlTypeName() + QLatin1String(" ") + QString::number(type->majorVersion()) + QLatin1String(".") + QString::number(minorVersion) + QLatin1String(" contains an illegal property \"") + overloadName + QLatin1String("\". This is an error in the type's implementation."));
return 0;
}
QString url; // This is a QString for a reason. QUrls are slooooooow...
int line;
- QByteArray name; //function name, hint for the debugger
+ QString name; //function name, hint for the debugger
QDeclarativeRefCount *dataRef;
};
QString typeName;
QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
if (type) {
- typeName = QLatin1String(type->qmlTypeName());
+ typeName = type->qmlTypeName();
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
if (lastSlash != -1)
typeName = typeName.mid(lastSlash+1);
typeName += QLatin1Char('*');
type = QDeclarativeMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
if (type) {
- typeName = QLatin1String(type->qmlTypeName());
+ typeName = type->qmlTypeName();
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
if (lastSlash != -1)
typeName = typeName.mid(lastSlash+1);
bool m_isInterface : 1;
const char *m_iid;
QString m_module;
- QByteArray m_name;
+ QString m_name;
QString m_elementName;
int m_version_maj;
int m_version_min;
QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::RegisterType &type)
: d(new QDeclarativeTypePrivate)
{
- QByteArray name = type.uri;
- if (type.uri) name += '/';
- name += type.elementName;
+ QString name = QString::fromUtf8(type.uri);
+ if (type.uri) name += QLatin1Char('/');
+ name += QString::fromUtf8(type.elementName);
d->m_module = QString::fromUtf8(type.uri);
d->m_name = name;
const QString &QDeclarativeType::elementName() const
{
if (d->m_elementName.isEmpty()) {
- QByteArray n = qmlTypeName();
- int idx = n.lastIndexOf('/');
- d->m_elementName = QString::fromUtf8(n.mid(idx + 1));
+ QString n = qmlTypeName();
+ int idx = n.lastIndexOf(QLatin1Char('/'));
+ d->m_elementName = n.mid(idx + 1);
}
return d->m_elementName;
}
-const QByteArray &QDeclarativeType::qmlTypeName() const
+const QString &QDeclarativeType::qmlTypeName() const
{
return d->m_name;
}
data->idToType.insert(type->qListTypeId(), type);
// XXX No insertMulti, so no multi-version interfaces?
if (!type->qmlTypeName().isEmpty())
- data->nameToType.insert(QString::fromUtf8(type->qmlTypeName()), type);
+ data->nameToType.insert(type->qmlTypeName(), type);
if (data->interfaces.size() <= interface.typeId)
data->interfaces.resize(interface.typeId + 16);
if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
if (!dtype->qmlTypeName().isEmpty())
- data->nameToType.insertMulti(QString::fromUtf8(dtype->qmlTypeName()), dtype);
+ data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
data->metaObjectToType.insertMulti(dtype->baseMetaObject(), dtype);
{
public:
QByteArray typeName() const;
- const QByteArray &qmlTypeName() const;
+ const QString &qmlTypeName() const;
const QString &elementName() const;
QString module() const;
// XXX this doesn't do anything (_scope never builds up)
_scope.append(resolvableObjectType);
- obj->typeName = qualifiedNameId().toUtf8();
+ obj->typeName = qualifiedNameId();
_scope.removeLast();
obj->location = location;
int type;
// The fully-qualified name of this type
- QByteArray typeName;
+ QString typeName;
// The id assigned to the object (if any). Set by the QDeclarativeCompiler
QString id;
// The id index assigned to the object (if any). Set by the QDeclarativeCompiler
QDeclarativeExpression *expr =
new QDeclarativeExpression(CTXT, context, PRIMITIVES.at(instr.value));
expr->setSourceLocation(COMP->name, instr.line);
- static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr))->name = DATAS.at(instr.name);
+ static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr))->name = QString::fromUtf8(DATAS.at(instr.name));
bs->setExpression(expr);
QML_END_INSTR(StoreSignal)
for(int ii = 0; ii < props.count(); ++ii)
{
- QString propName = QString::fromUtf8(props.at(ii).name());
+ QString propName = props.at(ii).name();
if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) {
error(props.at(ii), QDeclarativeConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
return QByteArray();
error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot contain nested elements"));
return false;
}
- if (nodeProp.name() == "id") {
+ if (nodeProp.name() == QStringLiteral("id")) {
error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot use reserved \"id\" property"));
return false;
}
ListInstruction li;
int ref = data.count();
- data.append(nodeProp.name());
+ data.append(nodeProp.name().toUtf8());
data.append('\0');
li.type = ListInstruction::Set;
li.dataIdx = ref;
{
QList<ListInstruction> instr;
QByteArray data;
- listElementTypeName = QByteArray(); // unknown
+ listElementTypeName = QString(); // unknown
for(int ii = 0; ii < customProps.count(); ++ii) {
const QDeclarativeCustomParserProperty &prop = customProps.at(ii);
if(!prop.name().isEmpty()) { // isn't default property
- error(prop, QDeclarativeListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name())));
+ error(prop, QDeclarativeListModel::tr("ListModel: undefined property '%1'").arg(prop.name()));
return QByteArray();
}
bool definesEmptyList(const QString &);
- QByteArray listElementTypeName;
+ QString listElementTypeName;
};
};
void
-QDeclarativePropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
- const QByteArray &pre,
+QDeclarativePropertyChangesParser::compileList(QList<QPair<QString, QVariant> > &list,
+ const QString &pre,
const QDeclarativeCustomParserProperty &prop)
{
- QByteArray propName = pre + prop.name();
+ QString propName = pre + prop.name();
QList<QVariant> values = prop.assignedValues();
for (int ii = 0; ii < values.count(); ++ii) {
QDeclarativeCustomParserProperty prop =
qvariant_cast<QDeclarativeCustomParserProperty>(value);
- QByteArray pre = propName + '.';
+ QString pre = propName + QLatin1Char('.');
compileList(list, pre, prop);
} else {
QByteArray
QDeclarativePropertyChangesParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
{
- QList<QPair<QByteArray, QVariant> > data;
+ QList<QPair<QString, QVariant> > data;
for(int ii = 0; ii < props.count(); ++ii)
- compileList(data, QByteArray(), props.at(ii));
+ compileList(data, QString(), props.at(ii));
QByteArray rv;
QDataStream ds(&rv, QIODevice::WriteOnly);
break;
}
- ds << QString::fromUtf8(data.at(ii).first) << isScript << var;
+ ds << data.at(ii).first << isScript << var;
if (isScript)
ds << id;
}
QDeclarativePropertyChangesParser()
: QDeclarativeCustomParser(AcceptsAttachedProperties) {}
- void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop);
+ void compileList(QList<QPair<QString, QVariant> > &list, const QString &pre, const QDeclarativeCustomParserProperty &prop);
virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
virtual void setCustomData(QObject *, const QByteArray &);
for(int ii = 0; ii < props.count(); ++ii)
{
- QString propName = QString::fromUtf8(props.at(ii).name());
+ QString propName = props.at(ii).name();
Qt::GestureType type;
if (propName == QLatin1String("onTap")) {
for(int ii = 0; ii < props.count(); ++ii)
{
- QString propName = QString::fromUtf8(props.at(ii).name());
+ QString propName = props.at(ii).name();
if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) {
error(props.at(ii), QDeclarative1Connections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
return QByteArray();
};
void
-QDeclarative1PropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
- const QByteArray &pre,
+QDeclarative1PropertyChangesParser::compileList(QList<QPair<QString, QVariant> > &list,
+ const QString &pre,
const QDeclarativeCustomParserProperty &prop)
{
- QByteArray propName = pre + prop.name();
+ QString propName = pre + prop.name();
QList<QVariant> values = prop.assignedValues();
for (int ii = 0; ii < values.count(); ++ii) {
QDeclarativeCustomParserProperty prop =
qvariant_cast<QDeclarativeCustomParserProperty>(value);
- QByteArray pre = propName + '.';
+ QString pre = propName + QLatin1Char('.');
compileList(list, pre, prop);
} else {
QByteArray
QDeclarative1PropertyChangesParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
{
- QList<QPair<QByteArray, QVariant> > data;
+ QList<QPair<QString, QVariant> > data;
for(int ii = 0; ii < props.count(); ++ii)
- compileList(data, QByteArray(), props.at(ii));
+ compileList(data, QString(), props.at(ii));
QByteArray rv;
QDataStream ds(&rv, QIODevice::WriteOnly);
break;
}
- ds << QString::fromUtf8(data.at(ii).first) << isScript << var;
+ ds << data.at(ii).first << isScript << var;
if (isScript)
ds << id;
}
QDeclarative1PropertyChangesParser()
: QDeclarativeCustomParser(AcceptsAttachedProperties) {}
- void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop);
+ void compileList(QList<QPair<QString, QVariant> > &list, const QString &pre, const QDeclarativeCustomParserProperty &prop);
virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
virtual void setCustomData(QObject *, const QByteArray &);
if (ty->typeName() == "QDeclarativeComponent")
continue;
- QByteArray tyName = ty->qmlTypeName();
- tyName = tyName.mid(tyName.lastIndexOf('/') + 1);
+ QString tyName = ty->qmlTypeName();
+ tyName = tyName.mid(tyName.lastIndexOf(QLatin1Char('/')) + 1);
if (tyName.isEmpty())
continue;
qWarning() << "Could not find QtObject type";
importCode = QByteArray("import QtQuick 2.0\n");
} else {
- QByteArray module = qtObjectType->qmlTypeName();
- module = module.mid(0, module.lastIndexOf('/'));
+ QString module = qtObjectType->qmlTypeName();
+ module = module.mid(0, module.lastIndexOf(QLatin1Char('/')));
importCode = QString("import %1 %2.%3\n").arg(module,
QString::number(qtObjectType->majorVersion()),
QString::number(qtObjectType->minorVersion())).toUtf8();