diff options
author | Bea Lam <bea.lam@nokia.com> | 2009-11-02 01:16:02 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2009-11-02 01:16:02 (GMT) |
commit | 55e2858f2146d72bc43bde850dbec0cf7aa055e6 (patch) | |
tree | ad72f4c53cc62bb285d56b0037c048b635115fce /src/declarative/qml/qmlenginedebug.cpp | |
parent | 37b5b477a044929bf69fe5f7251f2b5cbd892d93 (diff) | |
download | Qt-55e2858f2146d72bc43bde850dbec0cf7aa055e6.zip Qt-55e2858f2146d72bc43bde850dbec0cf7aa055e6.tar.gz Qt-55e2858f2146d72bc43bde850dbec0cf7aa055e6.tar.bz2 |
Make QmlBoundSignal children look like properties (instead of children)
in the debugger to reflect how signal properties are written in QML.
This also changes the FETCH_OBJECT reply stream to send children
data before property data.
Diffstat (limited to 'src/declarative/qml/qmlenginedebug.cpp')
-rw-r--r-- | src/declarative/qml/qmlenginedebug.cpp | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 8629f3a..7fb8d36 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -155,21 +155,61 @@ void QmlEngineDebugServer::buildObjectDump(QDataStream &message, QObject *object, bool recur) { message << objectData(object); - message << object->metaObject()->propertyCount(); - for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) - message << propertyData(object, ii); + // Some children aren't added to an object until particular properties are read + // - e.g. child state objects aren't added until the 'states' property is read - + // but this should only affect internal objects that aren't shown by the + // debugger anyway. QObjectList children = object->children(); - message << children.count() << recur; + + int childrenCount = children.count(); + for (int ii = 0; ii < children.count(); ++ii) { + if (QmlBoundSignal::cast(children[ii])) + --childrenCount; + } + + message << childrenCount << recur; + + QList<QmlObjectProperty> fakeProperties; for (int ii = 0; ii < children.count(); ++ii) { QObject *child = children.at(ii); - if (recur) - buildObjectDump(message, child, recur); - else - message << objectData(child); + QmlBoundSignal *signal = QmlBoundSignal::cast(child); + if (signal) { + QmlObjectProperty prop; + prop.type = QmlObjectProperty::SignalProperty; + prop.hasNotifySignal = false; + QmlExpression *expr = signal->expression(); + if (expr) { + prop.value = expr->expression(); + QObject *scope = expr->scopeObject(); + if (scope) { + QString sig = scope->metaObject()->method(signal->index()).signature(); + int lparen = sig.indexOf(QLatin1Char('(')); + if (lparen >= 0) { + QString methodName = sig.mid(0, lparen); + prop.name = QLatin1String("on") + methodName[0].toUpper() + + methodName.mid(1); + } + } + } + fakeProperties << prop; + } else { + if (recur) + buildObjectDump(message, child, recur); + else + message << objectData(child); + } } + + message << (object->metaObject()->propertyCount() + fakeProperties.count()); + + for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) + message << propertyData(object, ii); + + for (int ii = 0; ii < fakeProperties.count(); ++ii) + message << fakeProperties[ii]; } void QmlEngineDebugServer::buildObjectList(QDataStream &message, |