diff options
author | Shiqing <shiqing-thu18@yandex.com> | 2019-07-11 15:56:08 +0800 |
---|---|---|
committer | Shiqing <shiqing-thu18@yandex.com> | 2019-07-12 22:20:06 +0800 |
commit | b5b1a56c0447770bbf1c88735a3e8bbf8c2a12a8 (patch) | |
tree | b62857742e85e732d8c840252614d4a64cddfb27 /editor | |
parent | 49ce6bacc338d4279c121e13d4c7434d4318e4e4 (diff) |
Fixes and improvements in settings search
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_sectioned_inspector.cpp | 25 | ||||
-rw-r--r-- | editor/editor_sectioned_inspector.h | 2 |
2 files changed, 19 insertions, 8 deletions
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index e7019e4ef6..ad6b280b6d 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -144,8 +144,9 @@ void SectionedInspector::_section_selected() { if (!sections->get_selected()) return; - filter->set_section(sections->get_selected()->get_metadata(0), sections->get_selected()->get_children() == NULL); - inspector->set_property_prefix(String(sections->get_selected()->get_metadata(0)) + "/"); + selected_category = sections->get_selected()->get_metadata(0); + filter->set_section(selected_category, sections->get_selected()->get_children() == NULL); + inspector->set_property_prefix(selected_category + "/"); } void SectionedInspector::set_current_section(const String &p_section) { @@ -197,8 +198,13 @@ void SectionedInspector::edit(Object *p_object) { filter->set_edited(p_object); inspector->edit(filter); - if (sections->get_root()->get_children()) { - sections->get_root()->get_children()->select(0); + TreeItem *first_item = sections->get_root(); + if (first_item) { + while (first_item->get_children()) + first_item = first_item->get_children(); + + first_item->select(0); + selected_category = first_item->get_metadata(0); } } else { @@ -208,7 +214,6 @@ void SectionedInspector::edit(Object *p_object) { void SectionedInspector::update_category_list() { - String selected_category = get_current_section(); sections->clear(); Object *o = ObjectDB::get_instance(obj); @@ -224,6 +229,10 @@ void SectionedInspector::update_category_list() { TreeItem *root = sections->create_item(); section_map[""] = root; + String filter; + if (search_box) + filter = search_box->get_text(); + for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { PropertyInfo pi = E->get(); @@ -236,9 +245,6 @@ void SectionedInspector::update_category_list() { if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene" || pi.name.begins_with("_global_script")) continue; - if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1) - continue; - int sp = pi.name.find("/"); if (sp == -1) pi.name = "global/" + pi.name; @@ -246,6 +252,9 @@ void SectionedInspector::update_category_list() { Vector<String> sectionarr = pi.name.split("/"); String metasection; + if (!filter.empty() && !filter.is_subsequence_ofi(sectionarr[sectionarr.size() - 1].capitalize())) + continue; + int sc = MIN(2, sectionarr.size() - 1); for (int i = 0; i < sc; i++) { diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h index c32f23890f..4395e9bb27 100644 --- a/editor/editor_sectioned_inspector.h +++ b/editor/editor_sectioned_inspector.h @@ -50,6 +50,8 @@ class SectionedInspector : public HSplitContainer { EditorInspector *inspector; LineEdit *search_box; + String selected_category; + static void _bind_methods(); void _section_selected(); |