QTfrontend/teamselect.cpp
author unc0rr
Mon, 24 Jul 2006 22:37:34 +0000
changeset 84 0f6669da2fcb
parent 63 27e2b5bb6d4b
child 85 44d9045b26ff
permissions -rw-r--r--
Start rewrite ui
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>
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     5
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     6
#include <algorithm>
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     7
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     8
#include <vertScrollArea.h>
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
     9
#include "teamselect.h"
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    10
#include "teamselhelper.h"
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    11
#include "frameTeam.h"
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    12
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    13
void TeamSelWidget::addTeam(tmprop team)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    14
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    15
  frameDontPlaying->addTeam(team);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    16
  curDontPlayingTeams.push_back(team);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    17
  QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(tmprop)),
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    18
		   this, SLOT(changeTeamStatus(tmprop)));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    19
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    20
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    21
void TeamSelWidget::removeTeam(tmprop team)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    22
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    23
  //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    24
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    25
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    26
void TeamSelWidget::changeTeamStatus(tmprop team)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    27
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    28
  list<tmprop>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    29
  list<tmprop>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    30
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    31
  if(itDontPlay==curDontPlayingTeams.end()) {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    32
    // playing team => dont playing
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    33
    curDontPlayingTeams.push_back(*itPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    34
    curPlayingTeams.erase(itPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    35
  } else {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    36
    // dont playing team => playing
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    37
    curPlayingTeams.push_back(*itDontPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    38
    curDontPlayingTeams.erase(itDontPlay);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    39
  }
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    40
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    41
  FrameTeams* pRemoveTeams;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    42
  FrameTeams* pAddTeams;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    43
  if(itDontPlay==curDontPlayingTeams.end()) {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    44
    pRemoveTeams=framePlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    45
    pAddTeams=frameDontPlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    46
  } else {
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    47
    pRemoveTeams=frameDontPlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    48
    pAddTeams=framePlaying;
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    49
  }
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    50
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    51
  pAddTeams->addTeam(team);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    52
  pRemoveTeams->removeTeam(team);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    53
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    54
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    55
void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    56
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    57
  VertScrArea* area=new VertScrArea(color);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    58
  area->setWidget(pfteams);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    59
  mainLayout.addWidget(area, 30);
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    60
}
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    61
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    62
TeamSelWidget::TeamSelWidget(QWidget* parent) :
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    63
  QWidget(parent), mainLayout(this)
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    64
{
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    65
  framePlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    66
  frameDontPlaying=new FrameTeams();
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    67
  addScrArea(framePlaying, QColor("DarkTurquoise"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    68
  addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow"));
0f6669da2fcb Start rewrite ui
unc0rr
parents: 63
diff changeset
    69
}