Skip to content

Commit

Permalink
Merge pull request #6336 from PrimozGodec/select-rows-fix
Browse files Browse the repository at this point in the history
[FIX] Select Rows - Fix checked groups not considered in PyQt6
  • Loading branch information
janezd authored Feb 17, 2023
2 parents c42459a + 2e9b483 commit b122cea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Orange/widgets/data/owselectrows.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def _get_value_contents(box):
model = child.popup.list_view.model()
for row in range(model.rowCount()):
item = model.item(row)
if item.checkState():
if item.checkState() == Qt.Checked:
cont.append(row + 1)
names.append(item.text())
child.desc_text = ', '.join(names)
Expand Down
32 changes: 31 additions & 1 deletion Orange/widgets/data/tests/test_owselectrows.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test methods with long descriptive names can omit docstrings
# pylint: disable=missing-docstring,unsubscriptable-object
import time
import unittest
from unittest.mock import patch
import numpy as np

Expand Down Expand Up @@ -558,6 +558,32 @@ def test_meta_setting(self):
self.send_signal(self.widget.Inputs.data, data)
self.assertListEqual([c[0] for c in self.widget.conditions], vars_)

def test_one_of_click(self):
"""Test items checked in is one of dropdown"""
zoo = Table("zoo")
self.send_signal(self.widget.Inputs.data, zoo)
self.widget.remove_all_button.click()
self.enterFilter(zoo.domain[1], "is one of")
model = self.widget.cond_list.cellWidget(0, 2).popup.list_view.model()

output = self.get_output(self.widget.Outputs.matching_data)
self.assertEqual(len(zoo), len(output))

# check second item (group 1) - only 20 elements in this group
model.item(1).setCheckState(Qt.Checked)
output = self.get_output(self.widget.Outputs.matching_data)
self.assertEqual(20, len(output))

# check first item (group 0) - now all elements should be at the output
model.item(0).setCheckState(Qt.Checked)
output = self.get_output(self.widget.Outputs.matching_data)
self.assertEqual(len(zoo), len(output))

# uncheck second element (group 1) - only elements fo group 0 at output
model.item(1).setCheckState(Qt.Unchecked)
output = self.get_output(self.widget.Outputs.matching_data)
self.assertEqual(81, len(output))

def widget_with_context(self, domain, conditions):
ch = SelectRowsContextHandler()
context = ch.new_context(domain, *ch.encode_domain(domain))
Expand Down Expand Up @@ -612,3 +638,7 @@ def __set_value(widget, value):
widget.setDate(value)
else:
raise ValueError("Unsupported widget {}".format(widget))


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

0 comments on commit b122cea

Please sign in to comment.