network team add can be denied by server
authordisplacer
Sat, 27 Jan 2007 18:33:14 +0000
changeset 373 df912aab6b7e
parent 372 4bac77f8cd38
child 374 95169697cc38
network team add can be denied by server
QTfrontend/hwform.cpp
QTfrontend/newnetclient.cpp
QTfrontend/pages.cpp
QTfrontend/teamselect.cpp
QTfrontend/teamselect.h
--- a/QTfrontend/hwform.cpp	Sat Jan 27 17:41:08 2007 +0000
+++ b/QTfrontend/hwform.cpp	Sat Jan 27 18:33:14 2007 +0000
@@ -251,6 +251,7 @@
 	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)),
 		hwnet, SLOT(onTeamColorChanged(const HWTeam&)));
 	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam)));
+	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam)));
 	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&)));
 
 	connect(ui.pageNetGame->pGameCFG, SIGNAL(seedChanged(const QString &)), hwnet, SLOT(onSeedChanged(const QString &)));
--- a/QTfrontend/newnetclient.cpp	Sat Jan 27 17:41:08 2007 +0000
+++ b/QTfrontend/newnetclient.cpp	Sat Jan 27 18:33:14 2007 +0000
@@ -208,6 +208,7 @@
 
   if(lst[0]=="TEAM_ACCEPTED") {
     m_networkToLocalteams.insert(lst[2].toUInt(), lst[1]);
+    m_pTeamSelWidget->changeTeamStatus(lst[1]);
     return;
   }
 
--- a/QTfrontend/pages.cpp	Sat Jan 27 17:41:08 2007 +0000
+++ b/QTfrontend/pages.cpp	Sat Jan 27 18:33:14 2007 +0000
@@ -470,6 +470,7 @@
 	pageLayout->addWidget(pGameCFG, 0, 0);
 
 	pNetTeamsWidget = new TeamSelWidget(this);
+	pNetTeamsWidget->setAcceptOuter(true);
 	pageLayout->addWidget(pNetTeamsWidget, 0, 1);
 
 	BtnBack = new QPushButton(this);
--- a/QTfrontend/teamselect.cpp	Sat Jan 27 17:41:08 2007 +0000
+++ b/QTfrontend/teamselect.cpp	Sat Jan 27 18:33:14 2007 +0000
@@ -40,8 +40,13 @@
   } else {
     frameDontPlaying->addTeam(team, false);
     curDontPlayingTeams.push_back(team);
-    QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
-		     this, SLOT(changeTeamStatus(HWTeam)));
+    if(m_acceptOuter) {
+      connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
+	      this, SLOT(pre_changeTeamStatus(HWTeam)));
+    } else {
+      connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)),
+	      this, SLOT(changeTeamStatus(HWTeam)));
+    }
   }
 }
 
@@ -124,7 +129,7 @@
     if(framePlaying->isFullTeams()) return;
     // dont playing team => playing
     curPlayingTeams.push_back(*itDontPlay);
-    emit teamWillPlay(*itDontPlay);
+    if(!m_acceptOuter) emit teamWillPlay(*itDontPlay);
     curDontPlayingTeams.erase(itDontPlay);
   }
 
@@ -168,7 +173,7 @@
 }
 
 TeamSelWidget::TeamSelWidget(QWidget* parent) :
-  QGroupBox(parent), mainLayout(this)
+  QGroupBox(parent), mainLayout(this), m_acceptOuter(false)
 {
   setTitle(QGroupBox::tr("Playing teams"));
   framePlaying=new FrameTeams();
@@ -184,6 +189,11 @@
   mainLayout.addWidget(newTeam);
 }
 
+void TeamSelWidget::setAcceptOuter(bool acceptOuter)
+{
+  m_acceptOuter=acceptOuter;
+}
+
 void TeamSelWidget::resetPlayingTeams(const QList<HWTeam>& teamslist)
 {
   QList<HWTeam>::iterator it;
@@ -212,6 +222,11 @@
   return curPlayingTeams;
 }
 
+void TeamSelWidget::pre_changeTeamStatus(HWTeam team)
+{
+  emit acceptRequested(team);
+}
+
 void TeamSelWidget::newTeamClicked()
 {
 	emit NewTeam();
--- a/QTfrontend/teamselect.h	Sat Jan 27 17:41:08 2007 +0000
+++ b/QTfrontend/teamselect.h	Sat Jan 27 18:33:14 2007 +0000
@@ -39,7 +39,8 @@
   Q_OBJECT
 
  public:
-  TeamSelWidget(QWidget* parent=0);
+  TeamSelWidget(QWidget* parent);
+  void setAcceptOuter(bool acceptOuter);
   void removeNetTeam(const HWTeam& team);
   void resetPlayingTeams(const QList<HWTeam>& teamslist);
   bool isPlaying(HWTeam team) const;
@@ -51,6 +52,7 @@
   void netTeamStatusChanged(const HWTeam& team);
   void changeHHNum(const HWTeam&);
   void changeTeamColor(const HWTeam&);
+  void changeTeamStatus(HWTeam team);
   
  signals:
   void NewTeam();
@@ -58,9 +60,10 @@
   void teamNotPlaying(const HWTeam& team);
   void hhogsNumChanged(const HWTeam&);
   void teamColorChanged(const HWTeam&);
+  void acceptRequested(HWTeam team);
   
  private slots:
-  void changeTeamStatus(HWTeam team);
+  void pre_changeTeamStatus(HWTeam);
   void newTeamClicked();
   void hhNumChanged(const HWTeam& team);
   void proxyTeamColorChanged(const HWTeam& team);
@@ -71,6 +74,7 @@
   FrameTeams* framePlaying;
 
   QVBoxLayout mainLayout;
+  bool m_acceptOuter;
   QPushButton * newTeam;
 
   QList<HWTeam> curPlayingTeams;