forked from qt-creator/qt-creator
QmlDesigner: Remove mcu dependency from model
The function is only called in the formeditor. So moving it to the formeditor removes the dependency to the mcu manager. Change-Id: I1a1d6f65b97340206ea0d485b24046c3661daf92 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Aleksei German <aleksei.german@qt.io>
This commit is contained in:
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
#include "formeditoritem.h"
|
#include "formeditoritem.h"
|
||||||
|
|
||||||
|
#include <designermcumanager.h>
|
||||||
|
#include <nodehints.h>
|
||||||
|
#include <nodemetainfo.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
RotationIndicator::RotationIndicator(LayerItem *layerItem)
|
RotationIndicator::RotationIndicator(LayerItem *layerItem)
|
||||||
@@ -34,17 +38,58 @@ void RotationIndicator::clear()
|
|||||||
{
|
{
|
||||||
m_itemControllerHash.clear();
|
m_itemControllerHash.clear();
|
||||||
}
|
}
|
||||||
|
namespace {
|
||||||
|
|
||||||
static bool itemIsRotatable(const QmlItemNode &qmlItemNode)
|
bool itemIsResizable(const ModelNode &modelNode)
|
||||||
{
|
{
|
||||||
return qmlItemNode.isValid()
|
if (modelNode.metaInfo().isQtQuickControlsTab())
|
||||||
&& qmlItemNode.instanceIsResizable()
|
return false;
|
||||||
&& qmlItemNode.modelIsMovable()
|
|
||||||
&& qmlItemNode.modelIsRotatable()
|
return NodeHints::fromModelNode(modelNode).isResizable();
|
||||||
&& !qmlItemNode.instanceIsInLayoutable()
|
|
||||||
&& !qmlItemNode.isFlowItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isMcuRotationAllowed([[maybe_unused]] QString itemName, [[maybe_unused]] bool hasChildren)
|
||||||
|
{
|
||||||
|
const QString propName = "rotation";
|
||||||
|
const DesignerMcuManager &manager = DesignerMcuManager::instance();
|
||||||
|
if (manager.isMCUProject()) {
|
||||||
|
if (manager.allowedItemProperties().contains(itemName)) {
|
||||||
|
const DesignerMcuManager::ItemProperties properties = manager.allowedItemProperties().value(
|
||||||
|
itemName);
|
||||||
|
if (properties.properties.contains(propName)) {
|
||||||
|
if (hasChildren)
|
||||||
|
return properties.allowChildren;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (manager.bannedItems().contains(itemName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (manager.bannedProperties().contains(propName))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool modelIsRotatable(const QmlItemNode &itemNode)
|
||||||
|
{
|
||||||
|
auto modelNode = itemNode.modelNode();
|
||||||
|
return !modelNode.hasBindingProperty("rotation") && itemIsResizable(modelNode)
|
||||||
|
&& !itemNode.modelIsInLayout()
|
||||||
|
&& isMcuRotationAllowed(QString::fromUtf8(modelNode.type()), itemNode.hasChildren());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool itemIsRotatable(const QmlItemNode &qmlItemNode)
|
||||||
|
{
|
||||||
|
return qmlItemNode.isValid() && qmlItemNode.instanceIsResizable()
|
||||||
|
&& qmlItemNode.modelIsMovable() && modelIsRotatable(qmlItemNode)
|
||||||
|
&& !qmlItemNode.instanceIsInLayoutable() && !qmlItemNode.isFlowItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void RotationIndicator::setItems(const QList<FormEditorItem*> &itemList)
|
void RotationIndicator::setItems(const QList<FormEditorItem*> &itemList)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
@@ -74,4 +119,4 @@ void RotationIndicator::updateItems(const QList<FormEditorItem*> &itemList)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace QmlDesigner
|
||||||
|
@@ -82,7 +82,6 @@ public:
|
|||||||
|
|
||||||
bool modelIsMovable() const;
|
bool modelIsMovable() const;
|
||||||
bool modelIsResizable() const;
|
bool modelIsResizable() const;
|
||||||
bool modelIsRotatable() const;
|
|
||||||
bool modelIsInLayout() const;
|
bool modelIsInLayout() const;
|
||||||
bool hasFormEditorItem() const;
|
bool hasFormEditorItem() const;
|
||||||
|
|
||||||
|
@@ -325,41 +325,6 @@ bool QmlItemNode::modelIsResizable() const
|
|||||||
&& !modelIsInLayout();
|
&& !modelIsInLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isMcuRotationAllowed([[maybe_unused]] QString itemName, [[maybe_unused]] bool hasChildren)
|
|
||||||
{
|
|
||||||
#ifndef QMLDESIGNER_TEST
|
|
||||||
const QString propName = "rotation";
|
|
||||||
const DesignerMcuManager &manager = DesignerMcuManager::instance();
|
|
||||||
if (manager.isMCUProject()) {
|
|
||||||
if (manager.allowedItemProperties().contains(itemName)) {
|
|
||||||
const DesignerMcuManager::ItemProperties properties =
|
|
||||||
manager.allowedItemProperties().value(itemName);
|
|
||||||
if (properties.properties.contains(propName)) {
|
|
||||||
if (hasChildren)
|
|
||||||
return properties.allowChildren;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manager.bannedItems().contains(itemName))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (manager.bannedProperties().contains(propName))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmlItemNode::modelIsRotatable() const
|
|
||||||
{
|
|
||||||
return !modelNode().hasBindingProperty("rotation")
|
|
||||||
&& itemIsResizable(modelNode())
|
|
||||||
&& !modelIsInLayout()
|
|
||||||
&& isMcuRotationAllowed(QString::fromUtf8(modelNode().type()), hasChildren());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmlItemNode::modelIsInLayout() const
|
bool QmlItemNode::modelIsInLayout() const
|
||||||
{
|
{
|
||||||
if (modelNode().hasParentProperty()) {
|
if (modelNode().hasParentProperty()) {
|
||||||
|
Reference in New Issue
Block a user