Skip to content

Commit

Permalink
Fix #585
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelNicaise committed May 25, 2023
1 parent e19d32a commit 92aff70
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions cutevariant/gui/widgets/choice_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class ChoiceModel(QAbstractListModel):

choice_changed = Signal()

def __init__(self, parent=None):
Expand Down Expand Up @@ -79,14 +78,12 @@ def setData(self, index: QModelIndex, value: typing.Any, role: Qt.ItemDataRole):
TYPE: Description
"""
if role == Qt.CheckStateRole:

checked = True if value == Qt.Checked else False
self._data[index.row()]["checked"] = checked

if checked:
self.rows_checked.add(index.row())
else:
if index.row() in self.rows_checked:
self.rows_checked.remove(index.row())
self._data[index.row()]["checked"] = False
else:
self.rows_checked.add(index.row())
self._data[index.row()]["checked"] = True

self.dataChanged.emit(index, index, [Qt.CheckStateRole])
self.choice_changed.emit()
Expand Down Expand Up @@ -187,7 +184,6 @@ def get_checked(self) -> typing.List[str]:


class ChoiceButton(QPushButton):

item_changed = Signal(list)

def __init__(self, parent=None):
Expand Down Expand Up @@ -272,7 +268,7 @@ def uncheck_all(self):

l.addWidget(btn)

btn.set_checked(["test2"])
btn.set_checked(["test 2"])

w.show()

Expand Down

0 comments on commit 92aff70

Please sign in to comment.