MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / onModelRemoveRequested

Method onModelRemoveRequested

bt_editor/mainwindow.cpp:839–900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839void MainWindow::onModelRemoveRequested(QString ID)
840{
841 BehaviorTreeDataModel* node_found = nullptr;
842 QString tab_containing_node;
843
844 for (auto& it: _tab_info)
845 {
846 auto container = it.second;
847 for(const auto& node_it: container->scene()->nodes() )
848 {
849 QtNodes::Node* graphic_node = node_it.second.get();
850 auto bt_node = dynamic_cast<BehaviorTreeDataModel*>( graphic_node->nodeDataModel() );
851
852 if( bt_node->model().registration_ID == ID )
853 {
854 node_found = bt_node;
855 tab_containing_node = it.first;
856 break;
857 }
858 }
859 if( node_found != nullptr )
860 {
861 break;
862 }
863 }
864
865 NodeType node_type = _treenode_models.at(ID).type;
866
867 if( node_found && node_type != NodeType::SUBTREE )
868 {
869 QMessageBox::warning(this, "Can't remove this Model",
870 QString( "You are using this model in the Tree called [%1].\n"
871 "You can't delete this model unless you "
872 "remove all the instances of [%2].").arg(tab_containing_node, ID ),
873 QMessageBox::Ok );
874 }
875 else
876 {
877 int ret = QMessageBox::Cancel;
878 if( node_found->model().type != NodeType::SUBTREE )
879 {
880 ret = QMessageBox::warning(this,"Delete TreeNode Model?",
881 "Are you sure? This action can't be undone.",
882 QMessageBox::Cancel | QMessageBox::Yes,
883 QMessageBox::Cancel);
884 }
885 else{
886 ret = QMessageBox::warning(this,"Delete Subtree?",
887 "The Model of the Subtrees will be removed."
888 "An expanded version will be added to parent trees.\n"
889 "Are you sure? This action can't be undone.",
890 QMessageBox::Cancel | QMessageBox::Yes,
891 QMessageBox::Cancel);
892 }
893
894 if(ret == QMessageBox::Yes )
895 {
896 _editor_widget->onRemoveModel(ID);

Callers

nothing calls this directly

Calls 2

sceneMethod · 0.80
onRemoveModelMethod · 0.80

Tested by

no test coverage detected