QTfrontend/teamselect.cpp
changeset 884 99cc72c8a812
parent 572 302ad5c3836d
child 1066 1f1b3686a2b0
equal deleted inserted replaced
883:07a568ba44e0 884:99cc72c8a812
    20 
    20 
    21 #include <QLabel>
    21 #include <QLabel>
    22 #include <QPixmap>
    22 #include <QPixmap>
    23 #include <QPushButton>
    23 #include <QPushButton>
    24 #include <QFrame>
    24 #include <QFrame>
       
    25 #include <QDebug>
    25 
    26 
    26 #include <vertScrollArea.h>
    27 #include <vertScrollArea.h>
    27 #include "teamselect.h"
    28 #include "teamselect.h"
    28 #include "teamselhelper.h"
    29 #include "teamselhelper.h"
    29 #include "frameTeam.h"
    30 #include "frameTeam.h"
    59   framePlaying->setNonInteractive();
    60   framePlaying->setNonInteractive();
    60 }
    61 }
    61 
    62 
    62 void TeamSelWidget::hhNumChanged(const HWTeam& team)
    63 void TeamSelWidget::hhNumChanged(const HWTeam& team)
    63 {
    64 {
       
    65 	QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
       
    66 	if(itPlay==curPlayingTeams.end())
       
    67 	{
       
    68 		qWarning() << QString("hhNumChanged: team '%1' not found").arg(team.TeamName);
       
    69 		return;
       
    70 	}
       
    71 	itPlay->numHedgehogs=team.numHedgehogs;
       
    72 	emit hhogsNumChanged(team);
       
    73 }
       
    74 
       
    75 void TeamSelWidget::proxyTeamColorChanged(const HWTeam& team)
       
    76 {
       
    77 	QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
       
    78 	if(itPlay==curPlayingTeams.end())
       
    79 	{
       
    80 		qWarning() << QString("proxyTeamColorChanged: team '%1' not found").arg(team.TeamName);
       
    81 		return;
       
    82 	}
       
    83 	itPlay->teamColor=team.teamColor;
       
    84 	emit teamColorChanged(team);
       
    85 }
       
    86 
       
    87 void TeamSelWidget::changeHHNum(const HWTeam& team)
       
    88 {
    64   QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
    89   QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
       
    90 	if(itPlay==curPlayingTeams.end())
       
    91 	{
       
    92 		qWarning() << QString("changeHHNum: team '%1' not found").arg(team.TeamName);
       
    93 		return;
       
    94 	}
    65   itPlay->numHedgehogs=team.numHedgehogs;
    95   itPlay->numHedgehogs=team.numHedgehogs;
    66   emit hhogsNumChanged(team);
       
    67 }
       
    68 
       
    69 void TeamSelWidget::proxyTeamColorChanged(const HWTeam& team)
       
    70 {
       
    71   QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
       
    72   itPlay->teamColor=team.teamColor;
       
    73   emit teamColorChanged(team);
       
    74 }
       
    75 
       
    76 void TeamSelWidget::changeHHNum(const HWTeam& team)
       
    77 {
       
    78   QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
       
    79   if(itPlay==curPlayingTeams.end()) return;
       
    80   itPlay->numHedgehogs=team.numHedgehogs;
       
    81 
    96 
    82   framePlaying->setHHNum(team);
    97   framePlaying->setHHNum(team);
    83 }
    98 }
    84 
    99 
    85 void TeamSelWidget::changeTeamColor(const HWTeam& team)
   100 void TeamSelWidget::changeTeamColor(const HWTeam& team)
    86 {
   101 {
    87   QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
   102 	QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
    88   if(itPlay==curPlayingTeams.end()) return;
   103 	if(itPlay==curPlayingTeams.end())
    89   itPlay->teamColor=team.teamColor;
   104 	{
    90 
   105 		qWarning() << QString("changeTeamColor: team '%1' not found").arg(team.TeamName);
    91   framePlaying->setTeamColor(team);
   106 		return;
       
   107 	}
       
   108 	itPlay->teamColor=team.teamColor;
       
   109 
       
   110 	framePlaying->setTeamColor(team);
    92 }
   111 }
    93 
   112 
    94 void TeamSelWidget::removeNetTeam(const HWTeam& team)
   113 void TeamSelWidget::removeNetTeam(const HWTeam& team)
    95 {
   114 {
    96   for(;;) {
   115 	qDebug() << QString("removeNetTeam: removing team '%1'").arg(team.TeamName);
    97     QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
   116 	for(;;) {
    98     if(itPlay==curPlayingTeams.end()) break;
   117 		QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
    99     if(itPlay->isNetTeam()) {
   118 		if(itPlay==curPlayingTeams.end())
   100       QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam)));
   119 		{
   101       framePlaying->removeTeam(team);
   120 			qWarning() << QString("removeNetTeam: team '%1' not found").arg(team.TeamName);
   102       curPlayingTeams.erase(itPlay);
   121 			break;
   103       break;
   122 		}
   104     }
   123 		if(itPlay->isNetTeam()) {
   105   }
   124 			QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam)));
   106   emit setEnabledGameStart(curPlayingTeams.size()>1);
   125 			framePlaying->removeTeam(team);
       
   126 			curPlayingTeams.erase(itPlay);
       
   127 			break;
       
   128 		}
       
   129 	}
       
   130 	emit setEnabledGameStart(curPlayingTeams.size()>1);
   107 }
   131 }
   108 
   132 
   109 void TeamSelWidget::netTeamStatusChanged(const HWTeam& team)
   133 void TeamSelWidget::netTeamStatusChanged(const HWTeam& team)
   110 {
   134 {
   111   QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
   135   QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);