forked from qt-creator/qt-creator
QmlDesigner: MCU Metadata improvements
- Introduced allowChildren switch Task: QDS-2794 Change-Id: Ie992fb173e8eacb27b10679d5ff28238277aa346 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -98,12 +98,14 @@ VersionData {
|
||||
}
|
||||
|
||||
QtQuick.Image {
|
||||
allowChildren: false
|
||||
allowedProperties: ["rotation", "scale", "transformOrigin"]
|
||||
bannedProperties: ["mirror", "mipmap", "cache", "autoTransform", "asynchronous",
|
||||
"sourceSize", "smooth"]
|
||||
}
|
||||
|
||||
QtQuick.Text {
|
||||
allowChildren: false
|
||||
allowedProperties: ["rotation", "scale", "transformOrigin"]
|
||||
bannedProperties: ["elide", "lineHeight", "lineHeightMode", "wrapMode", "style",
|
||||
"styleColor", "minimumPointSize", "minimumPixelSize", "styleColor",
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include <qmldesignerplugin.h>
|
||||
#include <qmlobjectnode.h>
|
||||
#include <designermcumanager.h>
|
||||
#include <qmlitemnode.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -292,9 +293,17 @@ bool PropertyEditorValue::isAvailable() const
|
||||
//allowed item properties:
|
||||
const auto itemTypes = mcuAllowedItemProperties.keys();
|
||||
for (const auto &itemType : itemTypes) {
|
||||
if (isAllowedSubclassType(itemType, m_modelNode.metaInfo())
|
||||
&& mcuAllowedItemProperties.value(itemType).contains(pureNameStr)) {
|
||||
return true;
|
||||
if (isAllowedSubclassType(itemType, m_modelNode.metaInfo())) {
|
||||
const QmlDesigner::DesignerMcuManager::ItemProperties allowedItemProps =
|
||||
mcuAllowedItemProperties.value(itemType);
|
||||
if (allowedItemProps.properties.contains(pureNameStr)) {
|
||||
if (QmlDesigner::QmlItemNode::isValidQmlItemNode(m_modelNode)) {
|
||||
const bool itemHasChildren = QmlDesigner::QmlItemNode(m_modelNode).hasChildren();
|
||||
|
||||
if (allowedItemProps.allowChildren == itemHasChildren)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -170,9 +170,16 @@ void DesignerMcuManager::readVersionData(const DesignerMcuManager::Version &vers
|
||||
|
||||
//handling allowed properties:
|
||||
if (child->propertyNames().contains("allowedProperties")) {
|
||||
const QStringList allowedProperties(readPropertyList("allowedProperties", child));
|
||||
ItemProperties allowedProperties;
|
||||
|
||||
if (!allowedProperties.isEmpty())
|
||||
const QVariant childrenPropertyVar = child->property("allowChildren");
|
||||
|
||||
if (!childrenPropertyVar.isNull() && childrenPropertyVar.isValid())
|
||||
allowedProperties.allowChildren = childrenPropertyVar.toBool();
|
||||
|
||||
allowedProperties.properties = readPropertyList("allowedProperties", child);
|
||||
|
||||
if (!allowedProperties.properties.isEmpty())
|
||||
m_allowedItemProperties.insert(child->name(), allowedProperties);
|
||||
}
|
||||
|
||||
@@ -235,7 +242,7 @@ QStringList DesignerMcuManager::bannedImports() const
|
||||
return m_bannedImports;
|
||||
}
|
||||
|
||||
QHash<QString, QStringList> DesignerMcuManager::allowedItemProperties() const
|
||||
QHash<QString, DesignerMcuManager::ItemProperties> DesignerMcuManager::allowedItemProperties() const
|
||||
{
|
||||
return m_allowedItemProperties;
|
||||
}
|
||||
|
@@ -43,6 +43,11 @@ public:
|
||||
};
|
||||
using VersionsList = QList<Version>;
|
||||
|
||||
struct ItemProperties {
|
||||
QStringList properties;
|
||||
bool allowChildren = true;
|
||||
};
|
||||
|
||||
static DesignerMcuManager& instance();
|
||||
|
||||
static QString mcuResourcesPath();
|
||||
@@ -62,7 +67,7 @@ public:
|
||||
QStringList allowedImports() const;
|
||||
QStringList bannedImports() const;
|
||||
|
||||
QHash<QString, QStringList> allowedItemProperties() const;
|
||||
QHash<QString, ItemProperties> allowedItemProperties() const;
|
||||
QHash<QString, QStringList> bannedComplexProperties() const;
|
||||
|
||||
DesignerMcuManager(DesignerMcuManager const&) = delete;
|
||||
@@ -80,7 +85,7 @@ private:
|
||||
QSet<QString> m_bannedProperties;
|
||||
QStringList m_allowedImports;
|
||||
QStringList m_bannedImports;
|
||||
QHash<QString, QStringList> m_allowedItemProperties;
|
||||
QHash<QString, ItemProperties> m_allowedItemProperties;
|
||||
QHash<QString, QStringList> m_bannedComplexProperties;
|
||||
|
||||
DesignerMcuManager::VersionsList m_versionsList;
|
||||
|
Reference in New Issue
Block a user