diff options
Diffstat (limited to 'src/plugins/qmldesigner/components/navigator/navigatorview.cpp')
-rw-r--r-- | src/plugins/qmldesigner/components/navigator/navigatorview.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp index ea64f0715a..cd6857d789 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp @@ -147,6 +147,17 @@ void NavigatorView::bindingPropertiesChanged(const QList<BindingProperty> & prop } } +void NavigatorView::customNotification(const AbstractView *view, const QString &identifier, + const QList<ModelNode> &nodeList, const QList<QVariant> &data) +{ + Q_UNUSED(view) + Q_UNUSED(nodeList) + Q_UNUSED(data) + + if (identifier == "asset_import_update") + m_currentModelInterface->notifyIconsChanged(); +} + void NavigatorView::handleChangedExport(const ModelNode &modelNode, bool exported) { const ModelNode rootNode = rootModelNode(); @@ -416,12 +427,24 @@ void NavigatorView::updateItemSelection() QItemSelection itemSelection; foreach (const ModelNode &node, selectedModelNodes()) { const QModelIndex index = indexForModelNode(node); + if (index.isValid()) { const QModelIndex beginIndex(currentModel()->index(index.row(), 0, index.parent())); const QModelIndex endIndex(currentModel()->index(index.row(), currentModel()->columnCount(index.parent()) - 1, index.parent())); if (beginIndex.isValid() && endIndex.isValid()) itemSelection.select(beginIndex, endIndex); - } + } else { + // if the node index is invalid expand ancestors manually if they are valid. + ModelNode parentNode = node; + while (parentNode.hasParentProperty()) { + parentNode = parentNode.parentProperty().parentQmlObjectNode(); + QModelIndex parentIndex = indexForModelNode(parentNode); + if (parentIndex.isValid()) + treeWidget()->expand(parentIndex); + else + break; + } + } } bool blocked = blockSelectionChangedSignal(true); @@ -431,10 +454,10 @@ void NavigatorView::updateItemSelection() if (!selectedModelNodes().isEmpty()) treeWidget()->scrollTo(indexForModelNode(selectedModelNodes().constFirst())); - // make sure selected nodes a visible + // make sure selected nodes are visible foreach (const QModelIndex &selectedIndex, itemSelection.indexes()) { if (selectedIndex.column() == 0) - expandRecursively(selectedIndex); + expandAncestors(selectedIndex); } } @@ -458,9 +481,9 @@ bool NavigatorView::blockSelectionChangedSignal(bool block) return oldValue; } -void NavigatorView::expandRecursively(const QModelIndex &index) +void NavigatorView::expandAncestors(const QModelIndex &index) { - QModelIndex currentIndex = index; + QModelIndex currentIndex = index.parent(); while (currentIndex.isValid()) { if (!treeWidget()->isExpanded(currentIndex)) treeWidget()->expand(currentIndex); |