From aeb4c27c12c549194648f8039d476ecd0f61ec9a Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 3 May 2014 19:51:05 -0700 Subject: [PATCH] Clean up localization mgr lookups and add some missing mnemonics --- .../pfLocalizationDataMgr.cpp | 47 ++++++++++++------- .../Tools/plLocalizationEditor/plEditDlg.cpp | 10 ++-- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp b/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp index 441151e9..c9811f23 100644 --- a/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp +++ b/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp @@ -691,11 +691,14 @@ bool pfLocalizationDataMgr::pf3PartMap::exists(const plString & key) return false; // now check individually - if (fData.find(age) == fData.end()) // age doesn't exist + auto curAge = fData.find(age); + if (curAge == fData.end()) // age doesn't exist return false; - if (fData[age].find(set) == fData[age].end()) // set doesn't exist + auto curSet = curAge->second.find(set); + if (curSet == curAge->second.end()) // set doesn't exist return false; - if (fData[age][set].find(name) == fData[age][set].end()) // name doesn't exist + auto curElement = curSet->second.find(name); + if (curElement == curSet->second.end()) // name doesn't exist return false; // we passed all the tests, return true! @@ -713,9 +716,11 @@ bool pfLocalizationDataMgr::pf3PartMap::setExists(const plString & key) return false; // now check individually - if (fData.find(age) == fData.end()) // age doesn't exist + auto curAge = fData.find(age); + if (curAge == fData.end()) // age doesn't exist return false; - if (fData[age].find(set) == fData[age].end()) // set doesn't exist + auto curSet = curAge->second.find(set); + if (curSet == curAge->second.end()) // set doesn't exist return false; // we passed all the tests, return true! @@ -733,19 +738,22 @@ void pfLocalizationDataMgr::pf3PartMap::erase(const plString & key) return; // now check individually - if (fData.find(age) == fData.end()) // age doesn't exist + auto curAge = fData.find(age); + if (curAge == fData.end()) // age doesn't exist return; - if (fData[age].find(set) == fData[age].end()) // set doesn't exist + auto curSet = curAge->second.find(set); + if (curSet == curAge->second.end()) // set doesn't exist return; - if (fData[age][set].find(name) == fData[age][set].end()) // name doesn't exist + auto curElement = curSet->second.find(name); + if (curElement == curSet->second.end()) // name doesn't exist return; // ok, so now we want to nuke it! - fData[age][set].erase(name); - if (fData[age][set].size() == 0) // is the set now empty? - fData[age].erase(set); // nuke it! - if (fData[age].size() == 0) // is the age now empty? - fData.erase(age); // nuke it! + curSet->second.erase(name); + if (curSet->second.size() == 0) // is the set now empty? + curAge->second.erase(curSet); // nuke it! + if (curAge->second.size() == 0) // is the age now empty? + fData.erase(curAge); // nuke it! } //// operator[]() //////////////////////////////////////////////////// @@ -780,10 +788,11 @@ std::vector pfLocalizationDataMgr::pf3PartMap::getSetList(const std::vector retVal; typename std::map >::iterator curSet; - if (fData.find(age) == fData.end()) + auto curAge = fData.find(age); + if (curAge == fData.end()) return retVal; // return an empty list, the age doesn't exist - for (curSet = fData[age].begin(); curSet != fData[age].end(); curSet++) + for (curSet = curAge->second.begin(); curSet != curAge->second.end(); curSet++) retVal.push_back(curSet->first); return retVal; @@ -797,13 +806,15 @@ std::vector pfLocalizationDataMgr::pf3PartMap::getNameList(const std::vector retVal; typename std::map::iterator curName; - if (fData.find(age) == fData.end()) + auto curAge = fData.find(age); + if (curAge == fData.end()) return retVal; // return an empty list, the age doesn't exist - if (fData[age].find(set) == fData[age].end()) + auto curSet = curAge->second.find(set); + if (curSet == curAge->second.end()) return retVal; // return an empty list, the set doesn't exist - for (curName = fData[age][set].begin(); curName != fData[age][set].end(); curName++) + for (curName = curSet->second.begin(); curName != curSet->second.end(); curName++) retVal.push_back(curName->first); return retVal; diff --git a/Sources/Tools/plLocalizationEditor/plEditDlg.cpp b/Sources/Tools/plLocalizationEditor/plEditDlg.cpp index 686ed0a0..1dde33bc 100644 --- a/Sources/Tools/plLocalizationEditor/plEditDlg.cpp +++ b/Sources/Tools/plLocalizationEditor/plEditDlg.cpp @@ -127,7 +127,7 @@ void EditDialog::LoadLocalization(const plString &locPath) return; fCurrentLocPath = locPath; - fUI->fTextPathLabel->setText(QString("Text (%1):").arg(locPath.c_str())); + fUI->fTextPathLabel->setText(QString("&Text (%1):").arg(locPath.c_str())); plString ageName, setName, elementName, elementLanguage; SplitLocalizationPath(locPath, ageName, setName, elementName, elementLanguage); @@ -147,9 +147,9 @@ void EditDialog::LoadLocalization(const plString &locPath) if (!elementLanguage.IsEmpty()) // they have selected a language { fEditMode = kEditLocalization; - fUI->fAddButton->setText(tr("Add Localization")); + fUI->fAddButton->setText(tr("&Add Localization")); fUI->fAddButton->setEnabled(true); - fUI->fDeleteButton->setText(tr("Delete Localization")); + fUI->fDeleteButton->setText(tr("&Delete Localization")); // don't allow them to delete the default language fUI->fDeleteButton->setEnabled(elementLanguage != "English"); @@ -157,9 +157,9 @@ void EditDialog::LoadLocalization(const plString &locPath) else // they have selected something else { fEditMode = kEditElement; - fUI->fAddButton->setText(tr("Add Element")); + fUI->fAddButton->setText(tr("&Add Element")); fUI->fAddButton->setEnabled(true); - fUI->fDeleteButton->setText(tr("Delete Element")); + fUI->fDeleteButton->setText(tr("&Delete Element")); if (!elementName.IsEmpty()) // they have selected an individual element { std::vector elementNames = pfLocalizationDataMgr::Instance().GetElementList(ageName, setName);