QTfrontend/teamselect.cpp
author unc0rr
Sun, 05 Feb 2006 18:51:54 +0000
changeset 62 c3eda0c68cd6
parent 61 505691a09dee
child 63 27e2b5bb6d4b
permissions -rw-r--r--
No more hedgehogs hung in air
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     1
#include <QLabel>
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     2
#include <QPixmap>
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     3
#include <QPushButton>
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     4
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     5
#include <algorithm>
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     6
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     7
#include "teamselect.h"
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     8
#include "teamselhelper.h"
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
     9
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    10
void TeamSelWidget::addTeam(tmprop team)
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    11
{
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    12
  curDontPlayingTeams.push_back(team);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    13
  TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team);
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    14
  dontPlayingLayout->addWidget(pTeamShowWidget);
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    15
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    16
  teamToWidget.insert(make_pair(team, pTeamShowWidget));
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    17
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    18
  QObject::connect(pTeamShowWidget, SIGNAL(teamStatusChanged(tmprop)), this, SLOT(changeTeamStatus(tmprop)));
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    19
}
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    20
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    21
void TeamSelWidget::removeTeam(tmprop team)
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    22
{
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    23
  curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team));
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    24
}
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    25
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    26
void TeamSelWidget::changeTeamStatus(tmprop team)
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    27
{
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    28
  list<tmprop>::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    29
  list<tmprop>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    30
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    31
  if(itDontPlay==curDontPlayingTeams.end()) {
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    32
    // playing team => dont playing
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    33
    curDontPlayingTeams.push_back(*itPlay);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    34
    curPlayingTeams.erase(itPlay);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    35
  } else {
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    36
    // dont playing team => playing
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    37
    curPlayingTeams.push_back(*itDontPlay);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    38
    curDontPlayingTeams.erase(itDontPlay);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    39
  }
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    40
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    41
  QGridLayout* pRemoveGrid;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    42
  QGridLayout* pAddGrid;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    43
  QWidget* newParent;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    44
  if(itDontPlay==curDontPlayingTeams.end()) {
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    45
    pRemoveGrid=playingLayout;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    46
    pAddGrid=dontPlayingLayout;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    47
    newParent=dontPlayingColorFrame;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    48
  } else {
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    49
    pRemoveGrid=dontPlayingLayout;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    50
    pAddGrid=playingLayout;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    51
    newParent=playingColorFrame;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    52
  }
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    53
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    54
  pRemoveGrid->removeWidget(teamToWidget[team]);
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    55
  teamToWidget[team]->setParent(newParent);
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    56
  pAddGrid->addWidget(teamToWidget[team]);
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    57
}
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    58
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    59
TeamSelWidget::TeamSelWidget(QWidget* parent) :
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    60
  QWidget(parent), mainLayout(this)
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    61
{
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    62
  playingColorFrame = new QFrame;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    63
  QPalette newPalette = palette();
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    64
  newPalette.setColor(QPalette::Background, QColor("DarkTurquoise"));
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    65
  playingColorFrame->setPalette(newPalette);
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    66
  mainLayout.addWidget(playingColorFrame);
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    67
61
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    68
  dontPlayingColorFrame = new QFrame;
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    69
  newPalette.setColor(QPalette::Background, QColor("LightGoldenrodYellow")); //BlanchedAlmond MistyRose honeydew PeachPuff LightCoral
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    70
  dontPlayingColorFrame->setPalette(newPalette);
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    71
  mainLayout.addWidget(dontPlayingColorFrame);
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    72
  
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    73
  playingLayout = new QGridLayout(playingColorFrame);
505691a09dee colors added to teamselwidget
displacer
parents: 50
diff changeset
    74
  dontPlayingLayout = new QGridLayout(dontPlayingColorFrame);
50
9ab4067dabec TeamSelect widget alpha added
displacer
parents:
diff changeset
    75
}