QmlJS Live Preview: Showing object id's in context menu

To show the object string id's, the debug protocol is used to get them.
The problem is that the required methods in QDeclarativeContext(Data)
are not exposed, and it's too late to do it for 4.7.0. Hence this change
should be reverted in 4.8 when more efficient way of getting the id's
comes available.
This commit is contained in:
Lasse Holmstedt
2010-07-26 15:31:59 +02:00
parent fb681918c6
commit 689cbc06f1
9 changed files with 77 additions and 6 deletions

View File

@@ -130,6 +130,40 @@ void QmlJSDesignDebugClient::setSelectedItemsByObjectId(const QList<QDeclarative
sendMessage(message);
}
void recurseObjectIdList(const QDeclarativeDebugObjectReference &ref, QList<int> &debugIds, QList<QString> &objectIds)
{
debugIds << ref.debugId();
objectIds << ref.idString();
foreach(const QDeclarativeDebugObjectReference &child, ref.children()) {
recurseObjectIdList(child, debugIds, objectIds);
}
}
void QmlJSDesignDebugClient::setObjectIdList(const QList<QDeclarativeDebugObjectReference> &objectRoots)
{
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
QList<int> debugIds;
QList<QString> objectIds;
foreach(const QDeclarativeDebugObjectReference &ref, objectRoots) {
recurseObjectIdList(ref, debugIds, objectIds);
}
ds << QByteArray("OBJECT_ID_LIST")
<< debugIds.length();
Q_ASSERT(debugIds.length() == objectIds.length());
for(int i = 0; i < debugIds.length(); ++i) {
ds << debugIds[i] << objectIds[i];
}
sendMessage(message);
}
void QmlJSDesignDebugClient::reloadViewer()
{
if (!m_connection || !m_connection->isConnected())