Skip to content

Commit

Permalink
ListView: Fix selection
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT authored and markotoplak committed Oct 10, 2024
1 parent a395d45 commit bfe44fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions Orange/widgets/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
is_macstyle
)
from orangewidget.utils.itemmodels import PyTableModel
from orangewidget.utils.listview import ListViewFilter

try:
# Some Orange widgets might expect this here
Expand Down Expand Up @@ -192,13 +193,15 @@ def listView(widget, master, value=None, model=None, box=None, callback=None,
else:
bg = widget
view = viewType(preferred_size=sizeHint)
if isinstance(view.model(), QSortFilterProxyModel):
if isinstance(view, ListViewFilter):
view.model().setSourceModel(model)
signal = view.sigSelectionChanged
else:
view.setModel(model)
signal = view.selectionModel().selectionChanged
if value is not None:
connectControl(master, value, callback,
view.selectionModel().selectionChanged,
signal,
CallFrontListView(view),
CallBackListView(model, view, master, value))
misc.setdefault('uniformItemSizes', True)
Expand Down Expand Up @@ -500,8 +503,8 @@ def __call__(self, *_):
from Orange.widgets.utils.itemmodels import PyListModel

selection = self.view.selectionModel().selection()
if isinstance(self.view.model(), QSortFilterProxyModel):
selection = self.view.model().mapSelectionToSource(selection)
if isinstance(self.view, ListViewFilter):
selection = self.view.selection
values = [i.row() for i in selection.indexes()]

# set attribute's values
Expand Down
2 changes: 1 addition & 1 deletion requirements-gui.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
orange-canvas-core>=0.2.2,<0.3a
orange-widget-base>=4.23.0
orange-widget-base>=4.25.0

AnyQt>=0.2.0

Expand Down

0 comments on commit bfe44fc

Please sign in to comment.