mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 15:59:43 +00:00
LibGUI/TreeView: Select parent on collapse
When collapsing a tree that contains the current selection, the parent node becomes selected instead.
This commit is contained in:
parent
67a5e9f018
commit
7a4445a1fe
Notes:
sideshowbarker
2024-07-18 17:05:47 +09:00
Author: https://github.com/gmta
Commit: 7a4445a1fe
Pull-request: https://github.com/SerenityOS/serenity/pull/7646
3 changed files with 16 additions and 0 deletions
|
@ -19,6 +19,17 @@ Variant ModelIndex::data(ModelRole role) const
|
|||
return model()->data(*this, role);
|
||||
}
|
||||
|
||||
bool ModelIndex::is_parent_of(const ModelIndex& child) const
|
||||
{
|
||||
auto current_index = child.parent();
|
||||
while (current_index.is_valid()) {
|
||||
if (current_index == *this)
|
||||
return true;
|
||||
current_index = current_index.parent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ModelIndex ModelIndex::sibling(int row, int column) const
|
||||
{
|
||||
if (!is_valid())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue