From 61b3569bae69a619f9aa7975b774009c1c73ea48 Mon Sep 17 00:00:00 2001 From: Marco Bubke <marco.bubke@digia.com> Date: Wed, 30 Apr 2014 14:34:47 +0200 Subject: [PATCH] QmlDesigner: Add NavigatorTreeModel::hasNodeForIndex Change-Id: Iffa392bdf2348c22319168a49aee9cd5bd3f6b2a Reviewed-by: Marco Bubke <marco.bubke@digia.com> --- .../components/navigator/navigatortreemodel.cpp | 11 +++++++++++ .../components/navigator/navigatortreemodel.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp index ab1b8822879..c9af5408500 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp @@ -414,6 +414,17 @@ ModelNode NavigatorTreeModel::nodeForIndex(const QModelIndex &index) const return m_view->modelNodeForInternalId(internalId); } +bool NavigatorTreeModel::hasNodeForIndex(const QModelIndex &index) const +{ + QVariant internalIdVaraint = index.data(InternalIdRole); + if (internalIdVaraint.isValid()) { + qint32 internalId = internalIdVaraint.toInt(); + return m_view->hasModelNodeForInternalId(internalId); + } + + return false; +} + bool NavigatorTreeModel::isInTree(const ModelNode &node) const { return m_nodeItemHash.contains(node); diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.h b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.h index 7183beefd61..13159b7ea5e 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.h +++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.h @@ -102,6 +102,7 @@ public: QModelIndex indexForNode(const ModelNode &node) const; ModelNode nodeForIndex(const QModelIndex &index) const; + bool hasNodeForIndex(const QModelIndex &index) const; bool isInTree(const ModelNode &node) const; bool isNodeInvisible(const QModelIndex &index) const; -- GitLab