QTfrontend/selectWeapon.cpp
changeset 717 490dc8bb5b87
parent 696 d6f32ed6edc8
child 718 f93a38d2c982
equal deleted inserted replaced
716:89dbc73c91d2 717:490dc8bb5b87
   119   for(int i=0; i<m_numItems; ++i) {
   119   for(int i=0; i<m_numItems; ++i) {
   120     twi::const_iterator it=weaponItems.find(i);
   120     twi::const_iterator it=weaponItems.find(i);
   121     int num = it==weaponItems.end() ? 9 : (*this)[i];
   121     int num = it==weaponItems.end() ? 9 : (*this)[i];
   122     currentState = QString("%1%2").arg(currentState).arg(num);
   122     currentState = QString("%1%2").arg(currentState).arg(num);
   123   }
   123   }
       
   124   if (curWeaponsName!="") {
       
   125     // remove old entry
       
   126     wconf->remove(curWeaponsName);
       
   127   }
   124   wconf->setValue(m_name->text(), currentState);
   128   wconf->setValue(m_name->text(), currentState);
   125   emit weaponsChanged();
   129   emit weaponsChanged();
   126 }
   130 }
   127 
   131 
   128 int SelWeaponWidget::operator [] (unsigned int weaponIndex) const
   132 int SelWeaponWidget::operator [] (unsigned int weaponIndex) const
   139 QString SelWeaponWidget::getWeaponsString(const QString& name) const
   143 QString SelWeaponWidget::getWeaponsString(const QString& name) const
   140 {
   144 {
   141   return wconf->value(name).toString();
   145   return wconf->value(name).toString();
   142 }
   146 }
   143 
   147 
   144 void SelWeaponWidget::setWeaponsName(const QString& name)
   148 void SelWeaponWidget::setWeaponsName(const QString& name, bool editMode)
   145 {
   149 {
   146   if(name!="" && wconf->contains(name)) {
   150   if(name!="" && wconf->contains(name)) {
   147     setWeapons(wconf->value(name).toString());
   151     setWeapons(wconf->value(name).toString());
   148   }
   152   }
   149 
   153 
   150   curWeaponsName=name;
   154   if(editMode) curWeaponsName=name;
       
   155   else curWeaponsName="";
       
   156 
   151   m_name->setText(name);
   157   m_name->setText(name);
   152 }
   158 }
   153 
   159 
   154 QStringList SelWeaponWidget::getWeaponNames() const
   160 QStringList SelWeaponWidget::getWeaponNames() const
   155 {
   161 {