QTfrontend/teamselect.cpp
author displacer
Sun, 03 Sep 2006 12:56:13 +0000
changeset 132 2d0f404cdf05
parent 131 482f78c595ec
child 140 50ccde437ea1
permissions -rw-r--r--
first hedgehogs number selection added
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
{
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 131
diff changeset
    14
  frameDontPlaying->addTeam(team, false);
84
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
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 131
diff changeset
    30
  bool willBePlaying=itDontPlay!=curDontPlayingTeams.end();
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 131
diff changeset
    31
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 131
diff changeset
    32
  if(!willBePlaying) {
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    33
    // playing team => dont playing
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    34
    curDontPlayingTeams.push_back(*itPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    35
    curPlayingTeams.erase(itPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    36
  } else {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    37
    // dont playing team => playing
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    38
    curPlayingTeams.push_back(*itDontPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    39
    curDontPlayingTeams.erase(itDontPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    40
  }
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    41
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    42
  FrameTeams* pRemoveTeams;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    43
  FrameTeams* pAddTeams;
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 131
diff changeset
    44
  if(!willBePlaying) {
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    45
    pRemoveTeams=framePlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    46
    pAddTeams=frameDontPlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    47
  } else {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    48
    pRemoveTeams=frameDontPlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    49
    pAddTeams=framePlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    50
  }
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    51
132
2d0f404cdf05 first hedgehogs number selection added
displacer
parents: 131
diff changeset
    52
  pAddTeams->addTeam(team, willBePlaying);
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    53
  pRemoveTeams->removeTeam(team);
117
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    54
  QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
d21a48200772 HWTeam integration in team select widget
displacer
parents: 114
diff changeset
    55
		   this, SLOT(changeTeamStatus(HWTeam)));
131
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    56
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    57
  QSize szh=pAddTeams->sizeHint();
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    58
  QSize szh1=pRemoveTeams->sizeHint();
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    59
  if(szh.isValid() && szh1.isValid()) {
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    60
    pAddTeams->resize(pAddTeams->size().width(), szh.height());
482f78c595ec resize bugfix
displacer
parents: 122
diff changeset
    61
    pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height());
122
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    62
  }
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    63
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    64
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    65
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    66
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    67
  VertScrArea* area=new VertScrArea(color);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    68
  area->setWidget(pfteams);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    69
  mainLayout.addWidget(area, 30);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    70
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    71
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    72
TeamSelWidget::TeamSelWidget(QWidget* parent) :
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    73
  QWidget(parent), mainLayout(this)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    74
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    75
  framePlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    76
  frameDontPlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    77
  addScrArea(framePlaying, QColor("DarkTurquoise"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    78
  addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    79
}