80
|
1 |
#include "frameTeam.h"
|
|
2 |
#include "teamselhelper.h"
|
|
3 |
|
|
4 |
#include <QResizeEvent>
|
|
5 |
#include <QCoreApplication>
|
|
6 |
|
|
7 |
using namespace std;
|
|
8 |
|
|
9 |
FrameTeams::FrameTeams(QWidget* parent) :
|
|
10 |
QWidget(parent), mainLayout(this)
|
|
11 |
{
|
134
|
12 |
mainLayout.setSpacing(1);
|
80
|
13 |
}
|
|
14 |
|
132
|
15 |
void FrameTeams::addTeam(HWTeam team, bool willPlay)
|
80
|
16 |
{
|
132
|
17 |
TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, willPlay, this);
|
87
|
18 |
// int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
|
80
|
19 |
teamToWidget.insert(make_pair(team, pTeamShowWidget));
|
|
20 |
mainLayout.addWidget(pTeamShowWidget);
|
|
21 |
QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size());
|
|
22 |
QCoreApplication::postEvent(parentWidget(), pevent);
|
|
23 |
}
|
|
24 |
|
117
|
25 |
void FrameTeams::removeTeam(HWTeam team)
|
80
|
26 |
{
|
|
27 |
tmapTeamToWidget::iterator it=teamToWidget.find(team);
|
|
28 |
mainLayout.removeWidget(it->second);
|
|
29 |
delete it->second;
|
|
30 |
teamToWidget.erase(team);
|
|
31 |
}
|
|
32 |
|
117
|
33 |
QWidget* FrameTeams::getTeamWidget(HWTeam team)
|
80
|
34 |
{
|
|
35 |
tmapTeamToWidget::iterator it=teamToWidget.find(team);
|
|
36 |
QWidget* ret = it!=teamToWidget.end() ? it->second : 0;
|
|
37 |
if(!ret) throw; // FIXME: this is debug exception
|
|
38 |
return ret;
|
|
39 |
}
|