Replace iterators with simple declarative foreach (not tested if it works)
authorunc0rr
Sun, 04 Sep 2011 21:39:50 +0400
changeset 5772 c09c50efe8b5
parent 5771 e3a047e84e19
child 5773 c277657854a2
Replace iterators with simple declarative foreach (not tested if it works)
QTfrontend/chatwidget.cpp
QTfrontend/databrowser.cpp
QTfrontend/game.cpp
QTfrontend/hwform.cpp
QTfrontend/teamselect.cpp
--- a/QTfrontend/chatwidget.cpp	Sun Sep 04 13:36:59 2011 -0400
+++ b/QTfrontend/chatwidget.cpp	Sun Sep 04 21:39:50 2011 +0400
@@ -400,9 +400,8 @@
 
 void HWChatWidget::nickRemoved(const QString& nick)
 {
-    QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
-    QListIterator<QListWidgetItem *> it(items);
-    while(it.hasNext()) chatNicks->takeItem(chatNicks->row(it.next()));
+    foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly))
+        chatNicks->takeItem(chatNicks->row(item));
 
     emit nickCountUpdate(chatNicks->count());
 }
--- a/QTfrontend/databrowser.cpp	Sun Sep 04 13:36:59 2011 -0400
+++ b/QTfrontend/databrowser.cpp	Sun Sep 04 21:39:50 2011 +0400
@@ -26,6 +26,7 @@
         else
             if(!requestedResources.contains(name))
             {
+                qDebug() << "Requesting resource" << name.toString();
                 requestedResources.insert(name);
 
                 QNetworkRequest newRequest(QUrl("http://www.hedgewars.org" + name.toString()));
--- a/QTfrontend/game.cpp	Sun Sep 04 13:36:59 2011 -0400
+++ b/QTfrontend/game.cpp	Sun Sep 04 21:39:50 2011 +0400
@@ -84,8 +84,7 @@
 
     if (m_pTeamSelWidget)
     {
-        QListIterator<HWTeam> it(m_pTeamSelWidget->getPlayingTeams());
-        while(it.hasNext())
+        foreach(HWTeam team, m_pTeamSelWidget->getPlayingTeams())
         {
             HWProto::addStringToBuffer(buf, QString("eammloadt %1").arg(ammostr.mid(0, cAmmoNumber)));
             HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber)));
@@ -93,7 +92,7 @@
             HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber)));
             if(!gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore"));
             HWProto::addStringListToBuffer(buf,
-                it.next().TeamGameConfig(gamecfg->getInitHealth()));
+                team.TeamGameConfig(gamecfg->getInitHealth()));
             ;
         }
     }
@@ -392,9 +391,8 @@
     if (m_pTeamSelWidget)
     {
         QByteArray buf;
-        QListIterator<HWTeam> it(m_pTeamSelWidget->getPlayingTeams());
-        while(it.hasNext())
-            HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg(it.next().TeamName));
+        foreach(HWTeam team, m_pTeamSelWidget->getPlayingTeams())
+            HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg(team.TeamName));
         RawSendIPC(buf);
     }
 }
--- a/QTfrontend/hwform.cpp	Sun Sep 04 13:36:59 2011 -0400
+++ b/QTfrontend/hwform.cpp	Sun Sep 04 21:39:50 2011 +0400
@@ -626,8 +626,9 @@
     }
 
     QStringList tmnames;
-    QListIterator<HWTeam> it(curTeamSelWidget->getDontPlayingTeams());
-    while(it.hasNext()) tmnames += it.next().TeamName;
+
+    foreach(HWTeam team, curTeamSelWidget->getDontPlayingTeams())
+        tmnames += team.TeamName;
 
     //UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring
     UpdateTeamsLists();
--- a/QTfrontend/teamselect.cpp	Sun Sep 04 13:36:59 2011 -0400
+++ b/QTfrontend/teamselect.cpp	Sun Sep 04 21:39:50 2011 +0400
@@ -255,8 +255,8 @@
   frameDontPlaying->resetTeams();
   curDontPlayingTeams.clear();
 
-  QListIterator<HWTeam> it(teamslist);
-  while(it.hasNext()) addTeam(it.next());
+  foreach(HWTeam team, teamslist)
+    addTeam(team);
 }
 
 bool TeamSelWidget::isPlaying(HWTeam team) const