diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/TreeView.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/TreeView.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TreeView.cpp b/Userland/Libraries/LibGUI/TreeView.cpp index 87d58ad7d6..b5cc4a0978 100644 --- a/Userland/Libraries/LibGUI/TreeView.cpp +++ b/Userland/Libraries/LibGUI/TreeView.cpp @@ -158,6 +158,18 @@ void TreeView::toggle_index(ModelIndex const& index) update(); } +bool TreeView::is_toggled(ModelIndex const& index) +{ + if (model()->row_count(index) == 0) { + if (model()->parent_index(index).is_valid()) + return is_toggled(model()->parent_index(index)); + return false; + } + + auto& metadata = ensure_metadata_for_index(index); + return metadata.open; +} + template<typename Callback> void TreeView::traverse_in_paint_order(Callback callback) const { diff --git a/Userland/Libraries/LibGUI/TreeView.h b/Userland/Libraries/LibGUI/TreeView.h index 3e1543e8a8..b369b75a14 100644 --- a/Userland/Libraries/LibGUI/TreeView.h +++ b/Userland/Libraries/LibGUI/TreeView.h @@ -21,6 +21,7 @@ public: virtual int item_count() const override; virtual void toggle_index(ModelIndex const&) override; + bool is_toggled(ModelIndex const& index); void expand_tree(ModelIndex const& root = {}); void collapse_tree(ModelIndex const& root = {}); |