QTfrontend/teamselect.cpp
author unc0rr
Sun, 27 Aug 2006 13:21:11 +0000
changeset 128 223522298250
parent 122 4911cf9c1924
child 131 482f78c595ec
permissions -rw-r--r--
Update file headers & delete unneeded files
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)));
122
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    54
  QSize szh=sizeHint();
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    55
  if(szh.isValid()) resize(szh);
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    56
  else {
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    57
    szh=pAddTeams->sizeHint();
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    58
    QSize szh1=pRemoveTeams->sizeHint();
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    59
    if(szh.isValid() && szh1.isValid()) {
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    60
      pAddTeams->resize(szh);
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    61
      pRemoveTeams->resize(szh1);
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    62
    }
4911cf9c1924 resize bugfix
displacer
parents: 121
diff changeset
    63
  }
84
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    64
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    65
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    66
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    67
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    68
  VertScrArea* area=new VertScrArea(color);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    69
  area->setWidget(pfteams);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    70
  mainLayout.addWidget(area, 30);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    71
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    72
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    73
TeamSelWidget::TeamSelWidget(QWidget* parent) :
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    74
  QWidget(parent), mainLayout(this)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    75
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    76
  framePlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    77
  frameDontPlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    78
  addScrArea(framePlaying, QColor("DarkTurquoise"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    79
  addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    80
}