Merge remote-tracking branch 'origin/4.7'

Change-Id: Ib288796892faf5345d2a150a5ce0dadf91552924
This commit is contained in:
Eike Ziller
2018-06-04 16:33:03 +02:00
193 changed files with 2196 additions and 1542 deletions

View File

@@ -381,6 +381,51 @@ void QmlInspectorAgent::newObject(int engineId, int /*objectId*/, int /*parentId
m_delayQueryTimer.start();
}
static void sortChildrenIfNecessary(WatchItem *propertiesWatch)
{
if (boolSetting(SortStructMembers)) {
propertiesWatch->sortChildren([](const WatchItem *item1, const WatchItem *item2) {
return item1->name < item2->name;
});
}
}
static bool insertChildren(WatchItem *parent, const QVariant &value)
{
switch (value.type()) {
case QVariant::Map: {
const QVariantMap map = value.toMap();
for (auto it = map.begin(), end = map.end(); it != end; ++it) {
WatchItem *child = new WatchItem;
child->name = it.key();
child->value = it.value().toString();
child->type = QLatin1String(it.value().typeName());
child->valueEditable = false;
child->wantsChildren = insertChildren(child, it.value());
parent->appendChild(child);
}
sortChildrenIfNecessary(parent);
return true;
}
case QVariant::List: {
const QVariantList list = value.toList();
for (int i = 0, end = list.size(); i != end; ++i) {
WatchItem *child = new WatchItem;
const QVariant &value = list.at(i);
child->arrayIndex = i;
child->value = value.toString();
child->type = QLatin1String(value.typeName());
child->valueEditable = false;
child->wantsChildren = insertChildren(child, value);
parent->appendChild(child);
}
return true;
}
default:
return false;
}
}
void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyName,
const QVariant &value)
{
@@ -392,6 +437,8 @@ void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyNa
<< value.toString();
if (WatchItem *item = watchHandler->findItem(iname)) {
item->value = value.toString();
item->removeChildren();
item->wantsChildren = insertChildren(item, value);
item->update();
}
}
@@ -658,16 +705,11 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj,
propertyWatch->exp = propertyName;
propertyWatch->type = property.valueTypeName();
propertyWatch->value = property.value().toString();
propertyWatch->wantsChildren = false;
propertyWatch->wantsChildren = insertChildren(propertyWatch, property.value());
propertiesWatch->appendChild(propertyWatch);
}
if (boolSetting(SortStructMembers)) {
propertiesWatch->sortChildren([](const WatchItem *item1, const WatchItem *item2) {
return item1->name < item2->name;
});
}
sortChildrenIfNecessary(propertiesWatch);
m_qmlEngine->watchHandler()->insertItem(propertiesWatch);
}