Skip to content

Commit

Permalink
Fix selection expanded after change.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Nov 3, 2017
1 parent 737b6c6 commit 32b2cf5
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions lib/python/rose/config_editor/panelwidget/summary_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,14 @@ def update(self, sections=None, variables=None):
if variables is not None:
self.variables = variables
old_cols = set(self.column_names)
expanded_rows = []
self._view.map_expanded_rows(lambda r, d: expanded_rows.append(d))

# Generate a set of expanded sections (one level only).
expanded_sections = set()
model = self._view.get_model()
self._view.map_expanded_rows(
lambda r, p:
expanded_sections.add(model.get_value(model.get_iter(p), 0)))

start_path, start_column = self._view.get_cursor()
should_redraw = self.update_tree_model()
if should_redraw:
Expand All @@ -273,8 +279,18 @@ def update(self, sections=None, variables=None):
self._group_widget.set_model(group_model)
self._group_widget.set_active(start_index)
model = self._view.get_model()
for this_row in expanded_rows:
self._view.expand_to_path(this_row)

# Expand previously expanded sections (one level only).
path = (0,)
while True:
if model.get_value(model.get_iter(path), 0) in expanded_sections:
self._view.expand_to_path(path)

sibling = model.iter_next(model.get_iter(path))
if sibling:
path = model.get_path(sibling)
else:
break

def add_new_columns(self, treeview, column_names):
"""Create new columns."""
Expand Down Expand Up @@ -724,8 +740,7 @@ def _apply_grouping(self, data_rows, column_names, group_index=None,
k = group_index
data_rows = [r[k:k + 1] + r[0:k] + r[k + 1:] for r in data_rows]
column_names.insert(0, column_names.pop(k))
data_rows.sort(lambda x, y:
self._sort_row_data(x, y, 0, descending))
data_rows.sort(lambda x, y: self._sort_row_data(x, y, 0, descending))
last_entry = None
rows_are_descendants = []
for i, row in enumerate(data_rows):
Expand Down

0 comments on commit 32b2cf5

Please sign in to comment.