Compare commits
2 Commits
5607244db6
...
a1949026b3
Author | SHA1 | Date |
---|---|---|
monxa | a1949026b3 | |
Alexander Montag | 6776319472 |
|
@ -56,9 +56,13 @@ void TreeSearch::_clean_callable_cache() {
|
||||||
|
|
||||||
void TreeSearch::_filter_tree() {
|
void TreeSearch::_filter_tree() {
|
||||||
ERR_FAIL_COND(!tree_reference);
|
ERR_FAIL_COND(!tree_reference);
|
||||||
|
if (!tree_reference->get_root()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (matching_entries.is_empty()) {
|
if (matching_entries.is_empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_filter_tree(tree_reference->get_root(), false);
|
_filter_tree(tree_reference->get_root(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +80,10 @@ void TreeSearch::_filter_tree(TreeItem *p_item, bool p_parent_matching) {
|
||||||
// Makes all tree items visible.
|
// Makes all tree items visible.
|
||||||
void TreeSearch::_clear_filter() {
|
void TreeSearch::_clear_filter() {
|
||||||
ERR_FAIL_COND(!tree_reference);
|
ERR_FAIL_COND(!tree_reference);
|
||||||
|
if (!tree_reference->get_root()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Vector<TreeItem *> items = { tree_reference->get_root() };
|
Vector<TreeItem *> items = { tree_reference->get_root() };
|
||||||
for (int idx = 0; idx < items.size(); idx++) {
|
for (int idx = 0; idx < items.size(); idx++) {
|
||||||
TreeItem *cur_item = items[idx];
|
TreeItem *cur_item = items[idx];
|
||||||
|
@ -220,8 +228,9 @@ void TreeSearch::_update_matching_entries(const String &p_search_mask) {
|
||||||
- i4 ---> [i1,i2,i3,i4]
|
- i4 ---> [i1,i2,i3,i4]
|
||||||
*/
|
*/
|
||||||
void TreeSearch::_update_ordered_tree_items(TreeItem *p_tree_item) {
|
void TreeSearch::_update_ordered_tree_items(TreeItem *p_tree_item) {
|
||||||
if (!p_tree_item)
|
if (!p_tree_item) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (p_tree_item == p_tree_item->get_tree()->get_root()) {
|
if (p_tree_item == p_tree_item->get_tree()->get_root()) {
|
||||||
ordered_tree_items.clear();
|
ordered_tree_items.clear();
|
||||||
}
|
}
|
||||||
|
@ -245,7 +254,7 @@ void TreeSearch::_update_number_matches() {
|
||||||
if (!tree_root) {
|
if (!tree_root) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_update_number_matches(tree_reference->get_root());
|
_update_number_matches(tree_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeSearch::_update_number_matches(TreeItem *item) {
|
void TreeSearch::_update_number_matches(TreeItem *item) {
|
||||||
|
@ -268,7 +277,7 @@ void TreeSearch::_update_number_matches(TreeItem *item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
String TreeSearch::_get_search_mask() const {
|
String TreeSearch::_get_search_mask() const {
|
||||||
ERR_FAIL_COND(!search_panel);
|
ERR_FAIL_COND_V(!search_panel, "");
|
||||||
return search_panel->get_text();
|
return search_panel->get_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,10 +285,12 @@ void TreeSearch::_find_matching_entries(TreeItem *p_tree_item, const String &p_s
|
||||||
if (!p_tree_item) {
|
if (!p_tree_item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringSearchIndices item_search_indices = _substring_bounds(p_tree_item->get_text(0), p_search_mask);
|
StringSearchIndices item_search_indices = _substring_bounds(p_tree_item->get_text(0), p_search_mask);
|
||||||
if (item_search_indices.hit()) {
|
if (item_search_indices.hit()) {
|
||||||
p_accum.push_back(p_tree_item);
|
p_accum.push_back(p_tree_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < p_tree_item->get_child_count(); i++) {
|
for (int i = 0; i < p_tree_item->get_child_count(); i++) {
|
||||||
TreeItem *child = p_tree_item->get_child(i);
|
TreeItem *child = p_tree_item->get_child(i);
|
||||||
_find_matching_entries(child, p_search_mask, p_accum);
|
_find_matching_entries(child, p_search_mask, p_accum);
|
||||||
|
@ -336,8 +347,10 @@ TreeSearch::StringSearchIndices TreeSearch::_substring_bounds(const String &p_se
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeSearch::_select_item(TreeItem *p_item) {
|
void TreeSearch::_select_item(TreeItem *p_item) {
|
||||||
if (!p_item)
|
if (!p_item) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ERR_FAIL_COND(!tree_reference || p_item->get_tree() != tree_reference);
|
ERR_FAIL_COND(!tree_reference || p_item->get_tree() != tree_reference);
|
||||||
|
|
||||||
// First unfold ancestors
|
// First unfold ancestors
|
||||||
|
@ -472,12 +485,18 @@ void TreeSearch::update_search(Tree *p_tree) {
|
||||||
|
|
||||||
tree_reference = p_tree;
|
tree_reference = p_tree;
|
||||||
|
|
||||||
|
if (!tree_reference->get_root()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!search_panel->is_visible() || search_panel->get_text().length() == 0) {
|
if (!search_panel->is_visible() || search_panel->get_text().length() == 0) {
|
||||||
// Clear and redraw if search was active recently.
|
// Clear and redraw if search was active recently.
|
||||||
if (was_searched_recently) {
|
if (was_searched_recently) {
|
||||||
_clear_filter();
|
|
||||||
number_matches.clear();
|
number_matches.clear();
|
||||||
matching_entries.clear();
|
matching_entries.clear();
|
||||||
|
|
||||||
|
_clear_filter();
|
||||||
|
|
||||||
was_searched_recently = false;
|
was_searched_recently = false;
|
||||||
p_tree->queue_redraw();
|
p_tree->queue_redraw();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue