| 180 | } |
| 181 | |
| 182 | void GroupsEditor::_update_tree() { |
| 183 | if (!is_visible_in_tree()) { |
| 184 | groups_dirty = true; |
| 185 | return; |
| 186 | } |
| 187 | |
| 188 | if (!node) { |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | if (updating_tree) { |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | updating_tree = true; |
| 197 | |
| 198 | tree->clear(); |
| 199 | |
| 200 | List<Node::GroupInfo> groups; |
| 201 | node->get_groups(&groups); |
| 202 | groups.sort_custom<_GroupInfoComparator>(); |
| 203 | |
| 204 | List<StringName> current_groups; |
| 205 | for (const Node::GroupInfo &gi : groups) { |
| 206 | current_groups.push_back(gi.name); |
| 207 | } |
| 208 | |
| 209 | TreeItem *root = tree->create_item(); |
| 210 | |
| 211 | TreeItem *local_root = tree->create_item(root); |
| 212 | local_root->set_text(0, TTR("Scene Groups")); |
| 213 | local_root->set_icon(0, get_editor_theme_icon(SNAME("PackedScene"))); |
| 214 | local_root->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor))); |
| 215 | local_root->set_selectable(0, false); |
| 216 | |
| 217 | List<StringName> scene_keys; |
| 218 | for (const KeyValue<StringName, bool> &E : scene_groups) { |
| 219 | scene_keys.push_back(E.key); |
| 220 | } |
| 221 | scene_keys.sort_custom<NoCaseComparator>(); |
| 222 | |
| 223 | for (const StringName &E : scene_keys) { |
| 224 | if (!filter->get_text().is_subsequence_ofn(E)) { |
| 225 | continue; |
| 226 | } |
| 227 | |
| 228 | TreeItem *item = tree->create_item(local_root); |
| 229 | item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); |
| 230 | item->set_editable(0, can_edit(node, E)); |
| 231 | item->set_checked(0, current_groups.find(E) != nullptr); |
| 232 | item->set_text(0, E); |
| 233 | item->set_meta("__local", true); |
| 234 | item->set_meta("__name", E); |
| 235 | item->set_meta("__description", ""); |
| 236 | if (!scene_groups[E]) { |
| 237 | item->add_button(0, get_editor_theme_icon(SNAME("Lock")), -1, true, TTR("This group belongs to another scene and can't be edited.")); |
| 238 | } |
| 239 | item->add_button(0, get_editor_theme_icon(SNAME("ActionCopy")), COPY_GROUP, false, TTR("Copy group name to clipboard.")); |
nothing calls this directly
no test coverage detected