def get_transformation_or_link_index(
    component_model: ComponentTreeModel,
    component_tree_view: QTreeView,
    transformation_list_index: QModelIndex,
) -> QModelIndex:
    """
    Retrieves the index of a component's first transformation or link.
    :param component_model: The component tree model.
    :param component_tree_view: The component tree view.
    :param transformation_list_index: The index of the component's transformation list.
    :return: The index of the component's first transformation/link.
    """
    component_tree_view.expand(transformation_list_index)
    return component_model.index(0, 0, transformation_list_index)
def get_transformation_list_index(
    component_model: ComponentTreeModel,
    component_tree_view: QTreeView,
    component_index: QModelIndex,
) -> QModelIndex:
    """
    Retrieves the index of a component's transformation list from the component tree view.
    :param component_model: The component model.
    :param component_tree_view: The component tree view.
    :param component_index: The index of the component.
    :return: The index of the component's transformation list.
    """
    component_tree_view.expand(component_index)
    return component_model.index(1, 0, component_index)
示例#3
0
def expand_transformation_list(
    node: QModelIndex,
    component_tree_view: QTreeView,
    component_model: NexusTreeModel,
):
    current_pointer = node.internalPointer()
    if isinstance(current_pointer, TransformationsList) or isinstance(
            current_pointer, Component):
        component_tree_view.expand(node)
        if isinstance(current_pointer, Component):
            trans_list_index = component_model.index(1, 0, node)
            component_tree_view.expand(trans_list_index)
        else:
            component_index = component_model.parent(node)
            component_tree_view.expand(component_index)
    elif isinstance(current_pointer, Transformation):
        trans_list_index = component_model.parent(node)
        component_tree_view.expand(trans_list_index)
        component_index = component_model.parent(trans_list_index)
        component_tree_view.expand(component_index)