mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00
LibGUI: Simplify GTreeView ancestor traversal
This commit is contained in:
parent
fed0133109
commit
6b5fbad250
1 changed files with 2 additions and 9 deletions
|
@ -226,19 +226,12 @@ void GTreeView::did_update_selection()
|
||||||
if (!index.is_valid())
|
if (!index.is_valid())
|
||||||
return;
|
return;
|
||||||
bool opened_any = false;
|
bool opened_any = false;
|
||||||
auto& metadata_for_index = ensure_metadata_for_index(index);
|
for (auto current = index; current.is_valid(); current = current.parent()) {
|
||||||
if (!metadata_for_index.open) {
|
auto& metadata_for_ancestor = ensure_metadata_for_index(current);
|
||||||
opened_any = true;
|
|
||||||
metadata_for_index.open = true;
|
|
||||||
}
|
|
||||||
auto ancestor = index.parent();
|
|
||||||
while (ancestor.is_valid()) {
|
|
||||||
auto& metadata_for_ancestor = ensure_metadata_for_index(ancestor);
|
|
||||||
if (!metadata_for_ancestor.open) {
|
if (!metadata_for_ancestor.open) {
|
||||||
metadata_for_ancestor.open = true;
|
metadata_for_ancestor.open = true;
|
||||||
opened_any = true;
|
opened_any = true;
|
||||||
}
|
}
|
||||||
ancestor = ancestor.parent();
|
|
||||||
}
|
}
|
||||||
if (opened_any)
|
if (opened_any)
|
||||||
update_content_size();
|
update_content_size();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue