Anonymous avatar Anonymous committed a74ff17

EXT-8061 FIXED refactoring, added a mapping for According Tab > Asset Type (COF Wearables)

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/704/

Comments (0)

Files changed (2)

indra/newview/llcofwearables.cpp

 	mBodyPartsTab = getChild<LLAccordionCtrlTab>("tab_body_parts");
 	mBodyPartsTab->setDropDownStateChangedCallback(boost::bind(&LLCOFWearables::onAccordionTabStateChanged, this, _1, _2));
 
+	mTab2AssetType[mClothingTab] = LLAssetType::AT_CLOTHING;
+	mTab2AssetType[mAttachmentsTab] = LLAssetType::AT_OBJECT;
+	mTab2AssetType[mBodyPartsTab] = LLAssetType::AT_BODYPART;
+
 	return LLPanel::postBuild();
 }
 
 
 	static type_map_t type_map;
 	static LLAccordionCtrl* accordion_ctrl = getChild<LLAccordionCtrl>("cof_wearables_accordion");
+	const LLAccordionCtrlTab* expanded_tab = accordion_ctrl->getExpandedTab();
 
-	if (type_map.empty())
-	{
-		type_map["tab_clothing"] = LLAssetType::AT_CLOTHING;
-		type_map["tab_attachments"] = LLAssetType::AT_OBJECT;
-		type_map["tab_body_parts"] = LLAssetType::AT_BODYPART;
-	}
-
-	const LLAccordionCtrlTab* tab = accordion_ctrl->getExpandedTab();
-	LLAssetType::EType result = LLAssetType::AT_NONE;
-
-	if (tab)
-	{
-		type_map_t::iterator i = type_map.find(tab->getName());
-		llassert(i != type_map.end());
-		result = i->second;
-	}
-
-	return result;
+	return get_if_there(mTab2AssetType, expanded_tab, LLAssetType::AT_NONE);
 }
 
 LLAssetType::EType LLCOFWearables::getSelectedAccordionAssetType()
 {
-	//*TODO share the code with ::getExpandedAccordionAssetType(...)
 	static LLAccordionCtrl* accordion_ctrl = getChild<LLAccordionCtrl>("cof_wearables_accordion");
 	const LLAccordionCtrlTab* selected_tab = accordion_ctrl->getSelectedTab();
-	
-	if (selected_tab == mClothingTab)
-	{
-		return LLAssetType::AT_CLOTHING;
-	} 
-	else if (selected_tab == mAttachmentsTab)
-	{
-		return LLAssetType::AT_OBJECT;
-	}
-	else if (selected_tab == mBodyPartsTab)
-	{
-		return LLAssetType::AT_BODYPART;
-	}
-	else
-	{
-		return LLAssetType::AT_NONE;
-	}
+
+	return get_if_there(mTab2AssetType, selected_tab, LLAssetType::AT_NONE);
 }
 
 void LLCOFWearables::onListRightClick(LLUICtrl* ctrl, S32 x, S32 y, LLListContextMenu* menu)

indra/newview/llcofwearables.h

 
 	LLAccordionCtrlTab* mLastSelectedTab;
 
+	std::map<const LLAccordionCtrlTab*, LLAssetType::EType> mTab2AssetType;
+
 	LLCOFCallbacks mCOFCallbacks;
 
 	LLListContextMenu* mClothingMenu;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.