/*! \brief Returns whether the root node of the model is one of the anchestors of this node. Will return true also for the root node itself. */ bool ModelNode::isInHierarchy() const { if (!isValid()) { Q_ASSERT_X(isValid(), Q_FUNC_INFO, "model node is invalid"); throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); } if (isRootNode()) return true; if (!hasParentProperty()) return false; return parentProperty().parentModelNode().isInHierarchy(); }
void ModelNode::setParentProperty(NodeAbstractProperty parent) { if (!isValid()) { Q_ASSERT_X(isValid(), Q_FUNC_INFO, "model node is invalid"); throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); } if (!parent.parentModelNode().isValid()) throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, "newParentNode"); if (*this == parent.parentModelNode()) { Q_ASSERT_X(*this != parent.parentModelNode(), Q_FUNC_INFO, "cannot set parent to itself"); throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); } if (parent == parentProperty()) return; parent.reparentHere(*this); }