Commit 40e36e0c authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlOutline: Treat grouped property items as properties

E.g. "anchors {}" is represented in the AST as a UiObjectDefinition.
Treat it nevertheless like a property in the outline, such that it
isn't shown in the outline if you deactivate showing bindings.
parent 39b1bb8b
......@@ -44,8 +44,7 @@ bool QmlJSOutlineFilterModel::filterAcceptsRow(int sourceRow,
if (m_filterBindings) {
QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent);
QVariant itemType = sourceIndex.data(QmlOutlineModel::ItemTypeRole);
Q_ASSERT(itemType.isValid());
if (itemType.isValid() && itemType == QmlOutlineModel::PropertyType) {
if (itemType == QmlOutlineModel::PropertyType) {
return false;
}
}
......
......@@ -347,20 +347,28 @@ QModelIndex QmlOutlineModel::enterObjectDefinition(AST::UiObjectDefinition *objD
QmlOutlineItem prototype(this);
const QString typeName = asString(objDef->qualifiedTypeNameId);
const QString id = getId(objDef);
if (!id.isEmpty()) {
prototype.setText(id);
if (typeName.at(0).isUpper()) {
const QString id = getId(objDef);
if (!id.isEmpty()) {
prototype.setText(id);
} else {
prototype.setText(typeName);
}
if (!m_typeToIcon.contains(typeName)) {
m_typeToIcon.insert(typeName, getIcon(objDef));
}
prototype.setIcon(m_typeToIcon.value(typeName));
prototype.setData(ElementType, ItemTypeRole);
prototype.setIdNode(objDef->qualifiedTypeNameId);
} else {
// it's a grouped propery like 'anchors'
prototype.setText(typeName);
prototype.setIcon(m_icons->scriptBindingIcon());
prototype.setData(PropertyType, ItemTypeRole);
}
if (!m_typeToIcon.contains(typeName)) {
m_typeToIcon.insert(typeName, getIcon(objDef));
}
prototype.setIcon(m_typeToIcon.value(typeName));
prototype.setData(ElementType, ItemTypeRole);
prototype.setSourceLocation(getLocation(objDef));
prototype.setNode(objDef);
prototype.setIdNode(objDef->qualifiedTypeNameId);
return enterNode(prototype);
}
......
Markdown is supported
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