Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #585 #586

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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