display war,campaign,round menu

This commit is contained in:
Maxime Réaux 2026-01-27 11:49:37 +01:00
parent c64bb2e90b
commit e33dec40be
7 changed files with 277 additions and 1556 deletions

View file

@ -5,6 +5,7 @@ from PyQt6.QtWidgets import QMessageBox, QDialog
from warchron.model.model import Model
from warchron.view.view import View
from warchron.constants import ItemType
from warchron.view.view import PlayerDialog, WarDialog, CampaignDialog
class Controller:
@ -121,7 +122,7 @@ class Controller:
def refresh_wars_view(self):
wars = self.model.get_all_wars()
self.view.display_wars(wars)
self.view.display_wars_tree(wars)
def refresh_views(self):
current = self.view.get_current_tab()
@ -130,17 +131,42 @@ class Controller:
elif current == "wars":
self.refresh_wars_view()
def _fill_war_details(self, war_id: str):
war = self.model.get_war(war_id)
self.view.warName.setText(war.name)
self.view.warYear.setText(str(war.year))
def _fill_campaign_details(self, campaign_id: str):
camp = self.model.get_campaign(campaign_id)
self.view.show_campaign_details(name=camp.name, month=camp.month)
def _fill_round_details(self, round_id: str):
index = self.model.get_round_index(round_id)
self.view.show_round_details(index=index)
def on_tree_selection_changed(self, selection):
self.selected_war_id = None
self.selected_campaign_id = None
self.selected_round_id = None
if selection:
if selection["type"] == "war":
self.selected_war_id = selection["id"]
elif selection["type"] == "campaign":
self.selected_campaign_id = selection["id"]
elif selection["type"] == "round":
self.selected_round_id = selection["id"]
item_type = selection["type"]
item_id = selection["id"]
if item_type == ItemType.WAR:
self.selected_war_id = item_id
self.view.show_details(ItemType.WAR)
self._fill_war_details(item_id)
elif item_type == ItemType.CAMPAIGN:
self.selected_campaign_id = item_id
self.view.show_details(ItemType.CAMPAIGN)
self._fill_campaign_details(item_id)
elif item_type == ItemType.ROUND:
self.selected_round_id = item_id
self.view.show_details(ItemType.ROUND)
self._fill_round_details(item_id)
else:
self.view.show_details(None)
self.update_actions_state()
return
self.update_actions_state()
def update_actions_state(self):