Skip to content

Commit

Permalink
Merge pull request #4281 from janezd/table-keep-pending-selection
Browse files Browse the repository at this point in the history
[FIX] Table: Keep pending selection if data is None
  • Loading branch information
markotoplak authored Dec 20, 2019
2 parents ea0146b + fa539f4 commit 67bd87a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Orange/widgets/data/owtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,20 +519,17 @@ def update(_):
if current is not None:
# pylint: disable=protected-access
self.set_info(current._input_slot.summary)
else:
self.__pending_selected_rows = None
self.__pending_selected_cols = None

self.tabs.tabBar().setVisible(self.tabs.count() > 1)
self.openContext(data)

if self.__pending_selected_rows is not None:
if data and self.__pending_selected_rows is not None:
self.selected_rows = self.__pending_selected_rows
self.__pending_selected_rows = None
else:
self.selected_rows = []

if self.__pending_selected_cols is not None:
if data and self.__pending_selected_cols is not None:
self.selected_cols = self.__pending_selected_cols
self.__pending_selected_cols = None
else:
Expand Down
9 changes: 9 additions & 0 deletions Orange/widgets/data/tests/test_owtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ def test_unconditional_commit_on_new_signal(self):
self.send_signal(self.widget.Inputs.data, self.data)
commit.assert_called()

def test_pending_selection(self):
widget = self.create_widget(OWDataTable, stored_settings=dict(
selected_rows=[5, 6, 7, 8, 9],
selected_cols=list(range(len(self.data.domain)))))
self.send_signal(widget.Inputs.data, None, 1)
self.send_signal(widget.Inputs.data, self.data, 1)
output = self.get_output(widget.Outputs.selected_data)
self.assertEqual(5, len(output))


if __name__ == "__main__":
unittest.main()

0 comments on commit 67bd87a

Please sign in to comment.