50
|
1 |
#include <QLabel>
|
|
2 |
#include <QPixmap>
|
|
3 |
#include <QPushButton>
|
|
4 |
|
|
5 |
#include <algorithm>
|
|
6 |
|
|
7 |
#include "teamselect.h"
|
|
8 |
#include "teamselhelper.h"
|
|
9 |
|
|
10 |
void TeamSelWidget::addTeam(tmprop team)
|
|
11 |
{
|
|
12 |
curDontPlayingTeams.push_back(team);
|
|
13 |
TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team);
|
61
|
14 |
dontPlayingLayout->addWidget(pTeamShowWidget);
|
50
|
15 |
|
|
16 |
teamToWidget.insert(make_pair(team, pTeamShowWidget));
|
|
17 |
|
|
18 |
QObject::connect(pTeamShowWidget, SIGNAL(teamStatusChanged(tmprop)), this, SLOT(changeTeamStatus(tmprop)));
|
|
19 |
}
|
|
20 |
|
|
21 |
void TeamSelWidget::removeTeam(tmprop team)
|
|
22 |
{
|
|
23 |
curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team));
|
|
24 |
}
|
|
25 |
|
|
26 |
void TeamSelWidget::changeTeamStatus(tmprop team)
|
|
27 |
{
|
|
28 |
list<tmprop>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team);
|
|
29 |
list<tmprop>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
|
|
30 |
|
|
31 |
if(itDontPlay==curDontPlayingTeams.end()) {
|
|
32 |
// playing team => dont playing
|
|
33 |
curDontPlayingTeams.push_back(*itPlay);
|
|
34 |
curPlayingTeams.erase(itPlay);
|
|
35 |
} else {
|
|
36 |
// dont playing team => playing
|
|
37 |
curPlayingTeams.push_back(*itDontPlay);
|
|
38 |
curDontPlayingTeams.erase(itDontPlay);
|
|
39 |
}
|
|
40 |
|
61
|
41 |
QGridLayout* pRemoveGrid;
|
|
42 |
QGridLayout* pAddGrid;
|
|
43 |
QWidget* newParent;
|
|
44 |
if(itDontPlay==curDontPlayingTeams.end()) {
|
|
45 |
pRemoveGrid=playingLayout;
|
|
46 |
pAddGrid=dontPlayingLayout;
|
|
47 |
newParent=dontPlayingColorFrame;
|
|
48 |
} else {
|
|
49 |
pRemoveGrid=dontPlayingLayout;
|
|
50 |
pAddGrid=playingLayout;
|
|
51 |
newParent=playingColorFrame;
|
|
52 |
}
|
50
|
53 |
|
|
54 |
pRemoveGrid->removeWidget(teamToWidget[team]);
|
61
|
55 |
teamToWidget[team]->setParent(newParent);
|
50
|
56 |
pAddGrid->addWidget(teamToWidget[team]);
|
|
57 |
}
|
|
58 |
|
61
|
59 |
TeamSelWidget::TeamSelWidget(QWidget* parent) :
|
50
|
60 |
QWidget(parent), mainLayout(this)
|
|
61 |
{
|
61
|
62 |
playingColorFrame = new QFrame;
|
|
63 |
QPalette newPalette = palette();
|
|
64 |
newPalette.setColor(QPalette::Background, QColor("DarkTurquoise"));
|
|
65 |
playingColorFrame->setPalette(newPalette);
|
|
66 |
mainLayout.addWidget(playingColorFrame);
|
50
|
67 |
|
61
|
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);
|
50
|
75 |
}
|