QTfrontend/teamselect.cpp
author displacer
Mon, 28 Aug 2006 19:02:57 +0000
changeset 131 482f78c595ec
parent 122 4911cf9c1924
child 132 2d0f404cdf05
permissions -rw-r--r--
resize bugfix
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     1
#include <QLabel>
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     2
#include <QPixmap>
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     3
#include <QPushButton>
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     4
#include <QFrame>
114
2762edfc23a9 add remove command slot fixed
displacer
parents: 85
diff changeset
     5
#include <QDebug>
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     6
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     7
#include <vertScrollArea.h>
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     8
#include "teamselect.h"
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     9
#include "teamselhelper.h"
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    10
#include "frameTeam.h"
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    11
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    12
void TeamSelWidget::addTeam(HWTeam team)
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    13
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    14
  frameDontPlaying->addTeam(team);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    15
  curDontPlayingTeams.push_back(team);
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    16
  QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    17
		   this, SLOT(changeTeamStatus(HWTeam)));
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    18
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    19
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    20
//void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team)
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    21
//{
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    22
  //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team));
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    23
//}
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    24
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    25
void TeamSelWidget::changeTeamStatus(HWTeam team)
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    26
{
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    27
  list<HWTeam>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team);
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    28
  list<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    29
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    30
  if(itDontPlay==curDontPlayingTeams.end()) {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    31
    // playing team => dont playing
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    32
    curDontPlayingTeams.push_back(*itPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    33
    curPlayingTeams.erase(itPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    34
  } else {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    35
    // dont playing team => playing
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    36
    curPlayingTeams.push_back(*itDontPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    37
    curDontPlayingTeams.erase(itDontPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    38
  }
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    39
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    40
  FrameTeams* pRemoveTeams;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    41
  FrameTeams* pAddTeams;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    42
  if(itDontPlay==curDontPlayingTeams.end()) {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    43
    pRemoveTeams=framePlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    44
    pAddTeams=frameDontPlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    45
  } else {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    46
    pRemoveTeams=frameDontPlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    47
    pAddTeams=framePlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    48
  }
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    49
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    50
  pAddTeams->addTeam(team);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    51
  pRemoveTeams->removeTeam(team);
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    52
  QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    53
		   this, SLOT(changeTeamStatus(HWTeam)));
131
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    54
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    55
  QSize szh=pAddTeams->sizeHint();
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    56
  QSize szh1=pRemoveTeams->sizeHint();
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    57
  if(szh.isValid() && szh1.isValid()) {
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    58
    pAddTeams->resize(pAddTeams->size().width(), szh.height());
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    59
    pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height());
122
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    60
  }
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    61
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    62
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    63
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    64
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    65
  VertScrArea* area=new VertScrArea(color);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    66
  area->setWidget(pfteams);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    67
  mainLayout.addWidget(area, 30);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    68
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    69
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    70
TeamSelWidget::TeamSelWidget(QWidget* parent) :
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    71
  QWidget(parent), mainLayout(this)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    72
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    73
  framePlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    74
  frameDontPlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    75
  addScrArea(framePlaying, QColor("DarkTurquoise"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    76
  addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    77
}