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);
|
|
14 |
dontPlayingLayout.addWidget(pTeamShowWidget);
|
|
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 |
|
|
41 |
QGridLayout* pRemoveGrid = itDontPlay==curDontPlayingTeams.end() ? &playingLayout : &dontPlayingLayout;
|
|
42 |
QGridLayout* pAddGrid = itDontPlay==curDontPlayingTeams.end() ? &dontPlayingLayout : &playingLayout;
|
|
43 |
|
|
44 |
pRemoveGrid->removeWidget(teamToWidget[team]);
|
|
45 |
pAddGrid->addWidget(teamToWidget[team]);
|
|
46 |
}
|
|
47 |
|
|
48 |
TeamSelWidget::TeamSelWidget(const vector<QString>& teams, QWidget* parent) :
|
|
49 |
QWidget(parent), mainLayout(this)
|
|
50 |
{
|
|
51 |
mainLayout.addLayout(&playingLayout);
|
|
52 |
mainLayout.addLayout(&dontPlayingLayout);
|
|
53 |
|
|
54 |
for(vector<QString>::const_iterator it=teams.begin(); it!=teams.end(); ++it) {
|
|
55 |
addTeam(*it);
|
|
56 |
}
|
|
57 |
}
|