fix propagate player update to participant views

This commit is contained in:
Maxime Réaux 2026-02-10 11:09:58 +01:00
parent 7792a76f8e
commit dd886802f4
6 changed files with 24 additions and 21 deletions

View file

@ -27,3 +27,4 @@ class RefreshScope(Enum):
WAR_DETAILS = auto() WAR_DETAILS = auto()
CAMPAIGN_DETAILS = auto() CAMPAIGN_DETAILS = auto()
ROUND_DETAILS = auto() ROUND_DETAILS = auto()
CURRENT_SELECTION_DETAILS = auto()

View file

@ -157,22 +157,22 @@ class AppController:
) )
elif item_type == ItemType.OBJECTIVE: elif item_type == ItemType.OBJECTIVE:
self.wars.edit_objective(item_id) self.wars.edit_objective(item_id)
self.navigation.refresh(RefreshScope.WAR_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.WAR_PARTICIPANT: elif item_type == ItemType.WAR_PARTICIPANT:
self.wars.edit_war_participant(item_id) self.wars.edit_war_participant(item_id)
self.navigation.refresh(RefreshScope.WAR_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.SECTOR: elif item_type == ItemType.SECTOR:
self.campaigns.edit_sector(item_id) self.campaigns.edit_sector(item_id)
self.navigation.refresh(RefreshScope.CAMPAIGN_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.CAMPAIGN_PARTICIPANT: elif item_type == ItemType.CAMPAIGN_PARTICIPANT:
self.campaigns.edit_campaign_participant(item_id) self.campaigns.edit_campaign_participant(item_id)
self.navigation.refresh(RefreshScope.CAMPAIGN_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.CHOICE: elif item_type == ItemType.CHOICE:
self.rounds.edit_round_choice(item_id) self.rounds.edit_round_choice(item_id)
self.navigation.refresh(RefreshScope.ROUND_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.BATTLE: elif item_type == ItemType.BATTLE:
self.rounds.edit_round_battle(item_id) self.rounds.edit_round_battle(item_id)
self.navigation.refresh(RefreshScope.ROUND_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
self.is_dirty = True self.is_dirty = True
except UpdateRequiresConfirmation as e: except UpdateRequiresConfirmation as e:
reply = QMessageBox.question( reply = QMessageBox.question(
@ -183,7 +183,7 @@ class AppController:
) )
if reply == QMessageBox.StandardButton.Yes: if reply == QMessageBox.StandardButton.Yes:
e.apply_update() e.apply_update()
self.navigation.refresh(RefreshScope.CAMPAIGN_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
def delete_item(self, item_type: str, item_id: str) -> None: def delete_item(self, item_type: str, item_id: str) -> None:
reply = QMessageBox.question( reply = QMessageBox.question(
@ -210,16 +210,16 @@ class AppController:
) )
elif item_type == ItemType.OBJECTIVE: elif item_type == ItemType.OBJECTIVE:
self.model.remove_objective(item_id) self.model.remove_objective(item_id)
self.navigation.refresh(RefreshScope.WAR_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.WAR_PARTICIPANT: elif item_type == ItemType.WAR_PARTICIPANT:
self.model.remove_war_participant(item_id) self.model.remove_war_participant(item_id)
self.navigation.refresh(RefreshScope.WAR_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.SECTOR: elif item_type == ItemType.SECTOR:
self.model.remove_sector(item_id) self.model.remove_sector(item_id)
self.navigation.refresh(RefreshScope.CAMPAIGN_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.CAMPAIGN_PARTICIPANT: elif item_type == ItemType.CAMPAIGN_PARTICIPANT:
self.model.remove_campaign_participant(item_id) self.model.remove_campaign_participant(item_id)
self.navigation.refresh(RefreshScope.CAMPAIGN_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
elif item_type == ItemType.ROUND: elif item_type == ItemType.ROUND:
camp = self.model.get_campaign_by_round(item_id) camp = self.model.get_campaign_by_round(item_id)
camp_id = camp.id camp_id = camp.id
@ -243,4 +243,4 @@ class AppController:
) )
if reply == QMessageBox.StandardButton.Yes: if reply == QMessageBox.StandardButton.Yes:
e.cleanup_action() e.cleanup_action()
self.navigation.refresh(RefreshScope.CAMPAIGN_DETAILS) self.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)

View file

@ -123,7 +123,7 @@ class CampaignController:
self.app.navigation.selected_campaign_id, player_id, leader, theme self.app.navigation.selected_campaign_id, player_id, leader, theme
) )
self.app.is_dirty = True self.app.is_dirty = True
self.app.navigation.refresh(RefreshScope.CAMPAIGN_DETAILS) self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
def edit_campaign_participant(self, participant_id: str) -> None: def edit_campaign_participant(self, participant_id: str) -> None:
camp_part = self.app.model.get_campaign_participant(participant_id) camp_part = self.app.model.get_campaign_participant(participant_id)
@ -198,7 +198,7 @@ class CampaignController:
influence_id, influence_id,
) )
self.app.is_dirty = True self.app.is_dirty = True
self.app.navigation.refresh(RefreshScope.CAMPAIGN_DETAILS) self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
def edit_sector(self, sector_id: str) -> None: def edit_sector(self, sector_id: str) -> None:
sect = self.app.model.get_sector(sector_id) sect = self.app.model.get_sector(sector_id)

View file

@ -59,18 +59,18 @@ class NavigationController:
self.app.navigation.refresh_players_view() self.app.navigation.refresh_players_view()
case RefreshScope.WARS_TREE: case RefreshScope.WARS_TREE:
self.app.navigation.refresh_wars_view() self.app.navigation.refresh_wars_view()
case RefreshScope.WAR_DETAILS: case RefreshScope.CURRENT_SELECTION_DETAILS:
if self.selected_war_id: if self.selected_war_id:
self.app.view.show_details(ItemType.WAR) self.app.view.show_details(ItemType.WAR)
self.app.wars._fill_war_details(self.selected_war_id) self.app.wars._fill_war_details(self.selected_war_id)
case RefreshScope.CAMPAIGN_DETAILS: elif self.selected_campaign_id:
if self.selected_campaign_id:
self.app.view.show_details(ItemType.CAMPAIGN) self.app.view.show_details(ItemType.CAMPAIGN)
self.app.campaigns._fill_campaign_details(self.selected_campaign_id) self.app.campaigns._fill_campaign_details(self.selected_campaign_id)
case RefreshScope.ROUND_DETAILS: elif self.selected_round_id:
if self.selected_round_id:
self.app.view.show_details(ItemType.ROUND) self.app.view.show_details(ItemType.ROUND)
self.app.rounds._fill_round_details(self.selected_round_id) self.app.rounds._fill_round_details(self.selected_round_id)
else:
self.app.view.show_details(None)
self.app.update_window_title() self.app.update_window_title()
def refresh_and_select( def refresh_and_select(

View file

@ -40,3 +40,5 @@ class PlayerController:
if not self._validate_player_inputs(name): if not self._validate_player_inputs(name):
return return
self.app.model.update_player(player_id, name=name) self.app.model.update_player(player_id, name=name)
# Propagate update to participants
self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)

View file

@ -105,7 +105,7 @@ class WarController:
self.app.navigation.selected_war_id, name, description self.app.navigation.selected_war_id, name, description
) )
self.app.is_dirty = True self.app.is_dirty = True
self.app.navigation.refresh(RefreshScope.WAR_DETAILS) self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
def edit_objective(self, objective_id: str) -> None: def edit_objective(self, objective_id: str) -> None:
obj = self.app.model.get_objective(objective_id) obj = self.app.model.get_objective(objective_id)
@ -143,7 +143,7 @@ class WarController:
self.app.navigation.selected_war_id, player_id, faction self.app.navigation.selected_war_id, player_id, faction
) )
self.app.is_dirty = True self.app.is_dirty = True
self.app.navigation.refresh(RefreshScope.WAR_DETAILS) self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
def edit_war_participant(self, participant_id: str) -> None: def edit_war_participant(self, participant_id: str) -> None:
war_part = self.app.model.get_war_participant(participant_id) war_part = self.app.model.get_war_participant(participant_id)