summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2016-06-12 13:43:31 -0300
committerGeorge Marques <george@gmarqu.es>2016-06-12 14:53:03 -0300
commit68868aabc6f27a8facd8fe3ecb5719bc50f0f3f4 (patch)
tree6f5d9ec78f4f3f20a22a532f26c67c88c2b10ef6
parenta6c37d2b5d058d3bad2a942d965564c5054424c5 (diff)
Add subsequence search to tools
Add it to the following searches: - Create node. - Scene tree. - Inspector properties. - Classes list in help. - Quick open.
-rw-r--r--tools/editor/create_dialog.cpp6
-rw-r--r--tools/editor/editor_help.cpp2
-rw-r--r--tools/editor/property_editor.cpp2
-rw-r--r--tools/editor/quick_open.cpp4
-rw-r--r--tools/editor/scene_tree_editor.cpp2
5 files changed, 8 insertions, 8 deletions
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index b6137ddac0..5275e1beeb 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -103,7 +103,7 @@ void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_ty
item->set_selectable(0,false);
} else {
- if (!*to_select && (search_box->get_text()=="" || p_type.findn(search_box->get_text())!=-1)) {
+ if (!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) {
*to_select=item;
}
@@ -172,7 +172,7 @@ void CreateDialog::_update_search() {
bool found=false;
String type=I->get();
while(type!="" && ObjectTypeDB::is_type(type,base_type) && type!=base_type) {
- if (type.findn(search_box->get_text())!=-1) {
+ if (search_box->get_text().is_subsequence_ofi(type)) {
found=true;
break;
@@ -194,7 +194,7 @@ void CreateDialog::_update_search() {
const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type];
for(int i=0;i<ct.size();i++) {
- bool show = search_box->get_text()=="" || ct[i].name.findn(search_box->get_text())!=-1;
+ bool show = search_box->get_text().is_subsequence_ofi(ct[i].name);
if (!show)
continue;
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index ac9feacd46..0b60db5ee3 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -453,7 +453,7 @@ void EditorHelpIndex::_update_class_list() {
String type = E->key();
while(type != "") {
- if (type.findn(filter)!=-1) {
+ if (filter.is_subsequence_ofi(type)) {
if (to_select.empty()) {
to_select = type;
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 2f0ba2da99..ddeaa0133f 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -2804,7 +2804,7 @@ void PropertyEditor::update_tree() {
if (capitalize_paths)
cat = cat.capitalize();
- if (cat.findn(filter)==-1 && name.findn(filter)==-1)
+ if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name))
continue;
}
diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp
index 72059c264f..fc2a2241ab 100644
--- a/tools/editor/quick_open.cpp
+++ b/tools/editor/quick_open.cpp
@@ -126,7 +126,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
path+="/";
if (path!="res://") {
path=path.substr(6,path.length());
- if (path.findn(search_box->get_text())!=-1) {
+ if (search_box->get_text().is_subsequence_ofi(path)) {
TreeItem *ti = search_options->create_item(root);
ti->set_text(0,path);
Ref<Texture> icon = get_icon("folder","FileDialog");
@@ -138,7 +138,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
String file = efsd->get_file_path(i);
file=file.substr(6,file.length());
- if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_box->get_text()=="" || file.findn(search_box->get_text())!=-1)) {
+ if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_box->get_text().is_subsequence_ofi(file))) {
TreeItem *ti = search_options->create_item(root);
ti->set_text(0,file);
diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp
index f8ce121690..f192f9c628 100644
--- a/tools/editor/scene_tree_editor.cpp
+++ b/tools/editor/scene_tree_editor.cpp
@@ -386,7 +386,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
item->set_as_cursor(0);
}
- bool keep= ( filter==String() || String(p_node->get_name()).to_lower().find(filter.to_lower())!=-1 );
+ bool keep= (filter.is_subsequence_ofi(String(p_node->get_name())));
for (int i=0;i<p_node->get_child_count();i++) {