26 #include "teamselhelper.h" |
26 #include "teamselhelper.h" |
27 #include "frameTeam.h" |
27 #include "frameTeam.h" |
28 |
28 |
29 void TeamSelWidget::addTeam(HWTeam team) |
29 void TeamSelWidget::addTeam(HWTeam team) |
30 { |
30 { |
31 if(team.netTeam) { |
31 if(team.isNetTeam()) { |
32 framePlaying->addTeam(team, true); |
32 framePlaying->addTeam(team, true); |
33 curPlayingTeams.push_back(team); |
33 curPlayingTeams.push_back(team); |
34 QObject::connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
34 connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
35 this, SLOT(netTeamStatusChanged(const HWTeam&))); |
35 this, SLOT(netTeamStatusChanged(const HWTeam&))); |
36 } else { |
36 } else { |
37 frameDontPlaying->addTeam(team, false); |
37 frameDontPlaying->addTeam(team, false); |
38 curDontPlayingTeams.push_back(team); |
38 curDontPlayingTeams.push_back(team); |
39 QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
39 QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
40 this, SLOT(changeTeamStatus(HWTeam))); |
40 this, SLOT(changeTeamStatus(HWTeam))); |
41 } |
41 } |
42 } |
42 } |
43 |
43 |
|
44 void TeamSelWidget::hhNumChanged(const HWTeam& team) |
|
45 { |
|
46 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
|
47 itPlay->numHedgehogs=team.numHedgehogs; |
|
48 emit hhogsNumChanged(team); |
|
49 } |
|
50 |
|
51 void TeamSelWidget::changeHHNum(const HWTeam& team) |
|
52 { |
|
53 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
|
54 itPlay->numHedgehogs=team.numHedgehogs; |
|
55 |
|
56 framePlaying->setHHNum(team); |
|
57 } |
|
58 |
44 void TeamSelWidget::removeNetTeam(const HWTeam& team) |
59 void TeamSelWidget::removeNetTeam(const HWTeam& team) |
45 { |
60 { |
46 for(;;) { |
61 for(;;) { |
47 list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
62 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
48 if(itPlay==curPlayingTeams.end()) break; |
63 if(itPlay==curPlayingTeams.end()) break; |
49 if(itPlay->netTeam) { |
64 if(itPlay->isNetTeam()) { |
50 QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam))); |
65 QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam))); |
51 framePlaying->removeTeam(team); |
66 framePlaying->removeTeam(team); |
52 curPlayingTeams.erase(itPlay); |
67 curPlayingTeams.erase(itPlay); |
53 break; |
68 break; |
54 } |
69 } |
55 } |
70 } |
56 } |
71 } |
57 |
72 |
58 void TeamSelWidget::netTeamStatusChanged(const HWTeam& team) |
73 void TeamSelWidget::netTeamStatusChanged(const HWTeam& team) |
59 { |
74 { |
60 list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
75 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
61 |
76 |
62 } |
77 } |
63 |
78 |
64 //void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) |
79 //void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) |
65 //{ |
80 //{ |
66 //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); |
81 //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); |
67 //} |
82 //} |
68 |
83 |
69 void TeamSelWidget::changeTeamStatus(HWTeam team) |
84 void TeamSelWidget::changeTeamStatus(HWTeam team) |
70 { |
85 { |
71 list<HWTeam>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team); |
86 QList<HWTeam>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team); |
72 list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
87 QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
73 |
88 |
74 bool willBePlaying=itDontPlay!=curDontPlayingTeams.end(); |
89 bool willBePlaying=itDontPlay!=curDontPlayingTeams.end(); |
75 |
90 |
76 if(!willBePlaying) { |
91 if(!willBePlaying) { |
77 // playing team => dont playing |
92 // playing team => dont playing |
99 |
114 |
100 pAddTeams->addTeam(team, willBePlaying); |
115 pAddTeams->addTeam(team, willBePlaying); |
101 pRemoveTeams->removeTeam(team); |
116 pRemoveTeams->removeTeam(team); |
102 QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
117 QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
103 this, SLOT(changeTeamStatus(HWTeam))); |
118 this, SLOT(changeTeamStatus(HWTeam))); |
|
119 if(willBePlaying) connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), |
|
120 this, SLOT(hhNumChanged(const HWTeam&))); |
104 |
121 |
105 QSize szh=pAddTeams->sizeHint(); |
122 QSize szh=pAddTeams->sizeHint(); |
106 QSize szh1=pRemoveTeams->sizeHint(); |
123 QSize szh1=pRemoveTeams->sizeHint(); |
107 if(szh.isValid() && szh1.isValid()) { |
124 if(szh.isValid() && szh1.isValid()) { |
108 pAddTeams->resize(pAddTeams->size().width(), szh.height()); |
125 pAddTeams->resize(pAddTeams->size().width(), szh.height()); |