--- a/QTfrontend/hwform.cpp Mon Jun 17 22:54:17 2013 +0200
+++ b/QTfrontend/hwform.cpp Mon Jun 17 23:10:45 2013 +0200
@@ -194,8 +194,8 @@
//connect (updateData, SIGNAL(activated()), &DataManager::instance(), SLOT(reload()));
#endif
- previousCampaignName = "";
- previousTeamName = "";
+ previousCampaignName = "";
+ previousTeamName = "";
UpdateTeamsLists();
InitCampaignPage();
UpdateCampaignPage(0);
@@ -597,7 +597,9 @@
updateXfire();
#endif
+#ifdef QT_DEBUG
qDebug("Leaving %s, entering %s", qPrintable(stringifyPageId(lastid)), qPrintable(stringifyPageId(id)));
+#endif
if (lastid == ID_PAGE_MAIN)
{
ui.pageMain->resetNetworkChoice();
@@ -1894,7 +1896,7 @@
void HWForm::UpdateCampaignPage(int index)
{
Q_UNUSED(index);
-
+
HWTeam team(ui.pageCampaign->CBTeam->currentText());
ui.pageCampaign->CBMission->clear();
@@ -1903,61 +1905,61 @@
QString tName = team.name();
unsigned int n = missionEntries.count();
unsigned int m = getCampProgress(tName, campaignName);
-
+
// if the campaign name changes update the campaignMissionDescriptions list
// this will be used later in UpdateCampaignPageMission() to update
// the mission description in the campaign page
bool updateMissionList = false;
QSettings * m_info;
- if(previousCampaignName.compare(campaignName)!=0 ||
- previousTeamName.compare(tName) != 0)
+ if(previousCampaignName.compare(campaignName)!=0 ||
+ previousTeamName.compare(tName) != 0)
{
- if (previousTeamName.compare(tName) != 0 &&
- previousTeamName.compare("") != 0)
- index = qMin(m + 1, n);
- previousCampaignName = campaignName;
- previousTeamName = tName;
- updateMissionList = true;
- // the following code was based on pagetraining.cpp
- DataManager & dataMgr = DataManager::instance();
- // get locale
- QSettings settings(dataMgr.settingsFileName(),
- QSettings::IniFormat);
- QString loc = settings.value("misc/locale", "").toString();
- if (loc.isEmpty())
- loc = QLocale::system().name();
- QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt");
- // if file is non-existant try with language only
- if (!QFile::exists(campaignDescFile))
- campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt");
+ if (previousTeamName.compare(tName) != 0 &&
+ previousTeamName.compare("") != 0)
+ index = qMin(m + 1, n);
+ previousCampaignName = campaignName;
+ previousTeamName = tName;
+ updateMissionList = true;
+ // the following code was based on pagetraining.cpp
+ DataManager & dataMgr = DataManager::instance();
+ // get locale
+ QSettings settings(dataMgr.settingsFileName(),
+ QSettings::IniFormat);
+ QString loc = settings.value("misc/locale", "").toString();
+ if (loc.isEmpty())
+ loc = QLocale::system().name();
+ QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt");
+ // if file is non-existant try with language only
+ if (!QFile::exists(campaignDescFile))
+ campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt");
- // fallback if file for current locale is non-existant
- if (!QFile::exists(campaignDescFile))
- campaignDescFile = QString("physfs://Locale/campaigns_en.txt");
-
- m_info = new QSettings(campaignDescFile, QSettings::IniFormat, this);
- m_info->setIniCodec("UTF-8");
- campaignMissionDescriptions.clear();
- ui.pageCampaign->CBMission->clear();
- }
-
+ // fallback if file for current locale is non-existant
+ if (!QFile::exists(campaignDescFile))
+ campaignDescFile = QString("physfs://Locale/campaigns_en.txt");
+
+ m_info = new QSettings(campaignDescFile, QSettings::IniFormat, this);
+ m_info->setIniCodec("UTF-8");
+ campaignMissionDescriptions.clear();
+ ui.pageCampaign->CBMission->clear();
+ }
+
for (unsigned int i = qMin(m + 1, n); i > 0; i--)
{
- if(updateMissionList)
+ if(updateMissionList)
{
- campaignMissionDescriptions += m_info->value(campaignName+"-"+ getCampaignMissionName(campaignName,i) + ".desc",
+ campaignMissionDescriptions += m_info->value(campaignName+"-"+ getCampaignMissionName(campaignName,i) + ".desc",
tr("No description available")).toString();
- }
- ui.pageCampaign->CBMission->addItem(QString("Mission %1: ").arg(i) + QString(missionEntries[i-1]), QString(missionEntries[i-1]));
+ }
+ ui.pageCampaign->CBMission->addItem(QString("Mission %1: ").arg(i) + QString(missionEntries[i-1]), QString(missionEntries[i-1]));
}
if(updateMissionList)
- delete m_info;
+ delete m_info;
UpdateCampaignPageMission(index);
}
-void HWForm::UpdateCampaignPageMission(int index)
-{
+void HWForm::UpdateCampaignPageMission(int index)
+{
// update thumbnail
QString campaignName = ui.pageCampaign->CBCampaign->currentText();
unsigned int mNum = ui.pageCampaign->CBMission->count() - ui.pageCampaign->CBMission->currentIndex();
@@ -1967,9 +1969,9 @@
// when campaign changes the UpdateCampaignPageMission is triggered with wrong values
// this will cause segfault. This check prevents illegal memory reads
if(index > -1 && index < campaignMissionDescriptions.count()) {
- ui.pageCampaign->lbltitle->setText("<h2>"+ui.pageCampaign->CBMission->currentText()+"</h2>");
- ui.pageCampaign->lbldescription->setText(campaignMissionDescriptions[index]);
- }
+ ui.pageCampaign->lbltitle->setText("<h2>"+ui.pageCampaign->CBMission->currentText()+"</h2>");
+ ui.pageCampaign->lbldescription->setText(campaignMissionDescriptions[index]);
+ }
}
void HWForm::UpdateCampaignPageProgress(int index)