QTfrontend/ui/widget/selectWeapon.cpp
changeset 6616 f77bb02b669f
parent 6479 4f08821cbff5
child 6700 e04da46ee43c
--- a/QTfrontend/ui/widget/selectWeapon.cpp	Mon Jan 30 23:20:28 2012 +0100
+++ b/QTfrontend/ui/widget/selectWeapon.cpp	Mon Jan 30 17:32:18 2012 -0500
@@ -81,8 +81,8 @@
 }
 
 SelWeaponWidget::SelWeaponWidget(int numItems, QWidget* parent) :
-  QFrame(parent),
-  m_numItems(numItems)
+    QFrame(parent),
+    m_numItems(numItems)
 {
     wconf = new QSettings(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat, this);
 
@@ -127,7 +127,8 @@
 
     int j = -1;
     int i = 0, k = 0;
-    for(; i < m_numItems; ++i) {
+    for(; i < m_numItems; ++i)
+    {
         if (i == 6) continue;
         if (k % 4 == 0) ++j;
         SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), QImage(":/res/ammopic.png"), QImage(":/res/ammopicgrey.png"), this);
@@ -158,10 +159,12 @@
 {
     bool enable = true;
     for(int i = 0; i < cDefaultAmmos.size(); i++)
-        if (!cDefaultAmmos[i].first.compare(m_name->text())) {
+        if (!cDefaultAmmos[i].first.compare(m_name->text()))
+        {
             enable = false;
         }
-    for(int i = 0; i < m_numItems; ++i) {
+    for(int i = 0; i < m_numItems; ++i)
+    {
         twi::iterator it = weaponItems.find(i);
         if (it == weaponItems.end()) continue;
         it.value()[0]->setItemsNum(ammo[i].digitValue());
@@ -179,7 +182,8 @@
 void SelWeaponWidget::setDefault()
 {
     for(int i = 0; i < cDefaultAmmos.size(); i++)
-        if (!cDefaultAmmos[i].first.compare(m_name->text())) {
+        if (!cDefaultAmmos[i].first.compare(m_name->text()))
+        {
             return;
         }
     setWeapons(*cDefaultAmmoStore);
@@ -188,7 +192,8 @@
 void SelWeaponWidget::save()
 {
     for(int i = 0; i < cDefaultAmmos.size(); i++)
-        if (!cDefaultAmmos[i].first.compare(m_name->text())) {
+        if (!cDefaultAmmos[i].first.compare(m_name->text()))
+        {
             QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not overwrite default weapon set '%1'!").arg(cDefaultAmmos[i].first));
             return;
         }
@@ -200,7 +205,8 @@
     QString state3;
     QString state4;
 
-    for(int i = 0; i < m_numItems; ++i) {
+    for(int i = 0; i < m_numItems; ++i)
+    {
         twi::const_iterator it = weaponItems.find(i);
         int num = it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); // 9 is for 'skip turn'
         state1.append(QString::number(num));
@@ -211,7 +217,8 @@
         int am = it == weaponItems.end() ? 0 : it.value()[3]->getItemsNum();
         state4.append(QString::number(am));
     }
-    if (curWeaponsName != "") {
+    if (curWeaponsName != "")
+    {
         // remove old entry
         wconf->remove(curWeaponsName);
     }
@@ -235,14 +242,16 @@
     if (curWeaponsName == "") return;
 
     for(int i = 0; i < cDefaultAmmos.size(); i++)
-        if (!cDefaultAmmos[i].first.compare(m_name->text())) {
+        if (!cDefaultAmmos[i].first.compare(m_name->text()))
+        {
             QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not delete default weapon set '%1'!").arg(cDefaultAmmos[i].first));
             return;
         }
 
     QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel);
 
-    if (reallyDelete.exec() == QMessageBox::Ok) {
+    if (reallyDelete.exec() == QMessageBox::Ok)
+    {
         wconf->remove(curWeaponsName);
         emit weaponsDeleted();
     }
@@ -251,7 +260,8 @@
 void SelWeaponWidget::newWeaponsName()
 {
     QString newName = tr("new");
-    if(wconf->contains(newName)) {
+    if(wconf->contains(newName))
+    {
         //name already used -> look for an appropriate name:
         int i=2;
         while(wconf->contains(newName = tr("new")+QString::number(i++))) ;
@@ -265,9 +275,12 @@
 
     curWeaponsName = name;
 
-    if(name != "" && wconf->contains(name)) {
+    if(name != "" && wconf->contains(name))
+    {
         setWeapons(wconf->value(name).toString());
-    } else {
+    }
+    else
+    {
         setWeapons(*cDefaultAmmoStore);
     }
 }
@@ -279,10 +292,12 @@
 
 void SelWeaponWidget::copy()
 {
-    if(wconf->contains(curWeaponsName)) {
+    if(wconf->contains(curWeaponsName))
+    {
         QString ammo = getWeaponsString(curWeaponsName);
         QString newName = tr("copy of") + " " + curWeaponsName;
-        if(wconf->contains(newName)) {
+        if(wconf->contains(newName))
+        {
             //name already used -> look for an appropriate name:
             int i=2;
             while(wconf->contains(newName = tr("copy of") + " " + curWeaponsName+QString::number(i++))) ;