--- a/QTfrontend/selectWeapon.cpp Fri Mar 25 19:42:00 2011 -0400
+++ b/QTfrontend/selectWeapon.cpp Fri Mar 25 20:02:27 2011 -0400
@@ -250,7 +250,13 @@
void SelWeaponWidget::newWeaponsName()
{
- setWeaponsName(tr("new"));
+ QString newName = tr("new");
+ if(wconf->contains(newName)) {
+ //name already used -> look for an appropriate name:
+ int i=2;
+ while(wconf->contains(newName = tr("new")+QString::number(i++)));
+ }
+ setWeaponsName(newName);
}
void SelWeaponWidget::setWeaponsName(const QString& name)
@@ -273,7 +279,15 @@
void SelWeaponWidget::copy()
{
- QString ammo = getWeaponsString(curWeaponsName);
- setWeaponsName(tr("copy of") + " " + curWeaponsName);
- setWeapons(ammo);
+ if(wconf->contains(curWeaponsName)) {
+ QString ammo = getWeaponsString(curWeaponsName);
+ QString newName = tr("copy of") + " " + curWeaponsName;
+ 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++)));
+ }
+ setWeaponsName(newName);
+ setWeapons(ammo);
+ }
}
--- a/QTfrontend/selectWeapon.h Fri Mar 25 19:42:00 2011 -0400
+++ b/QTfrontend/selectWeapon.h Fri Mar 25 20:02:27 2011 -0400
@@ -56,6 +56,7 @@
public slots:
void setDefault();
void setWeapons(const QString& ammo);
+ //sets the name of the current set
void setWeaponsName(const QString& name);
void deleteWeaponsName();
void newWeaponsName();
@@ -67,10 +68,12 @@
void weaponsDeleted();
private:
+ //the name of the current weapon set
QString curWeaponsName;
QLineEdit* m_name;
+ //storage for all the weapons sets
QSettings* wconf;
const int m_numItems;
@@ -79,6 +82,7 @@
typedef QList<SelWeaponItem*> ItemsList;
typedef QMap<int, ItemsList> twi;
twi weaponItems;
+ //layout element for each tab:
QGridLayout* p1Layout;
QGridLayout* p2Layout;
QGridLayout* p3Layout;