check if save from old campaign name scheme exists and if so rename it to use _ instead of spaces -see issue 722
authorPeriklis Ntanasis <pntanasis@gmail.com>
Mon, 23 Dec 2013 02:59:44 +0200
changeset 9821 7501208fd025
parent 9820 1c04ccb9e5fd
child 9822 f3b124352c3a
check if save from old campaign name scheme exists and if so rename it to use _ instead of spaces -see issue #722
QTfrontend/campaign.cpp
--- a/QTfrontend/campaign.cpp	Sun Dec 22 15:49:01 2013 -0500
+++ b/QTfrontend/campaign.cpp	Mon Dec 23 02:59:44 2013 +0200
@@ -28,6 +28,24 @@
     QList<MissionInfo> missionInfoList;
 	QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
     teamfile.setIniCodec("UTF-8");
+    
+    // if entry not found check if there is written without _
+    // if then is found rename it to use _
+    QString spaceCampName = campaignName;
+    spaceCampName = spaceCampName.replace(QString("_"),QString(" "));
+    if (teamfile.childGroups().contains("Campaign " + campaignName) == false and 
+			teamfile.childGroups().contains("Campaign " + spaceCampName) == true){
+		qDebug("CAMP NAME FOUND");
+		teamfile.beginGroup("Campaign " + spaceCampName);
+		QStringList keys = teamfile.childKeys();
+		teamfile.endGroup();
+		for (int i=0;i<keys.size();i++) {			
+			QVariant value = teamfile.value("Campaign " + spaceCampName + "/" + keys[i]);
+			teamfile.setValue("Campaign " + campaignName + "/" + keys[i], value);
+		}
+		teamfile.remove("Campaign " + spaceCampName);
+	}
+	
     int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt();
     int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();