QTfrontend/ui/widget/selectWeapon.cpp
changeset 9900 34ba1d8e0e9a
parent 9080 9b42757d7e71
child 9998 736015b847e3
equal deleted inserted replaced
9898:b87695f82d2e 9900:34ba1d8e0e9a
    91 
    91 
    92     QStringList keys = wconf->allKeys();
    92     QStringList keys = wconf->allKeys();
    93     for(int i = 0; i < keys.size(); i++)
    93     for(int i = 0; i < keys.size(); i++)
    94     {
    94     {
    95         if (wconf->value(keys[i]).toString().size() != cDefaultAmmoStore->size())
    95         if (wconf->value(keys[i]).toString().size() != cDefaultAmmoStore->size())
    96             wconf->remove(keys[i]);
    96             wconf->setValue(keys[i], fixWeaponSet(wconf->value(keys[i]).toString()));
    97     }
    97     }
    98 
    98 
    99     QString currentState = *cDefaultAmmoStore;
    99     QString currentState = *cDefaultAmmoStore;
   100 
   100 
   101     QTabWidget * tbw = new QTabWidget(this);
   101     QTabWidget * tbw = new QTabWidget(this);
   331         }
   331         }
   332         setWeaponsName(newName);
   332         setWeaponsName(newName);
   333         setWeapons(ammo);
   333         setWeapons(ammo);
   334     }
   334     }
   335 }
   335 }
       
   336 
       
   337 QString SelWeaponWidget::fixWeaponSet(const QString &s)
       
   338 {
       
   339     int neededLength = cDefaultAmmoStore->size() / 4;
       
   340     int thisSetLength = s.size() / 4;
       
   341 
       
   342     QStringList sl;
       
   343     sl
       
   344             << s.left(thisSetLength)
       
   345             << s.mid(thisSetLength, thisSetLength)
       
   346             << s.mid(thisSetLength * 2, thisSetLength)
       
   347             << s.right(thisSetLength)
       
   348                ;
       
   349 
       
   350     for(int i = sl.length() - 1; i >= 0; --i)
       
   351         sl[i] = sl[i].leftJustified(neededLength, '0', true);
       
   352 
       
   353     return sl.join(QString());
       
   354 }