QmlDesigner: Check complete type hierarchy for hints

A type can have hints provided by the .metainfo files.
Without this patch hints from parent classes/components
are not inherited.
Therefore we have to walk the class hierarchy. Once we find hints
they have precedence over all hints from further parent classes.

Task-number: QDS-1056
Change-Id: I8dc8e7e92939e8e7eb834b94afbf5e396e8975de
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2019-09-13 14:54:34 +02:00
parent fe62dde830
commit e1f2fea488

View File

@@ -31,6 +31,7 @@
#include <rewriterview.h>
#include <propertyparser.h>
#include <nodeabstractproperty.h>
#include <nodemetainfo.h>
#include <QDebug>
@@ -89,13 +90,30 @@ static QVariant evaluateExpression(const QString &expression, const ModelNode &m
QmlDesigner::NodeHints::NodeHints(const ModelNode &node) : m_modelNode(node)
{
if (isValid()) {
const ItemLibraryInfo *libraryInfo = model()->metaInfo().itemLibraryInfo();
if (!isValid())
return;
const ItemLibraryInfo *libraryInfo = model()->metaInfo().itemLibraryInfo();
if (!m_modelNode.metaInfo().isValid()) {
QList <ItemLibraryEntry> itemLibraryEntryList = libraryInfo->entriesForType(
modelNode().type(), modelNode().majorVersion(), modelNode().minorVersion());
if (!itemLibraryEntryList.isEmpty())
m_hints = itemLibraryEntryList.constFirst().hints();
} else { /* If we have meta information we run the complete type hierarchy and check for hints */
const auto classHierarchy = m_modelNode.metaInfo().classHierarchy();
for (const NodeMetaInfo &metaInfo : classHierarchy) {
QList <ItemLibraryEntry> itemLibraryEntryList = libraryInfo->entriesForType(
metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
if (!itemLibraryEntryList.isEmpty() && !itemLibraryEntryList.constFirst().hints().isEmpty()) {
m_hints = itemLibraryEntryList.constFirst().hints();
return;
}
}
}
}