diff --git a/src/plugins/qmldesigner/components/integration/componentview.cpp b/src/plugins/qmldesigner/components/integration/componentview.cpp index ccd0a395188aea2d865ed51a42b666715c4570b7..87573b6cd34b93d61060137622557648ead09ae7 100644 --- a/src/plugins/qmldesigner/components/integration/componentview.cpp +++ b/src/plugins/qmldesigner/components/integration/componentview.cpp @@ -167,7 +167,7 @@ void ComponentView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeL void ComponentView::fileUrlChanged(const QUrl &/*oldUrl*/, const QUrl &/*newUrl*/) {} -void ComponentView::nodeSlidedToIndex(const NodeListProperty &/*listProperty*/, int /*newIndex*/, int /*oldIndex*/) {} +void ComponentView::nodeOrderChanged(const NodeListProperty &/*listProperty*/, const ModelNode & /*movedNode*/, int /*oldIndex*/) {} void ComponentView::importsChanged() {} diff --git a/src/plugins/qmldesigner/components/integration/componentview.h b/src/plugins/qmldesigner/components/integration/componentview.h index b4ec1e83610afc7fee297d7b62d3628ca9639f58..cc02b7124333e62e0a97192c6a0a80c22ec932f6 100644 --- a/src/plugins/qmldesigner/components/integration/componentview.h +++ b/src/plugins/qmldesigner/components/integration/componentview.h @@ -72,7 +72,7 @@ public: void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl); - void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); + void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); void importsChanged(); diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp index 187328bad8bd6dc263cc5f64618640504d3860eb..fa3e42a2f2275a75bb7f7b8c3fe151fd3975388e 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp @@ -52,7 +52,7 @@ void DesignDocumentControllerView::nodeTypeChanged(const ModelNode & /*node*/,co void DesignDocumentControllerView::selectedNodesChanged(const QList<ModelNode> & /*selectedNodeList*/, const QList<ModelNode> & /*lastSelectedNodeList*/) {}; -void DesignDocumentControllerView::nodeSlidedToIndex(const NodeListProperty & /*listProperty*/, int /*newIndex*/, int /*oldIndex*/) {}; +void DesignDocumentControllerView::nodeOrderChanged(const NodeListProperty & /*listProperty*/, const ModelNode & /*movedNode*/, int /*oldIndex*/) {}; static QStringList arrayToStringList(const QByteArray &byteArray) { diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h index 6b4c89ea627abcfc3e0b4a7c789789c7add0de16..6000dd093d60439b6e25c34aef3225b3bd5e5ee6 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h @@ -56,7 +56,7 @@ public: virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList); - virtual void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); + virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); ModelNode insertModel(const ModelNode &modelNode) { return m_modelMerger.insertModel(modelNode); } diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp index e172f53cc0481b3bca04d9bf33a482cd0df68427..87c18f4e035ece817a063681544f96e6ccdf4342 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp @@ -122,20 +122,18 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *data, if (parentIndex.model() != this) return false; - int beginRow = 0; QModelIndex parentIdIndex = parentIndex; parentIdIndex = parentIdIndex.sibling(parentIdIndex.row(), 0); Q_ASSERT(parentIdIndex.isValid()); - if (row > -1) - beginRow = row; - else if (parentIdIndex.isValid()) - beginRow = rowCount(parentIdIndex); - else - beginRow = rowCount(QModelIndex()); - + int targetIndex = 0; + if (row > -1) { + targetIndex = row; + } else { + targetIndex = rowCount(parentIdIndex); + } QByteArray encodedData = data->data("application/vnd.modelnode.list"); QDataStream stream(&encodedData, QIODevice::ReadOnly); @@ -159,13 +157,19 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *data, if (!isAnchestorInList(node, nodeList)) { if (node.parentProperty().parentModelNode() != parentItemNode) { QmlItemNode itemNode(node); - if (node != parentItemNode) + if (node != parentItemNode) { itemNode.setParent(parentItemNode); + } } if (node.parentProperty().isNodeListProperty()) { int index = node.parentProperty().toNodeListProperty().toModelNodeList().indexOf(node); - node.parentProperty().toNodeListProperty().slide(index, beginRow); + if (index < targetIndex) { // item is first removed from oldIndex, then inserted at new index + --targetIndex; + } + if (index != targetIndex) { + node.parentProperty().toNodeListProperty().slide(index, targetIndex); + } } } } diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp index 9e9c4661b05331929667a2ebed7592c368aed436..80a5fad9c902ee3c20905631ae99c2c04593ddb8 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp @@ -133,14 +133,10 @@ void NavigatorView::auxiliaryDataChanged(const ModelNode &node, const QString &n m_treeModel->updateItemRow(node); } -void NavigatorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex) +void NavigatorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &node, int oldIndex) { - QmlModelView::nodeSlidedToIndex(listProperty, newIndex, oldIndex); + QmlModelView::nodeOrderChanged(listProperty, node, oldIndex); - int nodeIndex = newIndex; - if (oldIndex < newIndex) - --nodeIndex; - ModelNode node = listProperty.toModelNodeList().at(nodeIndex); if (m_treeModel->isInTree(node)) m_treeModel->updateItemRowOrder(node); } diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.h b/src/plugins/qmldesigner/components/navigator/navigatorview.h index c8545f802f0ec6b0b859d858941598428e123a95..d1f446cb1a405336abebcfebc8a52e402f5a9229 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.h +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.h @@ -60,8 +60,8 @@ public: void nodeAboutToBeRemoved(const ModelNode &removedNode); void nodeReparented(const ModelNode &node, const ModelNode &oldParent, const ModelNode &newParent); + void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); - void nodeSlidedToIndex(const ModelNode &node, int newIndex, int oldIndex); void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange); void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId); @@ -70,7 +70,6 @@ public: void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList); void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data); - void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index 38ac4b7db1b7f75e706899b143a5d28ca2faff6b..d4dce66173ec257722b4be35fcc6e7501b821e43 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -274,15 +274,16 @@ void StatesEditorView::nodeReparented(const ModelNode &node, const NodeAbstractP } } -void StatesEditorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex) +void StatesEditorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) { - QmlModelView::nodeSlidedToIndex(listProperty, newIndex, oldIndex); + QmlModelView::nodeOrderChanged(listProperty, movedNode, oldIndex); if (listProperty.parentModelNode() == m_stateRootNode && listProperty.name() == "states") { - int index = newIndex; - if (oldIndex < newIndex) - --index; - QmlModelState state = listProperty.toModelNodeList().at(index); + + int newIndex = listProperty.toModelNodeList().indexOf(movedNode); + Q_ASSERT(newIndex >= 0); + + QmlModelState state = QmlModelState(movedNode); if (state.isValid()) { Q_ASSERT(oldIndex == modelStateIndex(state)); removeModelState(state); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 284d939fb01280545e54b8c1defdc2207debaa20..4f91cd0f7fdde7d4ed60edae8374c4eff0e2b78b 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -64,7 +64,7 @@ public: void nodeAboutToBeRemoved(const ModelNode &removedNode); void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange); - void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); + void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); // QmlModelView void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); diff --git a/src/plugins/qmldesigner/core/include/abstractview.h b/src/plugins/qmldesigner/core/include/abstractview.h index 9f5852265741100fac06d4b714d48a96dcd30606..3d24c6bff033345100ab634024897300528a4a1e 100644 --- a/src/plugins/qmldesigner/core/include/abstractview.h +++ b/src/plugins/qmldesigner/core/include/abstractview.h @@ -118,7 +118,7 @@ public: virtual void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl); - virtual void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex) = 0; + virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) = 0; virtual void importsChanged(); diff --git a/src/plugins/qmldesigner/core/include/forwardview.h b/src/plugins/qmldesigner/core/include/forwardview.h index a69dd6ea8c7148386e00faac03919fda51983c1e..f7c74ce3fafbef614b372b7d01b95749df130040 100644 --- a/src/plugins/qmldesigner/core/include/forwardview.h +++ b/src/plugins/qmldesigner/core/include/forwardview.h @@ -69,7 +69,7 @@ public: void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl); - void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); + void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); void importsChanged(); @@ -210,10 +210,11 @@ void ForwardView<ViewType>::fileUrlChanged(const QUrl &oldUrl, const QUrl &newUr } template <class ViewType> -void ForwardView<ViewType>::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex) +void ForwardView<ViewType>::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) { foreach (const ViewTypePointer &view, m_targetViewList) - view->nodeSlidedToIndex(NodeListProperty(listProperty, view.data()), newIndex, oldIndex); + view->nodeOrderChanged(NodeListProperty(listProperty, view.data()), + ModelNode(movedNode, view.data()), oldIndex); } template <class ViewType> diff --git a/src/plugins/qmldesigner/core/include/nodeinstanceview.h b/src/plugins/qmldesigner/core/include/nodeinstanceview.h index 17cec2c1be330c63623cb02215af567342d45956..d1f60fc9a80d791244fbbd25dea6d4f6726642cc 100644 --- a/src/plugins/qmldesigner/core/include/nodeinstanceview.h +++ b/src/plugins/qmldesigner/core/include/nodeinstanceview.h @@ -85,7 +85,7 @@ public: void nodeStatesAboutToBeRemoved(const QList<ModelNode> &nodeStateList); void nodeStatesAdded(const QList<ModelNode> &nodeStateList); - void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); + void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); NodeInstance rootNodeInstance() const; NodeInstance viewNodeInstance() const; diff --git a/src/plugins/qmldesigner/core/include/rewriterview.h b/src/plugins/qmldesigner/core/include/rewriterview.h index e360736c8baf2ca3b5651a2461ffa140acb2f72d..6c956c920339bcfc834edadaf081a208a7db382f 100644 --- a/src/plugins/qmldesigner/core/include/rewriterview.h +++ b/src/plugins/qmldesigner/core/include/rewriterview.h @@ -121,7 +121,7 @@ public: void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange); void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId); - void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int /*oldIndex*/); + void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); diff --git a/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp index a9102ca10ee733d9019ddbeb780826a2d5c98bcb..67c2a3a62d4c10eb9e94600bb395578853b2d4cf 100644 --- a/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp @@ -293,10 +293,10 @@ void NodeInstanceView::nodeIdChanged(const ModelNode& node, const QString& newId } } -void NodeInstanceView::nodeSlidedToIndex(const NodeListProperty &listProperty, int /*newIndex*/, int /*oldIndex*/) +void NodeInstanceView::nodeOrderChanged(const NodeListProperty & listProperty, + const ModelNode & /*movedNode*/, int /*oldIndex*/) { - QList<ModelNode> newOrderModelNodeList = listProperty.toModelNodeList(); - foreach(const ModelNode &node, newOrderModelNodeList) { + foreach(const ModelNode &node, listProperty.toModelNodeList()) { NodeInstance instance = instanceForNode(node); instance.reparent(instance.parent(), listProperty.name(), instance.parent(), listProperty.name()); } diff --git a/src/plugins/qmldesigner/core/model/model.cpp b/src/plugins/qmldesigner/core/model/model.cpp index a837a811e4e2971704306bc8b04fbbcf31727e65..946289eea4822db26b9aaa75e80e1055569af236 100644 --- a/src/plugins/qmldesigner/core/model/model.cpp +++ b/src/plugins/qmldesigner/core/model/model.cpp @@ -438,12 +438,15 @@ void ModelPrivate::notifyNodeReparent(const InternalNode::Pointer &internalNodeP } } -void ModelPrivate::notifyNodeSlidedToIndex(const InternalNodeListProperty::Pointer &internalNodeListproperty, int newIndex, int oldIndex) +void ModelPrivate::notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer, + const InternalNode::Pointer &internalNodePointer, + int oldIndex) { foreach (const QWeakPointer<AbstractView> &view, m_viewList) { - Q_ASSERT(view != 0); - NodeListProperty nodeListproperty(internalNodeListproperty, model(), view.data()); - view->nodeSlidedToIndex(nodeListproperty, newIndex, oldIndex); + Q_ASSERT(!view.isNull()); + view->nodeOrderChanged(NodeListProperty(internalListPropertyPointer, model(), view.data()), + ModelNode(internalNodePointer, model(), view.data()), + oldIndex); } } @@ -678,14 +681,15 @@ void ModelPrivate::changeType(const InternalNodePointer &internalNode, const QSt notifyNodeTypeChanged(internalNode, type, majorVersion, minorVersion); } -void ModelPrivate::slideNodeList(const InternalNode::Pointer &internalNode, const QString &name, int from, int to) +void ModelPrivate::changeNodeOrder(const InternalNode::Pointer &internalParentNode, const QString &listPropertyName, int from, int to) { - InternalNodeListProperty::Pointer nodeList(internalNode->nodeListProperty(name)); + InternalNodeListProperty::Pointer nodeList(internalParentNode->nodeListProperty(listPropertyName)); Q_ASSERT(!nodeList.isNull()); nodeList->slide(from, to); - notifyNodeSlidedToIndex(nodeList, to, from); -} + const InternalNodePointer internalNode = nodeList->nodeList().at(to); + notifyNodeOrderChanged(nodeList, internalNode, from); +} void ModelPrivate::setRootNode(const InternalNode::Pointer& newRootNode) { diff --git a/src/plugins/qmldesigner/core/model/model_p.h b/src/plugins/qmldesigner/core/model/model_p.h index 184d10ca3ee9a664b2c126f7a93b6abccbc075e7..558628b643fc0714698954995554361519831c84 100644 --- a/src/plugins/qmldesigner/core/model/model_p.h +++ b/src/plugins/qmldesigner/core/model/model_p.h @@ -118,7 +118,7 @@ public: void notifyBindingPropertiesChanged(const QList<InternalBindingPropertyPointer> &propertyList, AbstractView::PropertyChangeFlags propertyChange); void notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const QStringList& propertyNameList, AbstractView::PropertyChangeFlags propertyChange); - void notifyNodeSlidedToIndex(const InternalNodeListPropertyPointer &internalNode, int newIndex, int oldIndex); + void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer, const InternalNodePointer &internalNodePointer, int oldIndex); void notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode, const QString &name, const QVariant &data); void notifyNodeTypeChanged(const InternalNodePointer &internalNode, const QString &type, int majorVersion, int minorVersion); @@ -156,7 +156,7 @@ public: void setDynamicVariantProperty(const InternalNodePointer &internalNode, const QString &name, const QString &propertyType, const QVariant &value); void setDynamicBindingProperty(const InternalNodePointer &internalNode, const QString &name, const QString &dynamicPropertyType, const QString &expression); void reparentNode(const InternalNodePointer &internalNode, const QString &name, const InternalNodePointer &internalNodeToBeAppended, bool list = true); - void slideNodeList(const InternalNodePointer &internalNode, const QString &name, int from, int to); + void changeNodeOrder(const InternalNodePointer &internalParentNode, const QString &listPropertyName, int from, int to); void checkPropertyName(const QString &propertyName); void clearParent(const InternalNodePointer &internalNode); void changeType(const InternalNodePointer & internalNode, const QString &type, int majorVersion, int minorVersion); diff --git a/src/plugins/qmldesigner/core/model/nodelistproperty.cpp b/src/plugins/qmldesigner/core/model/nodelistproperty.cpp index 70e3826968b471f1158cedd0323defc4f16639af..53bc1dc2f3d3fc684248dbb492aa44fc21df21a1 100644 --- a/src/plugins/qmldesigner/core/model/nodelistproperty.cpp +++ b/src/plugins/qmldesigner/core/model/nodelistproperty.cpp @@ -103,10 +103,10 @@ void NodeListProperty::slide(int from, int to) const { if (!isValid()) throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, "<invalid node list property>"); - if (to > toModelNodeList().count()) + if (to > toModelNodeList().count() - 1) throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, "<invalid node list sliding>"); - model()->m_d->slideNodeList(internalNode(), name(), from, to); + model()->m_d->changeNodeOrder(internalNode(), name(), from, to); } void NodeListProperty::reparentHere(const ModelNode &modelNode) diff --git a/src/plugins/qmldesigner/core/model/rewriterview.cpp b/src/plugins/qmldesigner/core/model/rewriterview.cpp index 4308c95172446304aa0fcd910da009b5ac22cd39..95d753dac4593423dfd643b0e424950df7a31d57 100644 --- a/src/plugins/qmldesigner/core/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/core/model/rewriterview.cpp @@ -258,18 +258,19 @@ void RewriterView::nodeIdChanged(const ModelNode& node, const QString& newId, co modelToTextMerger()->applyChanges(); } -void RewriterView::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int /*oldIndex*/) -{ // FIXME: "slided" ain't no English, probably "slid" or "sliding" is meant... +void RewriterView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int /*oldIndex*/) +{ Q_ASSERT(textModifier()); if (textToModelMerger()->isActive()) return; const QList<ModelNode> nodes = listProperty.toModelNodeList(); - const ModelNode movingNode = nodes.at(newIndex); + ModelNode trailingNode; + int newIndex = nodes.indexOf(movedNode); if (newIndex + 1 < nodes.size()) trailingNode = nodes.at(newIndex + 1); - modelToTextMerger()->nodeSlidAround(movingNode, trailingNode); + modelToTextMerger()->nodeSlidAround(movedNode, trailingNode); if (!isModificationGroupActive()) modelToTextMerger()->applyChanges(); diff --git a/src/plugins/qmldesigner/core/model/viewlogger.cpp b/src/plugins/qmldesigner/core/model/viewlogger.cpp index 2b1c5556648ea9632e032e09ea8d7a28bc2e2eff..64c4eef185e149833254fc2819d01b2bc0b019f6 100644 --- a/src/plugins/qmldesigner/core/model/viewlogger.cpp +++ b/src/plugins/qmldesigner/core/model/viewlogger.cpp @@ -171,9 +171,9 @@ void ViewLogger::fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl) m_output << time() << indent("fileUrlChanged:") << oldUrl.toString() << "\t" << newUrl.toString() << endl; } -void ViewLogger::nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex) +void ViewLogger::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) { - m_output << time() << indent("nodeSlidedToIndex:") << listProperty << newIndex << oldIndex << endl; + m_output << time() << indent("nodeOrderChanged:") << listProperty << movedNode << oldIndex << endl; } void ViewLogger::importsChanged() diff --git a/src/plugins/qmldesigner/core/model/viewlogger.h b/src/plugins/qmldesigner/core/model/viewlogger.h index 388c3ab8cc7668a5cb66b7bf88642ee28c4023da..37c6e2aef90a4313d031672e816718139da1a7c4 100644 --- a/src/plugins/qmldesigner/core/model/viewlogger.h +++ b/src/plugins/qmldesigner/core/model/viewlogger.h @@ -63,7 +63,7 @@ public: void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl); - void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); + void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); void importsChanged(); diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.cpp b/tests/auto/qml/qmldesigner/coretests/testcore.cpp index c848373b14d1ff211e42b6cc3c851cfd4faf9896..d29f6bc7d2b377a0eb94959f801db633a12dc303 100644 --- a/tests/auto/qml/qmldesigner/coretests/testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/testcore.cpp @@ -1381,14 +1381,12 @@ void TestCore::testModelReorderSiblings() NodeListProperty listProperty(rootModelNode.nodeListProperty("data")); - listProperty.slide(listProperty.toModelNodeList().indexOf(a), 3); //a.slideToIndex(3); - + listProperty.slide(listProperty.toModelNodeList().indexOf(a), 2); //a.slideToIndex(2); QVERIFY(a.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(a), 2); QVERIFY(b.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(b), 0); QVERIFY(c.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(c), 1); - listProperty.slide(listProperty.toModelNodeList().indexOf(c), 0); //c.slideToIndex(0); QVERIFY(a.isValid()); QCOMPARE(listProperty.toModelNodeList().indexOf(a), 2); diff --git a/tests/auto/qml/qmldesigner/testview.cpp b/tests/auto/qml/qmldesigner/testview.cpp index b1e424d9db00fccd6139cd68066560e8f36c4b8a..4f990fc569e5aaeab5661f4a19d7dde839997439 100644 --- a/tests/auto/qml/qmldesigner/testview.cpp +++ b/tests/auto/qml/qmldesigner/testview.cpp @@ -140,10 +140,11 @@ void TestView::selectedNodesChanged(const QList<QmlDesigner::ModelNode> &selecte m_methodCalls += MethodCall("selectedNodesChanged", QStringList() << selectedNodes.join(", ") << lastSelectedNodes.join(", ")); } -void TestView::nodeSlidedToIndex(const QmlDesigner::NodeListProperty &listProperty, int newIndex, int oldIndex) + +void TestView::nodeOrderChanged(const QmlDesigner::NodeListProperty &listProperty, const QmlDesigner::ModelNode &movedNode, int oldIndex) { - QmlDesigner::QmlModelView::nodeSlidedToIndex(listProperty, newIndex, oldIndex); - m_methodCalls += MethodCall("nodeSlidedToIndex", QStringList() << listProperty.name() << QString::number(newIndex) << QString::number(oldIndex)); + QmlDesigner::QmlModelView::nodeOrderChanged(listProperty, movedNode, oldIndex); + m_methodCalls += MethodCall("nodeOrderChanged", QStringList() << listProperty.name() << movedNode.id() << QString::number(oldIndex)); } void TestView::stateChanged(const QmlDesigner::QmlModelState &newQmlModelState, const QmlDesigner::QmlModelState &oldQmlModelState) diff --git a/tests/auto/qml/qmldesigner/testview.h b/tests/auto/qml/qmldesigner/testview.h index c667f8b04154e1595b7eb95aba383d9942585314..729d2dc99072cda222fff4b878e69567f41db1fb 100644 --- a/tests/auto/qml/qmldesigner/testview.h +++ b/tests/auto/qml/qmldesigner/testview.h @@ -70,7 +70,7 @@ public: void selectedNodesChanged(const QList<QmlDesigner::ModelNode> &selectedNodeList, const QList<QmlDesigner::ModelNode> &lastSelectedNodeList); - void nodeSlidedToIndex(const QmlDesigner::NodeListProperty &listProperty, int newIndex, int oldIndex); + void nodeOrderChanged(const QmlDesigner::NodeListProperty &listProperty, const QmlDesigner::ModelNode &movedNode, int oldIndex); void stateChanged(const QmlDesigner::QmlModelState &newQmlModelState, const QmlDesigner::QmlModelState &oldQmlModelState);