mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
LibGUI: Add TreeView::expand_all_parents_of(ModelIndex)
This does exactly what it sounds like. :^)
This commit is contained in:
parent
76ae47c6ed
commit
3bccd99fe9
2 changed files with 19 additions and 0 deletions
|
@ -125,6 +125,23 @@ void TreeView::set_open_state_of_all_in_subtree(const ModelIndex& root, bool ope
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TreeView::expand_all_parents_of(const ModelIndex& index)
|
||||||
|
{
|
||||||
|
if (!model())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto current = index;
|
||||||
|
while (current.is_valid()) {
|
||||||
|
ensure_metadata_for_index(current).open = true;
|
||||||
|
if (on_toggle)
|
||||||
|
on_toggle(current, true);
|
||||||
|
current = current.parent();
|
||||||
|
}
|
||||||
|
update_column_sizes();
|
||||||
|
update_content_size();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void TreeView::expand_tree(const ModelIndex& root)
|
void TreeView::expand_tree(const ModelIndex& root)
|
||||||
{
|
{
|
||||||
if (!model())
|
if (!model())
|
||||||
|
|
|
@ -44,6 +44,8 @@ public:
|
||||||
void expand_tree(const ModelIndex& root = {});
|
void expand_tree(const ModelIndex& root = {});
|
||||||
void collapse_tree(const ModelIndex& root = {});
|
void collapse_tree(const ModelIndex& root = {});
|
||||||
|
|
||||||
|
void expand_all_parents_of(const ModelIndex&);
|
||||||
|
|
||||||
Function<void(const ModelIndex&, const bool)> on_toggle;
|
Function<void(const ModelIndex&, const bool)> on_toggle;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue