auto create & edit choice

This commit is contained in:
Maxime Réaux 2026-01-30 15:32:44 +01:00
parent 723723dea1
commit 9f676f6b9d
6 changed files with 166 additions and 59 deletions

View file

@ -387,6 +387,8 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
if not name_item:
return
choice_id = name_item.data(Qt.ItemDataRole.UserRole)
if choice_id is None:
return
menu = QMenu(self)
edit_action = menu.addAction("Edit")
action = menu.exec(self.choicesTable.viewport().mapToGlobal(pos))
@ -396,16 +398,19 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
def show_round_details(self, *, index: int):
self.roundNb.setText(f"Round {index}")
def display_round_choices(self, rows: list[dict]):
self.choicesTable.setRowCount(len(rows))
for row, data in enumerate(rows):
self.choicesTable.setItem(row, 0, QtWidgets.QTableWidgetItem(data["participant_name"]))
self.choicesTable.setItem(row, 1, QtWidgets.QTableWidgetItem(data["priority"]))
self.choicesTable.setItem(row, 2, QtWidgets.QTableWidgetItem(data["secondary"]))
self.choicesTable.item(row, 0).setData(
Qt.ItemDataRole.UserRole,
data["participant_id"]
)
def display_round_choices(self, participants: list[tuple[str, str, str, str]]):
table = self.choicesTable
table.clearContents()
table.setRowCount(len(participants))
for row, (participant, priority, secondary, choice_id) in enumerate(participants):
participant_item = QtWidgets.QTableWidgetItem(participant)
priority_item = QtWidgets.QTableWidgetItem(priority)
secondary_item = QtWidgets.QTableWidgetItem(secondary)
participant_item.setData(Qt.ItemDataRole.UserRole, choice_id)
table.setItem(row, 0, participant_item)
table.setItem(row, 1, priority_item)
table.setItem(row, 2, secondary_item)
table.resizeColumnsToContents()
class PlayerDialog(QDialog):
def __init__(self, parent=None, *, default_name: str = ""):