From 7c8e91169ea2e5b30bf354cea9e6cdf572a5e307 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 14 Jan 2024 20:25:50 -0500 Subject: save expansion state --- src/components/channellist/channellisttree.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/components') diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index 720fdd2..b9c4d3c 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -691,6 +691,23 @@ void ChannelListTree::UseExpansionState(const ExpansionStateRoot &root) { ExpansionStateRoot ChannelListTree::GetExpansionState() const { ExpansionStateRoot r; + auto recurse = [this](auto &self, const Gtk::TreeRow &row) -> ExpansionState { + ExpansionState r; + + r.IsExpanded = row[m_columns.m_expanded]; + for (auto child : row.children()) { + r.Children.Children[static_cast(child[m_columns.m_id])] = self(self, child); + } + + return r; + }; + + for (auto child : m_model->children()) { + const auto id = static_cast(child[m_columns.m_id]); + if (static_cast(id) == 0ULL) continue; // dont save DM header + r.Children[id] = recurse(recurse, child); + } + return r; } -- cgit v1.2.3