diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2011-09-29 10:29:22 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-29 14:59:15 +0200 |
commit | bcc9a4b3d10899f23b304fecb581aa0d50e1b4e5 (patch) | |
tree | 557b4391429873a0a30e122059a9b1207a1ddb3d /src/declarative/qml | |
parent | 15a52c1a5f9cf166305c264abc01e35bad918d84 (diff) |
Remove more QByteArray<->QString conversions
Prefer to store types as QStrings. It's only when we manipulate
raw (compiled, meta-)data that utf conversion is needed.
Change-Id: Ie138a69c9a409804e1b90b21c1d60dedea35bddb
Reviewed-on: http://codereview.qt-project.org/5781
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qdeclarativecompiler.cpp | 10 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativecompiler_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativecomponent.cpp | 6 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativecustomparser.cpp | 10 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativecustomparser_p.h | 8 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativecustomparser_p_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativedirparser.cpp | 6 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativedirparser_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeexpression_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeinfo.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativemetatype.cpp | 20 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativemetatype_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativescript.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativescript_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativevme.cpp | 2 |
16 files changed, 44 insertions, 44 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 8c26a3bfa6..69df595bb5 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -2235,7 +2235,7 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeScript::Pro 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>(); @@ -2294,7 +2294,7 @@ bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeScript::Propert 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; @@ -2360,7 +2360,7 @@ bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop 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) @@ -2429,10 +2429,10 @@ int QDeclarativeCompiler::evaluateEnum(const QByteArray& script) const 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; diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 993c733d40..5e3ad03924 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -278,7 +278,7 @@ public: 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: diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 0d390b093a..2f1ad82138 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -91,16 +91,16 @@ static inline QString buildTypeNameForDebug(const QMetaObject *metaObject) 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(); } } } diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp index e806707a06..4327110d18 100644 --- a/src/declarative/qml/qdeclarativecustomparser.cpp +++ b/src/declarative/qml/qdeclarativecustomparser.cpp @@ -114,7 +114,7 @@ QDeclarativeCustomParserProperty 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; @@ -164,7 +164,7 @@ QDeclarativeCustomParserNode::~QDeclarativeCustomParserNode() delete d; d = 0; } -QByteArray QDeclarativeCustomParserNode::name() const +QString QDeclarativeCustomParserNode::name() const { return d->name; } @@ -204,7 +204,7 @@ QDeclarativeCustomParserProperty::~QDeclarativeCustomParserProperty() delete d; d = 0; } -QByteArray QDeclarativeCustomParserProperty::name() const +QString QDeclarativeCustomParserProperty::name() const { return d->name; } @@ -292,7 +292,7 @@ int QDeclarativeCustomParser::evaluateEnum(const QByteArray& script) const 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); } @@ -302,7 +302,7 @@ const QMetaObject *QDeclarativeCustomParser::resolveType(const QByteArray& 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); } diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h index 47b3ee8f8e..9aca8030c7 100644 --- a/src/declarative/qml/qdeclarativecustomparser_p.h +++ b/src/declarative/qml/qdeclarativecustomparser_p.h @@ -78,7 +78,7 @@ public: QDeclarativeCustomParserProperty &operator=(const QDeclarativeCustomParserProperty &); ~QDeclarativeCustomParserProperty(); - QByteArray name() const; + QString name() const; QDeclarativeScript::Location location() const; bool isList() const; @@ -101,7 +101,7 @@ public: QDeclarativeCustomParserNode &operator=(const QDeclarativeCustomParserNode &); ~QDeclarativeCustomParserNode(); - QByteArray name() const; + QString name() const; QDeclarativeScript::Location location() const; QList<QDeclarativeCustomParserProperty> properties() const; @@ -140,9 +140,9 @@ protected: 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; diff --git a/src/declarative/qml/qdeclarativecustomparser_p_p.h b/src/declarative/qml/qdeclarativecustomparser_p_p.h index b11cb3432d..cebad26b33 100644 --- a/src/declarative/qml/qdeclarativecustomparser_p_p.h +++ b/src/declarative/qml/qdeclarativecustomparser_p_p.h @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeCustomParserNodePrivate { public: - QByteArray name; + QString name; QList<QDeclarativeCustomParserProperty> properties; QDeclarativeScript::Location location; @@ -78,7 +78,7 @@ public: QDeclarativeCustomParserPropertyPrivate() : isList(false) {} - QByteArray name; + QString name; bool isList; QDeclarativeScript::Location location; QList<QVariant> values; diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp index 69c323b3c6..08d953f3e4 100644 --- a/src/declarative/qml/qdeclarativedirparser.cpp +++ b/src/declarative/qml/qdeclarativedirparser.cpp @@ -186,7 +186,7 @@ bool QDeclarativeDirParser::parse() 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")) { @@ -202,7 +202,7 @@ bool QDeclarativeDirParser::parse() } 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]; @@ -220,7 +220,7 @@ bool QDeclarativeDirParser::parse() 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); } diff --git a/src/declarative/qml/qdeclarativedirparser_p.h b/src/declarative/qml/qdeclarativedirparser_p.h index 8540747055..696c2e1932 100644 --- a/src/declarative/qml/qdeclarativedirparser_p.h +++ b/src/declarative/qml/qdeclarativedirparser_p.h @@ -98,11 +98,11 @@ public: 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; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 4c8d48f6ef..1e35f0a0ba 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -952,7 +952,7 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object) 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); @@ -1580,7 +1580,7 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeTy 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; } diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h index e9ee69960e..9feea5ca22 100644 --- a/src/declarative/qml/qdeclarativeexpression_p.h +++ b/src/declarative/qml/qdeclarativeexpression_p.h @@ -222,7 +222,7 @@ public: 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; }; diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp index 995a6b9ad7..d221eaeefb 100644 --- a/src/declarative/qml/qdeclarativeinfo.cpp +++ b/src/declarative/qml/qdeclarativeinfo.cpp @@ -120,7 +120,7 @@ QDeclarativeInfo::~QDeclarativeInfo() 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); @@ -136,7 +136,7 @@ QDeclarativeInfo::~QDeclarativeInfo() 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); diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index 4289dee907..ebe9808db3 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -180,7 +180,7 @@ public: 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; @@ -242,9 +242,9 @@ QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::Registe 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; @@ -517,14 +517,14 @@ QByteArray QDeclarativeType::typeName() const 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; } @@ -861,7 +861,7 @@ int registerInterface(const QDeclarativePrivate::RegisterInterface &interface) 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); @@ -895,7 +895,7 @@ int registerType(const QDeclarativePrivate::RegisterType &type) 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); diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h index 2a6ce20bbb..39e8b850d0 100644 --- a/src/declarative/qml/qdeclarativemetatype_p.h +++ b/src/declarative/qml/qdeclarativemetatype_p.h @@ -137,7 +137,7 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeType { public: QByteArray typeName() const; - const QByteArray &qmlTypeName() const; + const QString &qmlTypeName() const; const QString &elementName() const; QString module() const; diff --git a/src/declarative/qml/qdeclarativescript.cpp b/src/declarative/qml/qdeclarativescript.cpp index 9e6e09ed0c..8fb423c308 100644 --- a/src/declarative/qml/qdeclarativescript.cpp +++ b/src/declarative/qml/qdeclarativescript.cpp @@ -736,7 +736,7 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName, // 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; diff --git a/src/declarative/qml/qdeclarativescript_p.h b/src/declarative/qml/qdeclarativescript_p.h index a985fd7a8a..e27024161b 100644 --- a/src/declarative/qml/qdeclarativescript_p.h +++ b/src/declarative/qml/qdeclarativescript_p.h @@ -309,7 +309,7 @@ public: 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 diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index d3748a4974..bf81ae4fde 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -793,7 +793,7 @@ QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors, 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) |