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 |
{
|
|
14 |
frameDontPlaying->addTeam(team);
|
|
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 |
|
|
30 |
if(itDontPlay==curDontPlayingTeams.end()) {
|
|
31 |
// playing team => dont playing
|
|
32 |
curDontPlayingTeams.push_back(*itPlay);
|
|
33 |
curPlayingTeams.erase(itPlay);
|
|
34 |
} else {
|
|
35 |
// dont playing team => playing
|
|
36 |
curPlayingTeams.push_back(*itDontPlay);
|
|
37 |
curDontPlayingTeams.erase(itDontPlay);
|
|
38 |
}
|
|
39 |
|
|
40 |
FrameTeams* pRemoveTeams;
|
|
41 |
FrameTeams* pAddTeams;
|
|
42 |
if(itDontPlay==curDontPlayingTeams.end()) {
|
|
43 |
pRemoveTeams=framePlaying;
|
|
44 |
pAddTeams=frameDontPlaying;
|
|
45 |
} else {
|
|
46 |
pRemoveTeams=frameDontPlaying;
|
|
47 |
pAddTeams=framePlaying;
|
|
48 |
}
|
|
49 |
|
|
50 |
pAddTeams->addTeam(team);
|
|
51 |
pRemoveTeams->removeTeam(team);
|
117
|
52 |
QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
|
|
53 |
this, SLOT(changeTeamStatus(HWTeam)));
|
122
|
54 |
QSize szh=sizeHint();
|
|
55 |
if(szh.isValid()) resize(szh);
|
|
56 |
else {
|
|
57 |
szh=pAddTeams->sizeHint();
|
|
58 |
QSize szh1=pRemoveTeams->sizeHint();
|
|
59 |
if(szh.isValid() && szh1.isValid()) {
|
|
60 |
pAddTeams->resize(szh);
|
|
61 |
pRemoveTeams->resize(szh1);
|
|
62 |
}
|
|
63 |
}
|
84
|
64 |
}
|
|
65 |
|
|
66 |
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color)
|
|
67 |
{
|
|
68 |
VertScrArea* area=new VertScrArea(color);
|
|
69 |
area->setWidget(pfteams);
|
|
70 |
mainLayout.addWidget(area, 30);
|
|
71 |
}
|
|
72 |
|
|
73 |
TeamSelWidget::TeamSelWidget(QWidget* parent) :
|
|
74 |
QWidget(parent), mainLayout(this)
|
|
75 |
{
|
|
76 |
framePlaying=new FrameTeams();
|
|
77 |
frameDontPlaying=new FrameTeams();
|
|
78 |
addScrArea(framePlaying, QColor("DarkTurquoise"));
|
|
79 |
addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
|
|
80 |
}
|