Commit 99aae36e authored by Thomas Hartmann's avatar Thomas Hartmann

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: default avatarTim Jenssen <>
parent d31b3dce
......@@ -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);
......@@ -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);
......@@ -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)) {
if (node.isInHierarchy())
void NavigatorView::changeToComponent(const QModelIndex &index)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment