forked from qt-creator/qt-creator
QmlJSInspector: Show property values
When using the "Select" tool, update the property inspector with the selected object's properties. Change-Id: Ie24d9ed01b871b2f8f1f408cf4b1c0661c15cc84 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -152,25 +152,42 @@ void ClientProxy::onCurrentObjectsChanged(const QList<int> &debugIds,
|
|||||||
bool requestIfNeeded)
|
bool requestIfNeeded)
|
||||||
{
|
{
|
||||||
QList<QmlDebugObjectReference> selectedItems;
|
QList<QmlDebugObjectReference> selectedItems;
|
||||||
|
m_fetchCurrentObjects.clear();
|
||||||
|
m_fetchCurrentObjectsQueryIds.clear();
|
||||||
foreach (int debugId, debugIds) {
|
foreach (int debugId, debugIds) {
|
||||||
QmlDebugObjectReference ref = objectReferenceForId(debugId);
|
QmlDebugObjectReference ref = objectReferenceForId(debugId);
|
||||||
if (ref.debugId() != -1) {
|
if (ref.debugId() != -1 && !ref.needsMoreData()) {
|
||||||
selectedItems << ref;
|
selectedItems << ref;
|
||||||
} else if (requestIfNeeded) {
|
} else if (requestIfNeeded) {
|
||||||
// ### FIXME right now, there's no way in the protocol to
|
m_fetchCurrentObjectsQueryIds << fetchContextObject(
|
||||||
// a) get some item and know its parent (although that's possible
|
QmlDebugObjectReference(debugId));
|
||||||
// by adding it to a separate plugin)
|
|
||||||
// b) add children to part of an existing tree.
|
|
||||||
// So the only choice that remains is to update the complete
|
|
||||||
// tree when we have an unknown debug id.
|
|
||||||
// break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit selectedItemsChanged(selectedItems);
|
emit selectedItemsChanged(selectedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientProxy::onCurrentObjectsFetched(quint32 queryId, const QVariant &result)
|
||||||
|
{
|
||||||
|
m_fetchCurrentObjectsQueryIds.removeOne(queryId);
|
||||||
|
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
||||||
|
m_fetchCurrentObjects.push_front(obj);
|
||||||
|
|
||||||
|
//If this is not a root object, check if we have the parent
|
||||||
|
QmlDebugObjectReference parent = objectReferenceForId(obj.parentId());
|
||||||
|
if (obj.parentId() != -1 && (parent.debugId() == -1 || parent.needsMoreData())) {
|
||||||
|
m_fetchCurrentObjectsQueryIds << fetchContextObject(
|
||||||
|
QmlDebugObjectReference(obj.parentId()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (const QmlDebugObjectReference &o, m_fetchCurrentObjects)
|
||||||
|
addObjectToTree(o);
|
||||||
|
emit selectedItemsChanged(QList<QmlDebugObjectReference>() <<
|
||||||
|
m_fetchCurrentObjects.last());
|
||||||
|
}
|
||||||
|
|
||||||
void ClientProxy::setSelectedItemsByDebugId(const QList<int> &debugIds)
|
void ClientProxy::setSelectedItemsByDebugId(const QList<int> &debugIds)
|
||||||
{
|
{
|
||||||
if (!isConnected())
|
if (!isConnected())
|
||||||
@@ -538,6 +555,8 @@ void ClientProxy::onResult(quint32 queryId, const QVariant &value, const QByteAr
|
|||||||
updateEngineList(value);
|
updateEngineList(value);
|
||||||
else if (queryId == m_contextQueryId)
|
else if (queryId == m_contextQueryId)
|
||||||
contextChanged(value);
|
contextChanged(value);
|
||||||
|
else if (m_fetchCurrentObjectsQueryIds.contains(queryId))
|
||||||
|
onCurrentObjectsFetched(queryId, value);
|
||||||
else
|
else
|
||||||
emit result(queryId, value);
|
emit result(queryId, value);
|
||||||
}
|
}
|
||||||
|
@@ -150,6 +150,7 @@ private slots:
|
|||||||
void newObjects();
|
void newObjects();
|
||||||
void objectWatchTriggered(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
void objectWatchTriggered(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
||||||
void onResult(quint32 queryId, const QVariant &value, const QByteArray &type);
|
void onResult(quint32 queryId, const QVariant &value, const QByteArray &type);
|
||||||
|
void onCurrentObjectsFetched(quint32 queryId, const QVariant &result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void contextChanged(const QVariant &value);
|
void contextChanged(const QVariant &value);
|
||||||
@@ -178,8 +179,10 @@ private:
|
|||||||
quint32 m_engineQueryId;
|
quint32 m_engineQueryId;
|
||||||
quint32 m_contextQueryId;
|
quint32 m_contextQueryId;
|
||||||
QList<quint32> m_objectTreeQueryIds;
|
QList<quint32> m_objectTreeQueryIds;
|
||||||
|
QList<quint32> m_fetchCurrentObjectsQueryIds;
|
||||||
|
|
||||||
QList<QmlDebugObjectReference> m_rootObjects;
|
QList<QmlDebugObjectReference> m_rootObjects;
|
||||||
|
QList<QmlDebugObjectReference> m_fetchCurrentObjects;
|
||||||
QmlDebugEngineReferenceList m_engines;
|
QmlDebugEngineReferenceList m_engines;
|
||||||
DebugIdHash m_debugIdHash;
|
DebugIdHash m_debugIdHash;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user