def __update_view_for_current_match(self, o_match): self.__clear_listwidget(self.listWidget_domplayer) self.__clear_listwidget(self.listWidget_extplayer) self.__clear_listwidget(self.listWidget_matchevent) if o_match is not None: o_tdom = dao.getTeam().getById(o_match.idteam_home) o_tvis = dao.getTeam().getById(o_match.idteam_outside) self.textEdit_dom.setText(o_tdom.name) self.textEdit_vis.setText(o_tvis.name) self.textEdit_domscore.setText('0') self.textEdit_extscore.setText('0') playerteamdom = dao.getPlayer().getByTeam(o_tdom) for player in playerteamdom: self.listWidget_domplayer.addItem(player.description) playerteamext = dao.getPlayer().getByTeam(o_tvis) for player in playerteamext: self.listWidget_extplayer.addItem(player.description) # if there are goal listgoal = dao.getGoals().getByMatch(o_match) if listgoal is not None: for goal in listgoal: oteam = dao.getTeam().getById(goal.idequipe) oscorer = dao.getPlayer().getById(goal.idplayer_scorer) oass = dao.getPlayer().getById(goal.idplayer_ass) self.__update_view_after_goals(oteam, oscorer, oass)
def __event_bt_addplayer(self, checked): dialog = AddPlayerWindow(self) result = dialog.exec() if result: team = self.get_current_team() if dialog.get_lname() != "": player = model.getPlayerProvider().get_new( team.id, dialog.get_lname(), dialog.get_fname()) else: player = model.getPlayerProvider().get_randomplayer(team.id) dao.getPlayer().insert(player) self.__refresh_tab1() self.set_current_team(team)
def __event_bt_after_goals(self): match = self.get_current_match() oteamdom = dao.getTeam().getById(match.idteam_home) playersdom = dao.getPlayer().getByTeam(oteamdom) oteamvis = dao.getTeam().getById(match.idteam_outside) playersext = dao.getPlayer().getByTeam(oteamvis) dialog = GoalWindow(self, oteamdom, playersdom, oteamvis, playersext) btpressed = dialog.exec() if btpressed: oteam, oscorer, oass = dialog.get_datas() but = model.getGoalsProvider().get_new( oscorer.id if oscorer is not None else None, match.id, oteam.id, oass.id if oass is not None else None) dao.getGoals().insert(but) self.__update_view_after_goals(oteam, oscorer, oass)
def __after_changed_property_current_team(self, team): self.__clear_listwidget(self.listWidget_playerslist) # get players for the team if team is not None: self.set_players(dao.getPlayer().getByTeam(team)) self.pushButton_addplayer.setEnabled(True) self.pushButton_addplayer.setText("Add Player to {}".format( team.name)) else: self.pushButton_addplayer.setEnabled(False)
o = len(dao.getCompetition().getAll()) if o == 0: chp = model.getCompetitionProvider().get_standard_competition( "ma competition") dao.getCompetition().insert(chp) team1 = model.getTeamProvider().get_new("Liverpool") dao.getTeam().insert(team1, chp) team2 = model.getTeamProvider().get_new("Chelsea") dao.getTeam().insert(team2, chp) team3 = model.getTeamProvider().get_new("Arsenal") dao.getTeam().insert(team3, chp) team4 = model.getTeamProvider().get_new("Manchester") dao.getTeam().insert(team4, chp) pl1 = model.getPlayerProvider().get_randomplayer() pl2 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl1, team1, team1.name) dao.getPlayer().insert(pl2, team1, team1.name) pl3 = model.getPlayerProvider().get_randomplayer() pl4 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl3, team2, team2.name) dao.getPlayer().insert(pl4, team2, team2.name) pl5 = model.getPlayerProvider().get_randomplayer() pl6 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl5, team3, team3.name) dao.getPlayer().insert(pl6, team3, team3.name) pl7 = model.getPlayerProvider().get_randomplayer() pl8 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl7, team4, team4.name) dao.getPlayer().insert(pl8, team4, team4.name) teams = [team1, team2, team3, team4]
def __event_bt_deleteplayer(self, checked): if dao.getPlayer().delete(self.get_current_player()): self.set_current_player(None)