| 1029 | } |
| 1030 | |
| 1031 | void MainWindow::onTreeNodeEdited(QString prev_ID, QString new_ID) |
| 1032 | { |
| 1033 | for (auto& it: _tab_info) |
| 1034 | { |
| 1035 | auto container = it.second; |
| 1036 | std::vector<QtNodes::Node*> nodes_to_rename; |
| 1037 | |
| 1038 | for(const auto& node_it: container->scene()->nodes() ) |
| 1039 | { |
| 1040 | QtNodes::Node* graphic_node = node_it.second.get(); |
| 1041 | if( !graphic_node ) { |
| 1042 | continue; |
| 1043 | } |
| 1044 | auto bt_node = dynamic_cast<BehaviorTreeDataModel*>( graphic_node->nodeDataModel() ); |
| 1045 | if( !bt_node ) { |
| 1046 | continue; |
| 1047 | } |
| 1048 | |
| 1049 | if( bt_node->model().registration_ID == prev_ID ) |
| 1050 | { |
| 1051 | nodes_to_rename.push_back( graphic_node ); |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | for(auto& graphic_node: nodes_to_rename ) |
| 1056 | { |
| 1057 | auto bt_node = dynamic_cast<BehaviorTreeDataModel*>( graphic_node->nodeDataModel() ); |
| 1058 | bool is_expanded_subtree = false; |
| 1059 | |
| 1060 | if( bt_node->model().type == NodeType::SUBTREE) |
| 1061 | { |
| 1062 | auto subtree_model = dynamic_cast<SubtreeNodeModel*>( bt_node ); |
| 1063 | if(subtree_model && subtree_model->expanded()) |
| 1064 | { |
| 1065 | is_expanded_subtree = true; |
| 1066 | subTreeExpand( *container, *graphic_node, SUBTREE_COLLAPSE); |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | auto new_node = container->substituteNode( graphic_node, new_ID); |
| 1071 | |
| 1072 | if( is_expanded_subtree ) |
| 1073 | { |
| 1074 | subTreeExpand( *container, *new_node, SUBTREE_EXPAND); |
| 1075 | }; |
| 1076 | } |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | |
| 1081 |
no test coverage detected