1 #include <QLabel> |
1 #include <QLabel> |
2 #include <QPixmap> |
2 #include <QPixmap> |
3 #include <QPushButton> |
3 #include <QPushButton> |
|
4 #include <QFrame> |
4 |
5 |
5 #include <algorithm> |
6 #include <algorithm> |
6 |
7 |
|
8 #include <vertScrollArea.h> |
7 #include "teamselect.h" |
9 #include "teamselect.h" |
8 #include "teamselhelper.h" |
10 #include "teamselhelper.h" |
|
11 #include "frameTeam.h" |
9 |
12 |
10 void TeamSelWidget::addTeam(tmprop team) |
13 void TeamSelWidget::addTeam(tmprop team) |
11 { |
14 { |
|
15 frameDontPlaying->addTeam(team); |
12 curDontPlayingTeams.push_back(team); |
16 curDontPlayingTeams.push_back(team); |
13 TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team); |
17 QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(tmprop)), |
14 dontPlayingLayout->addWidget(pTeamShowWidget); |
18 this, SLOT(changeTeamStatus(tmprop))); |
15 |
|
16 teamToWidget.insert(make_pair(team, pTeamShowWidget)); |
|
17 |
|
18 QObject::connect(pTeamShowWidget, SIGNAL(teamStatusChanged(tmprop)), this, SLOT(changeTeamStatus(tmprop))); |
|
19 } |
19 } |
20 |
20 |
21 void TeamSelWidget::removeTeam(tmprop team) |
21 void TeamSelWidget::removeTeam(tmprop team) |
22 { |
22 { |
23 curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); |
23 //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); |
24 } |
24 } |
25 |
25 |
26 void TeamSelWidget::changeTeamStatus(tmprop team) |
26 void TeamSelWidget::changeTeamStatus(tmprop team) |
27 { |
27 { |
28 list<tmprop>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team); |
28 list<tmprop>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team); |
36 // dont playing team => playing |
36 // dont playing team => playing |
37 curPlayingTeams.push_back(*itDontPlay); |
37 curPlayingTeams.push_back(*itDontPlay); |
38 curDontPlayingTeams.erase(itDontPlay); |
38 curDontPlayingTeams.erase(itDontPlay); |
39 } |
39 } |
40 |
40 |
41 QGridLayout* pRemoveGrid; |
41 FrameTeams* pRemoveTeams; |
42 QGridLayout* pAddGrid; |
42 FrameTeams* pAddTeams; |
43 QWidget* newParent; |
|
44 if(itDontPlay==curDontPlayingTeams.end()) { |
43 if(itDontPlay==curDontPlayingTeams.end()) { |
45 pRemoveGrid=playingLayout; |
44 pRemoveTeams=framePlaying; |
46 pAddGrid=dontPlayingLayout; |
45 pAddTeams=frameDontPlaying; |
47 newParent=dontPlayingColorFrame; |
|
48 } else { |
46 } else { |
49 pRemoveGrid=dontPlayingLayout; |
47 pRemoveTeams=frameDontPlaying; |
50 pAddGrid=playingLayout; |
48 pAddTeams=framePlaying; |
51 newParent=playingColorFrame; |
|
52 } |
49 } |
53 |
50 |
54 pRemoveGrid->removeWidget(teamToWidget[team]); |
51 pAddTeams->addTeam(team); |
55 teamToWidget[team]->setParent(newParent); |
52 pRemoveTeams->removeTeam(team); |
56 pAddGrid->addWidget(teamToWidget[team]); |
53 } |
|
54 |
|
55 void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color) |
|
56 { |
|
57 VertScrArea* area=new VertScrArea(color); |
|
58 area->setWidget(pfteams); |
|
59 mainLayout.addWidget(area, 50); |
57 } |
60 } |
58 |
61 |
59 TeamSelWidget::TeamSelWidget(QWidget* parent) : |
62 TeamSelWidget::TeamSelWidget(QWidget* parent) : |
60 QWidget(parent), mainLayout(this) |
63 QWidget(parent), mainLayout(this) |
61 { |
64 { |
62 playingColorFrame = new QFrame; |
65 framePlaying=new FrameTeams(); |
63 QPalette newPalette = palette(); |
66 frameDontPlaying=new FrameTeams(); |
64 newPalette.setColor(QPalette::Background, QColor("DarkTurquoise")); |
67 addScrArea(framePlaying, QColor("DarkTurquoise")); |
65 playingColorFrame->setPalette(newPalette); |
68 addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow")); |
66 mainLayout.addWidget(playingColorFrame); |
|
67 |
|
68 dontPlayingColorFrame = new QFrame; |
|
69 newPalette.setColor(QPalette::Background, QColor("LightGoldenrodYellow")); //BlanchedAlmond MistyRose honeydew PeachPuff LightCoral |
|
70 dontPlayingColorFrame->setPalette(newPalette); |
|
71 mainLayout.addWidget(dontPlayingColorFrame); |
|
72 |
|
73 playingLayout = new QGridLayout(playingColorFrame); |
|
74 dontPlayingLayout = new QGridLayout(dontPlayingColorFrame); |
|
75 } |
69 } |