QmlDesigner: Block dragging anything under effect items

Effect items created by Effect maker are not valid parents for any
kind of node, so block dragging anything under them.

Fixes: QDS-11690
Change-Id: I9f6c8a6360d74d04ea871c57e7696466e4b7e41c
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2024-01-18 15:02:06 +02:00
parent e0bd133296
commit 2a746ff742

View File

@@ -147,9 +147,6 @@ static bool isInLayoutable(NodeAbstractProperty &parentProperty)
static void reparentModelNodeToNodeProperty(NodeAbstractProperty &parentProperty, const ModelNode &modelNode) static void reparentModelNodeToNodeProperty(NodeAbstractProperty &parentProperty, const ModelNode &modelNode)
{ {
try { try {
if (parentProperty.parentModelNode().type().startsWith("Effects."))
return;
if (!modelNode.hasParentProperty() || parentProperty != modelNode.parentProperty()) { if (!modelNode.hasParentProperty() || parentProperty != modelNode.parentProperty()) {
if (isInLayoutable(parentProperty)) { if (isInLayoutable(parentProperty)) {
removePosition(modelNode); removePosition(modelNode);
@@ -550,28 +547,29 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *mimeData,
if (widget) if (widget)
widget->setDragType(""); widget->setDragType("");
ModelNode targetNode = modelNodeForIndex(dropModelIndex);
if (!targetNode.isValid() || QmlItemNode(targetNode).isEffectItem())
return true;
if (dropModelIndex.model() == this) { if (dropModelIndex.model() == this) {
if (mimeData->hasFormat(Constants::MIME_TYPE_ITEM_LIBRARY_INFO)) { if (mimeData->hasFormat(Constants::MIME_TYPE_ITEM_LIBRARY_INFO)) {
handleItemLibraryItemDrop(mimeData, rowNumber, dropModelIndex); handleItemLibraryItemDrop(mimeData, rowNumber, dropModelIndex);
} else if (mimeData->hasFormat(Constants::MIME_TYPE_TEXTURE)) { } else if (mimeData->hasFormat(Constants::MIME_TYPE_TEXTURE)) {
const QModelIndex rowModelIndex = dropModelIndex.sibling(dropModelIndex.row(), 0); const QModelIndex rowModelIndex = dropModelIndex.sibling(dropModelIndex.row(), 0);
ModelNode targetNode = modelNodeForIndex(rowModelIndex); targetNode = modelNodeForIndex(rowModelIndex);
ModelNodeOperations::handleTextureDrop(mimeData, targetNode); ModelNodeOperations::handleTextureDrop(mimeData, targetNode);
} else if (mimeData->hasFormat(Constants::MIME_TYPE_MATERIAL)) { } else if (mimeData->hasFormat(Constants::MIME_TYPE_MATERIAL)) {
const QModelIndex rowModelIndex = dropModelIndex.sibling(dropModelIndex.row(), 0); const QModelIndex rowModelIndex = dropModelIndex.sibling(dropModelIndex.row(), 0);
ModelNode targetNode = modelNodeForIndex(rowModelIndex); targetNode = modelNodeForIndex(rowModelIndex);
ModelNodeOperations::handleMaterialDrop(mimeData, targetNode); ModelNodeOperations::handleMaterialDrop(mimeData, targetNode);
} else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_TEXTURE)) { } else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_TEXTURE)) {
QByteArray filePath = mimeData->data(Constants::MIME_TYPE_BUNDLE_TEXTURE); QByteArray filePath = mimeData->data(Constants::MIME_TYPE_BUNDLE_TEXTURE);
ModelNode targetNode(modelNodeForIndex(dropModelIndex));
if (targetNode.metaInfo().isQtQuick3DModel()) if (targetNode.metaInfo().isQtQuick3DModel())
m_view->emitCustomNotification("apply_asset_to_model3D", {targetNode}, {filePath}); // To MaterialBrowserView m_view->emitCustomNotification("apply_asset_to_model3D", {targetNode}, {filePath}); // To MaterialBrowserView
} else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_MATERIAL)) { } else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_MATERIAL)) {
ModelNode targetNode(modelNodeForIndex(dropModelIndex));
if (targetNode.isValid()) if (targetNode.isValid())
m_view->emitCustomNotification("drop_bundle_material", {targetNode}); // To ContentLibraryView m_view->emitCustomNotification("drop_bundle_material", {targetNode}); // To ContentLibraryView
} else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_EFFECT)) { } else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_EFFECT)) {
ModelNode targetNode(modelNodeForIndex(dropModelIndex));
if (targetNode.isValid()) if (targetNode.isValid())
m_view->emitCustomNotification("drop_bundle_effect", {targetNode}); // To ContentLibraryView m_view->emitCustomNotification("drop_bundle_effect", {targetNode}); // To ContentLibraryView
} else if (mimeData->hasFormat(Constants::MIME_TYPE_ASSETS)) { } else if (mimeData->hasFormat(Constants::MIME_TYPE_ASSETS)) {