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 <designermcumanager.h>
|
||||
#include <nodehints.h>
|
||||
#include <nodemetainfo.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
RotationIndicator::RotationIndicator(LayerItem *layerItem)
|
||||
@@ -34,17 +38,58 @@ void RotationIndicator::clear()
|
||||
{
|
||||
m_itemControllerHash.clear();
|
||||
}
|
||||
namespace {
|
||||
|
||||
static bool itemIsRotatable(const QmlItemNode &qmlItemNode)
|
||||
bool itemIsResizable(const ModelNode &modelNode)
|
||||
{
|
||||
return qmlItemNode.isValid()
|
||||
&& qmlItemNode.instanceIsResizable()
|
||||
&& qmlItemNode.modelIsMovable()
|
||||
&& qmlItemNode.modelIsRotatable()
|
||||
&& !qmlItemNode.instanceIsInLayoutable()
|
||||
&& !qmlItemNode.isFlowItem();
|
||||
if (modelNode.metaInfo().isQtQuickControlsTab())
|
||||
return false;
|
||||
|
||||
return NodeHints::fromModelNode(modelNode).isResizable();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
clear();
|
||||
@@ -74,4 +119,4 @@ void RotationIndicator::updateItems(const QList<FormEditorItem*> &itemList)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -82,7 +82,6 @@ public:
|
||||
|
||||
bool modelIsMovable() const;
|
||||
bool modelIsResizable() const;
|
||||
bool modelIsRotatable() const;
|
||||
bool modelIsInLayout() const;
|
||||
bool hasFormEditorItem() const;
|
||||
|
||||
|
@@ -325,41 +325,6 @@ bool QmlItemNode::modelIsResizable() const
|
||||
&& !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
|
||||
{
|
||||
if (modelNode().hasParentProperty()) {
|
||||
|
Reference in New Issue
Block a user