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