QTfrontend/teamselect.cpp
author displacer
Fri, 18 Aug 2006 20:37:50 +0000
changeset 117 d21a48200772
parent 114 2762edfc23a9
child 121 6c7111eddea9
permissions -rw-r--r--
HWTeam integration in team select widget
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)));
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    54
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    55
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    56
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    57
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    58
  VertScrArea* area=new VertScrArea(color);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    59
  area->setWidget(pfteams);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    60
  mainLayout.addWidget(area, 30);
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
TeamSelWidget::TeamSelWidget(QWidget* parent) :
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    64
  QWidget(parent), mainLayout(this)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    65
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    66
  framePlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    67
  frameDontPlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    68
  addScrArea(framePlaying, QColor("DarkTurquoise"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    69
  addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    70
}