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

Method updateTreeView

bt_editor/sidepanel_editor.cpp:53–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void SidepanelEditor::updateTreeView()
54{
55 ui->paletteTreeWidget->clear();
56 _tree_view_category_items.clear();
57
58 for (const QString& category : {"Action", "Condition",
59 "Control", "Decorator", "SubTree" } )
60 {
61 auto item = new QTreeWidgetItem(ui->paletteTreeWidget, {category});
62 QFont font = item->font(0);
63 font.setBold(true);
64 font.setPointSize(11);
65 item->setFont(0, font);
66 item->setFlags( item->flags() ^ Qt::ItemIsDragEnabled );
67 item->setFlags( item->flags() ^ Qt::ItemIsSelectable );
68 _tree_view_category_items[ category ] = item;
69 }
70
71 for (const auto &it : _tree_nodes_model)
72 {
73 const auto& ID = it.first;
74 const NodeModel& model = it.second;
75
76 if( model.registration_ID == "Root")
77 {
78 continue;
79 }
80 QString category = QString::fromStdString(toStr(model.type));
81 auto parent = _tree_view_category_items[category];
82 auto item = new QTreeWidgetItem(parent, {ID});
83 const bool is_builtin = BuiltinNodeModels().count( ID ) > 0;
84 const bool is_editable = (!ui->buttonLock->isChecked() && !is_builtin);
85
86 QFont font = item->font(0);
87 font.setItalic( is_builtin );
88 font.setPointSize(11);
89 item->setFont(0, font);
90 item->setData(0, Qt::UserRole, ID);
91
92 item->setTextColor(0, is_editable ? Qt::blue : Qt::black);
93 }
94
95 ui->paletteTreeWidget->expandAll();
96}
97
98void SidepanelEditor::clear()
99{

Callers 5

loadFromXMLMethod · 0.80
onAddToModelRegistryMethod · 0.80
updateCurrentModeMethod · 0.80
onTabRenameRequestedMethod · 0.80
clearTreeModelsMethod · 0.80

Calls 2

toStrFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected