| 900 | } |
| 901 | |
| 902 | QtNodes::Node* MainWindow::subTreeExpand(GraphicContainer &container, |
| 903 | QtNodes::Node &node, |
| 904 | MainWindow::SubtreeExpandOption option) |
| 905 | { |
| 906 | bool is_editor_mode = (_current_mode == GraphicMode::EDITOR); |
| 907 | const QSignalBlocker blocker( this ); |
| 908 | auto subtree_model = dynamic_cast<SubtreeNodeModel*>(node.nodeDataModel()); |
| 909 | const QString& subtree_name = subtree_model->registrationName(); |
| 910 | |
| 911 | if( option == SUBTREE_EXPAND && subtree_model->expanded() == false) |
| 912 | { |
| 913 | auto subtree_container = getTabByName(subtree_name); |
| 914 | auto abs_subtree = BuildTreeFromScene( subtree_container->scene() ); |
| 915 | |
| 916 | subtree_model->setExpanded(true); |
| 917 | node.nodeState().getEntries(PortType::Out).resize(1); |
| 918 | container.appendTreeToNode( node, abs_subtree ); |
| 919 | container.lockSubtreeEditing( node, true, is_editor_mode ); |
| 920 | |
| 921 | if( abs_subtree.nodes().size() > 1 ) |
| 922 | { |
| 923 | container.nodeReorder(); |
| 924 | } |
| 925 | |
| 926 | return &node; |
| 927 | } |
| 928 | |
| 929 | if( option == SUBTREE_COLLAPSE && subtree_model->expanded() == true) |
| 930 | { |
| 931 | bool need_reorder = true; |
| 932 | const auto& conn_out = node.nodeState().connections(PortType::Out, 0 ); |
| 933 | QtNodes::Node* child_node = nullptr; |
| 934 | if(conn_out.size() == 1) |
| 935 | { |
| 936 | child_node = conn_out.begin()->second->getNode( PortType::In ); |
| 937 | } |
| 938 | |
| 939 | const QSignalBlocker blocker( container ); |
| 940 | if( child_node) |
| 941 | { |
| 942 | container.deleteSubTreeRecursively( *child_node ); |
| 943 | } |
| 944 | else{ |
| 945 | need_reorder = false; |
| 946 | } |
| 947 | |
| 948 | subtree_model->setExpanded(false); |
| 949 | node.nodeState().getEntries(PortType::Out).resize(0); |
| 950 | container.lockSubtreeEditing( node, false, is_editor_mode ); |
| 951 | if( need_reorder ) |
| 952 | { |
| 953 | container.nodeReorder(); |
| 954 | } |
| 955 | |
| 956 | return &node; |
| 957 | } |
| 958 | |
| 959 | if( option == SUBTREE_REFRESH && subtree_model->expanded() == true ) |
nothing calls this directly
no test coverage detected