branch: store the selection and expanded state
commit18d2d3c1a4ca1761cabff2dfafdcc5b9d7e1696b
authorDavid Aguilar <davvid@gmail.com>
Tue, 25 Oct 2022 07:45:31 +0000 (25 00:45 -0700)
committerDavid Aguilar <davvid@gmail.com>
Tue, 25 Oct 2022 08:15:08 +0000 (25 01:15 -0700)
treeb40b179a12d48ff6e8b749d69ac194bcd6614020
parentf69761475a92466cb4046db253911d7eab092cc7
branch: store the selection and expanded state

We were currently saving the tree state as a sparse dict that can be
used to restore the collapsed/expanded state of tree items.

Extend this data structure to also include the selection state.
The data structure currently stores the expanded state implicitly;
existence of the dict means that the item is expanded.

The expanded state will now store the expanded state alongside other
data. Use separate dict entries for the expanded state, the selected
state and the children dict.

Update def _toggled_expanded() to only expand items and item when
that item has children. This avoid additional refreshes of the UI
because Qt will no longer re-layout the widgets below the clicked
widget.

The net result is that the selection state is restored across refreshes.
No longer do we lose the user's selection in response to actions, and
the UI no longer redraws itself as items are clicked.

Closes #1221
Reported-by: Jakub Klos <jakub@icewarp.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
CHANGES.rst
cola/widgets/branch.py
test/branch_test.py