Commit 46e970c3 authored by Christian Kamm's avatar Christian Kamm
Browse files

qmldump: Fix for extended objects.

Before, extended objects had the same exports as the base object
which lead to trouble.

Change-Id: Id40f0e0fd2211db95020ce224cf2c52939e68df7
Reviewed-on: http://codereview.qt.nokia.com/642


Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 600ec853
......@@ -651,6 +651,22 @@ Module {
Property { name: "position"; type: "qreal" }
Property { name: "color"; type: "QColor" }
}
Component {
name: "QDeclarativeGraphicsWidget"
defaultProperty: "children"
prototype: "QGraphicsWidget"
exports: [
"Qt/QGraphicsWidget 4.7",
"QtQuick/QGraphicsWidget 1.0"
]
Property { name: "anchors"; type: "QDeclarativeAnchors"; isReadonly: true; isPointer: true }
Property { name: "left"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "right"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "horizontalCenter"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "top"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "bottom"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "verticalCenter"; type: "QDeclarativeAnchorLine"; isReadonly: true }
}
Component {
name: "QDeclarativeGrid"
defaultProperty: "data"
......@@ -2948,18 +2964,24 @@ Module {
Component {
name: "QGraphicsWidget"
defaultProperty: "children"
prototype: "__extended__.QGraphicsWidget"
exports: [
"Qt/QGraphicsWidget 4.7",
"QtQuick/QGraphicsWidget 1.0"
]
Property { name: "anchors"; type: "QDeclarativeAnchors"; isReadonly: true; isPointer: true }
Property { name: "left"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "right"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "horizontalCenter"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "top"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "bottom"; type: "QDeclarativeAnchorLine"; isReadonly: true }
Property { name: "verticalCenter"; type: "QDeclarativeAnchorLine"; isReadonly: true }
prototype: "QGraphicsObject"
Property { name: "palette"; type: "QPalette" }
Property { name: "font"; type: "QFont" }
Property { name: "layoutDirection"; type: "Qt::LayoutDirection" }
Property { name: "size"; type: "QSizeF" }
Property { name: "minimumSize"; type: "QSizeF" }
Property { name: "preferredSize"; type: "QSizeF" }
Property { name: "maximumSize"; type: "QSizeF" }
Property { name: "sizePolicy"; type: "QSizePolicy" }
Property { name: "focusPolicy"; type: "Qt::FocusPolicy" }
Property { name: "windowFlags"; type: "Qt::WindowFlags" }
Property { name: "windowTitle"; type: "string" }
Property { name: "geometry"; type: "QRectF" }
Property { name: "autoFillBackground"; type: "bool" }
Property { name: "layout"; type: "QGraphicsLayout"; isPointer: true }
Signal { name: "geometryChanged" }
Signal { name: "layoutChanged" }
Method { name: "close"; type: "bool" }
}
Component {
name: "QIntValidator"
......@@ -4305,31 +4327,5 @@ Module {
}
}
}
Component {
name: "__extended__.QGraphicsWidget"
defaultProperty: "children"
prototype: "QGraphicsObject"
exports: [
"Qt/QGraphicsWidget 4.7",
"QtQuick/QGraphicsWidget 1.0"
]
Property { name: "palette"; type: "QPalette" }
Property { name: "font"; type: "QFont" }
Property { name: "layoutDirection"; type: "Qt::LayoutDirection" }
Property { name: "size"; type: "QSizeF" }
Property { name: "minimumSize"; type: "QSizeF" }
Property { name: "preferredSize"; type: "QSizeF" }
Property { name: "maximumSize"; type: "QSizeF" }
Property { name: "sizePolicy"; type: "QSizePolicy" }
Property { name: "focusPolicy"; type: "Qt::FocusPolicy" }
Property { name: "windowFlags"; type: "Qt::WindowFlags" }
Property { name: "windowTitle"; type: "string" }
Property { name: "geometry"; type: "QRectF" }
Property { name: "autoFillBackground"; type: "bool" }
Property { name: "layout"; type: "QGraphicsLayout"; isPointer: true }
Signal { name: "geometryChanged" }
Signal { name: "layoutChanged" }
Method { name: "close"; type: "bool" }
}
Component { name: "QEasingCurve"; prototype: "QDeclarativeEasingValueType" }
}
......@@ -154,29 +154,36 @@ QSet<const QMetaObject *> collectReachableMetaObjects(const QString &importCode,
collectReachableMetaObjects(ty, &metas);
}
// Adjust ids 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
// ### does this actually work for multiple extensions? it seems like the prototypes might be wrong
foreach (const QByteArray &extendedCpp, extensions.keys()) {
cppToId.remove(extendedCpp);
const QByteArray extendedId = convertToId(extendedCpp);
cppToId.insert(extendedCpp, "__extended__." + extendedId);
QSet<QByteArray> extensionCppNames = extensions.value(extendedCpp);
int c = 0;
// Adjust exports of the base object if there are extensions.
// For each export of a base object there can be a single extension object overriding it.
// Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export
// of QGraphicsWidget.
foreach (const QByteArray &baseCpp, extensions.keys()) {
QSet<const QDeclarativeType *> baseExports = qmlTypesByCppName.value(baseCpp);
const QSet<QByteArray> extensionCppNames = extensions.value(baseCpp);
foreach (const QByteArray &extensionCppName, extensionCppNames) {
if (c != extensionCppNames.size() - 1) {
QByteArray adjustedName = QString("__extension__%1.%2").arg(QString::number(c), QString(extendedId)).toAscii();
cppToId.insert(extensionCppName, adjustedName);
} else {
cppToId.insert(extensionCppName, extendedId);
const QSet<const QDeclarativeType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
// remove extension exports from base imports
// unfortunately the QDeclarativeType pointers don't match, so can't use QSet::substract
QSet<const QDeclarativeType *> newBaseExports;
foreach (const QDeclarativeType *baseExport, baseExports) {
bool match = false;
foreach (const QDeclarativeType *extensionExport, extensionExports) {
if (baseExport->module() == extensionExport->module()
&& baseExport->majorVersion() == extensionExport->majorVersion()
&& baseExport->minorVersion() == extensionExport->minorVersion()) {
match = true;
break;
}
}
if (!match)
newBaseExports.insert(baseExport);
}
++c;
baseExports = newBaseExports;
}
qmlTypesByCppName[baseCpp] = baseExports;
}
// find even more QMetaObjects by instantiating QML types and running
......
Supports Markdown
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