summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@digia.com>2014-09-08 10:37:22 +0200
committerThomas Hartmann <Thomas.Hartmann@digia.com>2014-09-08 15:51:11 +0200
commit99aae36e7a909f27f74f34ab4a208d61a529d4ce (patch)
tree1681b86ab4a133768c53421a1c8fb75592ca3010
parentd31b3dcef3b6e8f705636c2554f4eb54d081a0e9 (diff)
downloadqt-creator-99aae36e7a909f27f74f34ab4a208d61a529d4ce.tar.gz
QmlDesigner.Navigator: Fix reordering in case of invisble nodes
If the model contains nodes that are invisible in the navigator (e.g. QtObject) updateItemRowOrder() does not work correctly. To avoid complexity we update the subtree in this case. Change-Id: Ia40ce061e9188ef9ad6ca54ce3444432b878ddf6 Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
-rw-r--r--src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp27
-rw-r--r--src/plugins/qmldesigner/components/navigator/navigatortreemodel.h1
-rw-r--r--src/plugins/qmldesigner/components/navigator/navigatorview.cpp9
3 files changed, 7 insertions, 30 deletions
diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
index 059d4c173a..ae9019e2bf 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
@@ -360,33 +360,6 @@ static void findTargetItem(const NodeListProperty &listProperty,
}
}
-static void moveItemRow(QStandardItem *targetItem ,
- int currentRowNumber,
- int newRowNumber)
-{
- if (targetItem && currentRowNumber != newRowNumber) {//### Items without a parent should not exist
- QList<QStandardItem*> items = targetItem->takeRow(currentRowNumber);
- targetItem->insertRow(newRowNumber, items);
- }
-}
-
-/**
- Updates the sibling position of the item, depending on the position in the model.
- */
-void NavigatorTreeModel::updateItemRowOrder(const NodeListProperty &listProperty, const ModelNode &modelNode, int /*oldIndex*/)
-{
- if (isInTree(modelNode)) {
- ItemRow currentItemRow = itemRowForNode(modelNode);
- int currentRowNumber = currentItemRow.idItem->row();
- int newRowNumber = listProperty.indexOf(modelNode);
- QStandardItem *targetItem = 0;
-
- findTargetItem(listProperty, currentItemRow, this, &newRowNumber, &targetItem);
- moveItemRow(targetItem, currentRowNumber, newRowNumber);
-
- }
-}
-
static void handleWrongId(QStandardItem *item, const ModelNode &modelNode, const QString &errorTitle, const QString &errorMessage, NavigatorTreeModel *treeModel)
{
QMessageBox::warning(Core::ICore::dialogParent(), errorTitle, errorMessage);
diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.h b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.h
index 0c19a803e1..b324b86e43 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.h
+++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.h
@@ -113,7 +113,6 @@ public:
void addSubTree(const ModelNode &node);
void removeSubTree(const ModelNode &node);
void updateItemRow(const ModelNode &node);
- void updateItemRowOrder(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
void setId(const QModelIndex &index, const QString &id);
void setVisible(const QModelIndex &index, bool visible);
diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
index 24809188b5..eb126af2cc 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
@@ -296,8 +296,13 @@ void NavigatorView::instancesToken(const QString &/*tokenName*/, int /*tokenNumb
void NavigatorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &node, int oldIndex)
{
- if (m_treeModel->isInTree(node))
- m_treeModel->updateItemRowOrder(listProperty, node, oldIndex);
+ if (m_treeModel->isInTree(node)) {
+ m_treeModel->removeSubTree(listProperty.parentModelNode());
+
+ if (node.isInHierarchy())
+ m_treeModel->addSubTree(listProperty.parentModelNode());
+
+ }
}
void NavigatorView::changeToComponent(const QModelIndex &index)