From 45f8895e932e8b07b5848cacca185daa1f76ed4f Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Tue, 12 Jan 2010 10:39:40 +0100
Subject: [PATCH] Change signature of AbstractView::nodeSlidedToIndex in
 QmlDesigner

The usage of 'int newIndex' was ambiguous in the case of
oldIndex < newIndex. Solved by directly passing the ModelNode that was
moved around.

'nodeSlidedToIndex' was also renamed to 'nodeOrderChanged', since
'Slided' is no proper English.
---
 .../components/integration/componentview.cpp  |  2 +-
 .../components/integration/componentview.h    |  2 +-
 .../designdocumentcontrollerview.cpp          |  2 +-
 .../designdocumentcontrollerview.h            |  2 +-
 .../navigator/navigatortreemodel.cpp          | 24 +++++++++++--------
 .../components/navigator/navigatorview.cpp    |  8 ++-----
 .../components/navigator/navigatorview.h      |  3 +--
 .../stateseditor/stateseditorview.cpp         | 13 +++++-----
 .../stateseditor/stateseditorview.h           |  2 +-
 .../qmldesigner/core/include/abstractview.h   |  2 +-
 .../qmldesigner/core/include/forwardview.h    |  7 +++---
 .../core/include/nodeinstanceview.h           |  2 +-
 .../qmldesigner/core/include/rewriterview.h   |  2 +-
 .../core/instances/nodeinstanceview.cpp       |  6 ++---
 src/plugins/qmldesigner/core/model/model.cpp  | 20 +++++++++-------
 src/plugins/qmldesigner/core/model/model_p.h  |  4 ++--
 .../core/model/nodelistproperty.cpp           |  4 ++--
 .../qmldesigner/core/model/rewriterview.cpp   |  9 +++----
 .../qmldesigner/core/model/viewlogger.cpp     |  4 ++--
 .../qmldesigner/core/model/viewlogger.h       |  2 +-
 .../qml/qmldesigner/coretests/testcore.cpp    |  4 +---
 tests/auto/qml/qmldesigner/testview.cpp       |  7 +++---
 tests/auto/qml/qmldesigner/testview.h         |  2 +-
 23 files changed, 69 insertions(+), 64 deletions(-)

diff --git a/src/plugins/qmldesigner/components/integration/componentview.cpp b/src/plugins/qmldesigner/components/integration/componentview.cpp
index ccd0a395188..87573b6cd34 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 b4ec1e83610..cc02b712433 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 187328bad8b..fa3e42a2f22 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 6b4c89ea627..6000dd093d6 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 e172f53cc04..87c18f4e035 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 9e9c4661b05..80a5fad9c90 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 c8545f802f0..d1f446cb1a4 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 38ac4b7db1b..d4dce66173e 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 284d939fb01..4f91cd0f7fd 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 9f585226574..3d24c6bff03 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 a69dd6ea8c7..f7c74ce3faf 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 17cec2c1be3..d1f60fc9a80 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 e360736c8ba..6c956c92033 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 a9102ca10ee..67c2a3a62d4 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 a837a811e4e..946289eea48 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 184d10ca3ee..558628b643f 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 70e3826968b..53bc1dc2f3d 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 4308c951724..95d753dac45 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 2b1c5556648..64c4eef185e 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 388c3ab8cc7..37c6e2aef90 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 c848373b14d..d29f6bc7d2b 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 b1e424d9db0..4f990fc569e 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 c667f8b0415..729d2dc9907 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);
 
-- 
GitLab