diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-15 11:22:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-15 11:22:02 +0200 |
commit | 7e27da54d8ac3cacd7ecdcb8cdf009d76702ed69 (patch) | |
tree | df59cec8859c55f91d82b64564207dd8c2ad1967 /editor | |
parent | 7d4c3035ad7a128198a791be1b3587b5a1b6a28f (diff) | |
parent | b5b1a56c0447770bbf1c88735a3e8bbf8c2a12a8 (diff) |
Merge pull request #30516 from kawa-yoiko/editor-settings-search
Improvements on searching in the settings dialog
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(); |