author | displacer |
Sat, 09 Sep 2006 16:59:10 +0000 | |
changeset 140 | 50ccde437ea1 |
parent 132 | 2d0f404cdf05 |
child 147 | 52a3c431db8a |
permissions | -rw-r--r-- |
84 | 1 |
#include <QLabel> |
2 |
#include <QPixmap> |
|
3 |
#include <QPushButton> |
|
4 |
#include <QFrame> |
|
114 | 5 |
#include <QDebug> |
84 | 6 |
|
7 |
#include <vertScrollArea.h> |
|
8 |
#include "teamselect.h" |
|
9 |
#include "teamselhelper.h" |
|
10 |
#include "frameTeam.h" |
|
11 |
||
117 | 12 |
void TeamSelWidget::addTeam(HWTeam team) |
84 | 13 |
{ |
132 | 14 |
frameDontPlaying->addTeam(team, false); |
84 | 15 |
curDontPlayingTeams.push_back(team); |
117 | 16 |
QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
17 |
this, SLOT(changeTeamStatus(HWTeam))); |
|
84 | 18 |
} |
19 |
||
117 | 20 |
//void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) |
21 |
//{ |
|
84 | 22 |
//curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); |
117 | 23 |
//} |
84 | 24 |
|
117 | 25 |
void TeamSelWidget::changeTeamStatus(HWTeam team) |
84 | 26 |
{ |
117 | 27 |
list<HWTeam>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team); |
28 |
list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); |
|
84 | 29 |
|
132 | 30 |
bool willBePlaying=itDontPlay!=curDontPlayingTeams.end(); |
31 |
||
32 |
if(!willBePlaying) { |
|
84 | 33 |
// playing team => dont playing |
34 |
curDontPlayingTeams.push_back(*itPlay); |
|
35 |
curPlayingTeams.erase(itPlay); |
|
36 |
} else { |
|
37 |
// dont playing team => playing |
|
38 |
curPlayingTeams.push_back(*itDontPlay); |
|
39 |
curDontPlayingTeams.erase(itDontPlay); |
|
40 |
} |
|
41 |
||
42 |
FrameTeams* pRemoveTeams; |
|
43 |
FrameTeams* pAddTeams; |
|
132 | 44 |
if(!willBePlaying) { |
84 | 45 |
pRemoveTeams=framePlaying; |
46 |
pAddTeams=frameDontPlaying; |
|
47 |
} else { |
|
48 |
pRemoveTeams=frameDontPlaying; |
|
49 |
pAddTeams=framePlaying; |
|
50 |
} |
|
51 |
||
132 | 52 |
pAddTeams->addTeam(team, willBePlaying); |
84 | 53 |
pRemoveTeams->removeTeam(team); |
117 | 54 |
QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), |
55 |
this, SLOT(changeTeamStatus(HWTeam))); |
|
131 | 56 |
|
57 |
QSize szh=pAddTeams->sizeHint(); |
|
58 |
QSize szh1=pRemoveTeams->sizeHint(); |
|
59 |
if(szh.isValid() && szh1.isValid()) { |
|
60 |
pAddTeams->resize(pAddTeams->size().width(), szh.height()); |
|
61 |
pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); |
|
122 | 62 |
} |
84 | 63 |
} |
64 |
||
65 |
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color) |
|
66 |
{ |
|
67 |
VertScrArea* area=new VertScrArea(color); |
|
68 |
area->setWidget(pfteams); |
|
69 |
mainLayout.addWidget(area, 30); |
|
70 |
} |
|
71 |
||
72 |
TeamSelWidget::TeamSelWidget(QWidget* parent) : |
|
73 |
QWidget(parent), mainLayout(this) |
|
74 |
{ |
|
75 |
framePlaying=new FrameTeams(); |
|
76 |
frameDontPlaying=new FrameTeams(); |
|
77 |
addScrArea(framePlaying, QColor("DarkTurquoise")); |
|
78 |
addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow")); |
|
79 |
} |
|
140
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
80 |
|
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
81 |
void TeamSelWidget::resetPlayingTeams() |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
82 |
{ |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
83 |
} |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
84 |
|
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
85 |
bool TeamSelWidget::isPlaying(HWTeam team) |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
86 |
{ |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
87 |
return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
88 |
} |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
89 |
|
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
90 |
unsigned char TeamSelWidget::numHedgedogs(HWTeam team) |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
91 |
{ |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
92 |
TeamShowWidget* tsw=dynamic_cast<TeamShowWidget*>(framePlaying->getTeamWidget(team)); |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
93 |
if(!tsw) return 0; |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
94 |
return tsw->getHedgehogsNum(); |
50ccde437ea1
teams and hedgedogs num selection added to HWgame
displacer
parents:
132
diff
changeset
|
95 |
} |