Commit 24a736b6 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Make the qmldump tool treat extended types correctly.

(cherry picked from commit 619d50f0)
parent 34f241c0
......@@ -275,17 +275,35 @@ int main(int argc, char *argv[])
metas.insert(FriendlyQObject::qtMeta());
// ### TODO: We don't treat extended types correctly. Currently only hits the
// QDeclarativeGraphicsWidget extension to QGraphicsWidget
QMultiHash<QByteArray, QByteArray> extensions;
foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) {
if (ty->isExtendedType())
continue;
cppToQml.insert(ty->metaObject()->className(), ty->qmlTypeName());
qmlTypeByCppName.insert(ty->metaObject()->className(), ty);
if (ty->isExtendedType()) {
extensions.insert(ty->typeName(), ty->metaObject()->className());
} else {
cppToQml.insert(ty->metaObject()->className(), ty->qmlTypeName());
}
processDeclarativeType(ty, &metas);
}
// Adjust qml names of extended objects.
// The chain ends up being:
// __extended__.originalname - the base object
// __extension_0_.originalname - first extension
// ..
// __extension_n-2_.originalname - second to last extension
// originalname - last extension
foreach (const QByteArray &extendedCpp, extensions.keys()) {
const QByteArray extendedQml = cppToQml.value(extendedCpp);
cppToQml.insert(extendedCpp, "__extended__." + extendedQml);
QList<QByteArray> extensionCppNames = extensions.values(extendedCpp);
for (int i = 0; i < extensionCppNames.size() - 1; ++i) {
QByteArray adjustedName = QString("__extension__%1.%2").arg(QString::number(i), QString(extendedQml)).toAscii();
cppToQml.insert(extensionCppNames.value(i), adjustedName);
}
cppToQml.insert(extensionCppNames.last(), extendedQml);
}
foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) {
if (ty->isExtendedType())
continue;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment