25 |
25 |
26 QSettings* getMissionTeamFile(QString & missionName, QString & teamName) |
26 QSettings* getMissionTeamFile(QString & missionName, QString & teamName) |
27 { |
27 { |
28 QSettings* teamfile = new QSettings(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
28 QSettings* teamfile = new QSettings(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
29 teamfile->setIniCodec("UTF-8"); |
29 teamfile->setIniCodec("UTF-8"); |
30 // if entry not found check if there is written without _ |
30 if (!teamfile->childGroups().contains("Mission " + missionName) && |
31 // if then is found rename it to use _ |
31 teamfile->childGroups().contains("Mission " + missionName)){ |
32 QString cleanedMissionName = missionName; |
32 teamfile->beginGroup("Mission " + missionName); |
33 cleanedMissionName = cleanedMissionName.replace(QString("_"),QString(" ")); |
|
34 if (!teamfile->childGroups().contains("Mission " + cleanedMissionName) && |
|
35 teamfile->childGroups().contains("Mission " + cleanedMissionName)){ |
|
36 teamfile->beginGroup("Mission " + cleanedMissionName); |
|
37 QStringList keys = teamfile->childKeys(); |
33 QStringList keys = teamfile->childKeys(); |
38 teamfile->endGroup(); |
34 teamfile->endGroup(); |
39 for (int i=0;i<keys.size();i++) { |
35 for (int i=0;i<keys.size();i++) { |
40 QVariant value = teamfile->value("Mission " + cleanedMissionName + "/" + keys[i]); |
36 QVariant value = teamfile->value("Mission " + missionName + "/" + keys[i]); |
41 teamfile->setValue("Mission " + missionName + "/" + keys[i], value); |
37 teamfile->setValue("Mission " + missionName + "/" + keys[i], value); |
42 } |
38 } |
43 teamfile->remove("Mission " + cleanedMissionName); |
39 teamfile->remove("Mission " + missionName); |
44 } |
40 } |
45 |
41 |
46 return teamfile; |
42 return teamfile; |
47 } |
43 } |
48 |
44 |