6#include "QskTreeNode.h"
8static const auto extraFlag =
9 static_cast< QSGNode::Flag
>( QSGNode::IsVisitableNode << 1 );
11static inline QSGNode* qskCheckedNode(
const QSGNode* node, QSGNode::NodeType type )
13 return node && ( node->type() == type ) && ( node->flags() & extraFlag )
14 ?
const_cast< QSGNode*
>( node ) : nullptr;
17QskTreeNode::QskTreeNode()
19 setFlag( extraFlag,
true );
22QskTreeNode::QskTreeNode( QSGNodePrivate& d )
23 : QSGNode( d, QSGNode::BasicNodeType )
25 setFlag( extraFlag,
true );
28QskTreeNode::~QskTreeNode()
32void QskTreeNode::setSubtreeBlocked(
bool on,
bool notify )
34 if ( on == m_isBlocked )
40 markDirty( DirtySubtreeBlocked );
43bool QskTreeNode::isSubtreeBlocked()
const
51 qskCheckedNode( node, QSGNode::BasicNodeType ) );
54const QskTreeNode* qskTreeNodeCast(
const QSGNode* node )
57 qskCheckedNode( node, QSGNode::BasicNodeType ) );
63QskItemNode::QskItemNode()
65 setFlag( extraFlag,
true );
68QskItemNode::~QskItemNode()
72void QskItemNode::setSubtreeBlocked(
bool on,
bool notify )
74 if ( on == m_isBlocked )
80 markDirty( DirtySubtreeBlocked );
83bool QskItemNode::isSubtreeBlocked()
const
91 qskCheckedNode( node, QSGNode::TransformNodeType ) );
94const QskItemNode* qskItemNodeCast(
const QSGNode* node )
97 qskCheckedNode( node, QSGNode::TransformNodeType ) );
100bool qskIsBlockableNode(
const QSGNode* node )
102 switch( node->type() )
104 case QSGNode::BasicNodeType:
105 case QSGNode::TransformNodeType:
106 return node->flags() & extraFlag;
113bool qskTryBlockNode( QSGNode* node,
bool on,
bool notify )
115 if ( node && ( node->flags() & extraFlag ) )
117 if ( node->type() == QSGNode::BasicNodeType )
119 static_cast< QskTreeNode*
>( node )->setSubtreeBlocked( on, notify );
123 if ( node->type() == QSGNode::TransformNodeType )
125 static_cast< QskItemNode*
>( node )->setSubtreeBlocked( on, notify );
133void qskTryBlockTree( QSGNode* node,
bool on,
bool notify )
135 if ( qskTryBlockNode( node, on, notify ) )
138 for (
auto child = node->firstChild();
139 child !=
nullptr; child = child->nextSibling() )
141 qskTryBlockTree( child, on, notify );
145void qskTryBlockTrailingNodes(
146 QSGNode* node,
const QSGNode* ancestorNode,
bool on,
bool notify )
148 qskTryBlockTree( node, on, notify );
150 for (
auto sibling = node->nextSibling();
151 sibling !=
nullptr; sibling = sibling->nextSibling() )
153 qskTryBlockTree( sibling, on, notify );
156 if ( node != ancestorNode )
158 if (
auto upperNode = node->parent() )
160 upperNode = upperNode->nextSibling();
162 qskTryBlockTrailingNodes( upperNode, ancestorNode, on, notify );