mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
LibGUI: Only report toggled directories once on subtree collapse/expansion
This prevents redundant calls to on_toggle for the same indices when subtrees are collapsed or expanded.
This commit is contained in:
parent
f1bbc39148
commit
366d7e6d05
1 changed files with 6 additions and 3 deletions
|
@ -110,13 +110,16 @@ void TreeView::doubleclick_event(MouseEvent& event)
|
||||||
|
|
||||||
void TreeView::set_open_state_of_all_in_subtree(const ModelIndex& root, bool open)
|
void TreeView::set_open_state_of_all_in_subtree(const ModelIndex& root, bool open)
|
||||||
{
|
{
|
||||||
if (root.is_valid())
|
if (root.is_valid()) {
|
||||||
ensure_metadata_for_index(root).open = open;
|
ensure_metadata_for_index(root).open = open;
|
||||||
|
if (model()->row_count(root)) {
|
||||||
|
if (on_toggle)
|
||||||
|
on_toggle(root, open);
|
||||||
|
}
|
||||||
|
}
|
||||||
int row_count = model()->row_count(root);
|
int row_count = model()->row_count(root);
|
||||||
int column = model()->tree_column();
|
int column = model()->tree_column();
|
||||||
for (int row = 0; row < row_count; ++row) {
|
for (int row = 0; row < row_count; ++row) {
|
||||||
if (on_toggle)
|
|
||||||
on_toggle(root, open);
|
|
||||||
auto index = model()->index(row, column, root);
|
auto index = model()->index(row, column, root);
|
||||||
set_open_state_of_all_in_subtree(index, open);
|
set_open_state_of_all_in_subtree(index, open);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue