QTfrontend/teamselect.cpp
changeset 61 505691a09dee
parent 50 9ab4067dabec
child 63 27e2b5bb6d4b
equal deleted inserted replaced
60:7fbfa2f13f6f 61:505691a09dee
     9 
     9 
    10 void TeamSelWidget::addTeam(tmprop team)
    10 void TeamSelWidget::addTeam(tmprop team)
    11 {
    11 {
    12   curDontPlayingTeams.push_back(team);
    12   curDontPlayingTeams.push_back(team);
    13   TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team);
    13   TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team);
    14   dontPlayingLayout.addWidget(pTeamShowWidget);
    14   dontPlayingLayout->addWidget(pTeamShowWidget);
    15 
    15 
    16   teamToWidget.insert(make_pair(team, pTeamShowWidget));
    16   teamToWidget.insert(make_pair(team, pTeamShowWidget));
    17 
    17 
    18   QObject::connect(pTeamShowWidget, SIGNAL(teamStatusChanged(tmprop)), this, SLOT(changeTeamStatus(tmprop)));
    18   QObject::connect(pTeamShowWidget, SIGNAL(teamStatusChanged(tmprop)), this, SLOT(changeTeamStatus(tmprop)));
    19 }
    19 }
    36     // dont playing team => playing
    36     // dont playing team => playing
    37     curPlayingTeams.push_back(*itDontPlay);
    37     curPlayingTeams.push_back(*itDontPlay);
    38     curDontPlayingTeams.erase(itDontPlay);
    38     curDontPlayingTeams.erase(itDontPlay);
    39   }
    39   }
    40 
    40 
    41   QGridLayout* pRemoveGrid = itDontPlay==curDontPlayingTeams.end() ? &playingLayout : &dontPlayingLayout;
    41   QGridLayout* pRemoveGrid;
    42   QGridLayout* pAddGrid = itDontPlay==curDontPlayingTeams.end() ? &dontPlayingLayout : &playingLayout;
    42   QGridLayout* pAddGrid;
       
    43   QWidget* newParent;
       
    44   if(itDontPlay==curDontPlayingTeams.end()) {
       
    45     pRemoveGrid=playingLayout;
       
    46     pAddGrid=dontPlayingLayout;
       
    47     newParent=dontPlayingColorFrame;
       
    48   } else {
       
    49     pRemoveGrid=dontPlayingLayout;
       
    50     pAddGrid=playingLayout;
       
    51     newParent=playingColorFrame;
       
    52   }
    43 
    53 
    44   pRemoveGrid->removeWidget(teamToWidget[team]);
    54   pRemoveGrid->removeWidget(teamToWidget[team]);
       
    55   teamToWidget[team]->setParent(newParent);
    45   pAddGrid->addWidget(teamToWidget[team]);
    56   pAddGrid->addWidget(teamToWidget[team]);
    46 }
    57 }
    47 
    58 
    48 TeamSelWidget::TeamSelWidget(const vector<QString>& teams, QWidget* parent) :
    59 TeamSelWidget::TeamSelWidget(QWidget* parent) :
    49   QWidget(parent), mainLayout(this)
    60   QWidget(parent), mainLayout(this)
    50 {
    61 {
    51   mainLayout.addLayout(&playingLayout);
    62   playingColorFrame = new QFrame;
    52   mainLayout.addLayout(&dontPlayingLayout);
    63   QPalette newPalette = palette();
       
    64   newPalette.setColor(QPalette::Background, QColor("DarkTurquoise"));
       
    65   playingColorFrame->setPalette(newPalette);
       
    66   mainLayout.addWidget(playingColorFrame);
    53 
    67 
    54   for(vector<QString>::const_iterator it=teams.begin(); it!=teams.end(); ++it) {
    68   dontPlayingColorFrame = new QFrame;
    55     addTeam(*it);
    69   newPalette.setColor(QPalette::Background, QColor("LightGoldenrodYellow")); //BlanchedAlmond MistyRose honeydew PeachPuff LightCoral
    56   }
    70   dontPlayingColorFrame->setPalette(newPalette);
       
    71   mainLayout.addWidget(dontPlayingColorFrame);
       
    72   
       
    73   playingLayout = new QGridLayout(playingColorFrame);
       
    74   dontPlayingLayout = new QGridLayout(dontPlayingColorFrame);
    57 }
    75 }