fix random hidden cells in tables

This commit is contained in:
Maxime Réaux 2026-02-26 16:00:42 +01:00
parent e457131879
commit 0897f8de40

View file

@ -197,11 +197,13 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
def display_players(self, players: List[ParticipantOption]) -> None: def display_players(self, players: List[ParticipantOption]) -> None:
table = self.playersTable table = self.playersTable
table.setSortingEnabled(False)
table.setRowCount(len(players)) table.setRowCount(len(players))
for row, player in enumerate(players): for row, player in enumerate(players):
play_item = QtWidgets.QTableWidgetItem(player.name) play_item = QtWidgets.QTableWidgetItem(player.name)
play_item.setData(Qt.ItemDataRole.UserRole, player.id) play_item.setData(Qt.ItemDataRole.UserRole, player.id)
table.setItem(row, 0, play_item) table.setItem(row, 0, play_item)
table.setSortingEnabled(True)
table.resizeColumnsToContents() table.resizeColumnsToContents()
# Wars view # Wars view
@ -355,6 +357,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
def display_war_objectives(self, objectives: List[ObjectiveDTO]) -> None: def display_war_objectives(self, objectives: List[ObjectiveDTO]) -> None:
table = self.objectivesTable table = self.objectivesTable
table.setSortingEnabled(False)
table.clearContents() table.clearContents()
table.setRowCount(len(objectives)) table.setRowCount(len(objectives))
for row, obj in enumerate(objectives): for row, obj in enumerate(objectives):
@ -363,6 +366,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
name_item.setData(Qt.ItemDataRole.UserRole, obj.id) name_item.setData(Qt.ItemDataRole.UserRole, obj.id)
table.setItem(row, 0, name_item) table.setItem(row, 0, name_item)
table.setItem(row, 1, desc_item) table.setItem(row, 1, desc_item)
table.setSortingEnabled(True)
table.resizeColumnsToContents() table.resizeColumnsToContents()
def display_war_participants( def display_war_participants(
@ -371,6 +375,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
objectives: List[ObjectiveDTO], objectives: List[ObjectiveDTO],
) -> None: ) -> None:
table = self.warParticipantsTable table = self.warParticipantsTable
table.setSortingEnabled(False)
table.clearContents() table.clearContents()
base_cols = ["Player", "Faction", "Victory pts"] base_cols = ["Player", "Faction", "Victory pts"]
headers = ( headers = (
@ -398,6 +403,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
table.setItem(row, col, NP_item) table.setItem(row, col, NP_item)
col += 1 col += 1
table.setItem(row, col, token_item) table.setItem(row, col, token_item)
table.setSortingEnabled(True)
table.resizeColumnsToContents() table.resizeColumnsToContents()
def _on_major_changed(self, value: int) -> None: def _on_major_changed(self, value: int) -> None:
@ -467,6 +473,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
def display_campaign_sectors(self, sectors: List[SectorDTO]) -> None: def display_campaign_sectors(self, sectors: List[SectorDTO]) -> None:
table = self.sectorsTable table = self.sectorsTable
table.setSortingEnabled(False)
table.clearContents() table.clearContents()
table.setRowCount(len(sectors)) table.setRowCount(len(sectors))
for row, sect in enumerate(sectors): for row, sect in enumerate(sectors):
@ -487,6 +494,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
table.setItem(row, 4, minor_item) table.setItem(row, 4, minor_item)
table.setItem(row, 5, influence_item) table.setItem(row, 5, influence_item)
table.setItem(row, 6, description_item) table.setItem(row, 6, description_item)
table.setSortingEnabled(True)
table.resizeColumnsToContents() table.resizeColumnsToContents()
def display_campaign_participants( def display_campaign_participants(
@ -495,6 +503,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
objectives: List[ObjectiveDTO], objectives: List[ObjectiveDTO],
) -> None: ) -> None:
table = self.campaignParticipantsTable table = self.campaignParticipantsTable
table.setSortingEnabled(False)
table.clearContents() table.clearContents()
base_cols = ["Player", "Leader", "Theme", "Victory pts"] base_cols = ["Player", "Leader", "Theme", "Victory pts"]
headers = ( headers = (
@ -524,6 +533,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
table.setItem(row, col, NP_item) table.setItem(row, col, NP_item)
col += 1 col += 1
table.setItem(row, col, token_item) table.setItem(row, col, token_item)
table.setSortingEnabled(True)
table.resizeColumnsToContents() table.resizeColumnsToContents()
# Round page # Round page
@ -571,6 +581,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
def display_round_choices(self, participants: List[ChoiceDTO]) -> None: def display_round_choices(self, participants: List[ChoiceDTO]) -> None:
table = self.choicesTable table = self.choicesTable
table.setSortingEnabled(False)
table.clearContents() table.clearContents()
table.setRowCount(len(participants)) table.setRowCount(len(participants))
for row, choice in enumerate(participants): for row, choice in enumerate(participants):
@ -581,10 +592,12 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
table.setItem(row, 0, participant_item) table.setItem(row, 0, participant_item)
table.setItem(row, 1, priority_item) table.setItem(row, 1, priority_item)
table.setItem(row, 2, secondary_item) table.setItem(row, 2, secondary_item)
table.setSortingEnabled(True)
table.resizeColumnsToContents() table.resizeColumnsToContents()
def display_round_battles(self, sectors: List[BattleDTO]) -> None: def display_round_battles(self, sectors: List[BattleDTO]) -> None:
table = self.battlesTable table = self.battlesTable
table.setSortingEnabled(False)
table.clearContents() table.clearContents()
table.setRowCount(len(sectors)) table.setRowCount(len(sectors))
table.setIconSize(QSize(32, 16)) table.setIconSize(QSize(32, 16))
@ -608,4 +621,5 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
table.setItem(row, 3, vp_item) table.setItem(row, 3, vp_item)
table.setItem(row, 4, score_item) table.setItem(row, 4, score_item)
table.setItem(row, 5, comment_item) table.setItem(row, 5, comment_item)
table.setSortingEnabled(True)
table.resizeColumnsToContents() table.resizeColumnsToContents()