diff options
author | Loren Shih <seraph@lindenlab.com> | 2010-07-23 10:13:11 -0400 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2010-07-23 10:13:11 -0400 |
commit | 056685d9d4ac82aad45e46ae5d5226690d416513 (patch) | |
tree | 7f20ea566ee324303582b83c62530b6fa7d7bf98 /indra/newview/llwearableitemslist.cpp | |
parent | 75cfa9a0c3c15e3a472a4c4fd2462402a3a766a0 (diff) | |
parent | 77911533dc68731f50f40b18cd44e287df28f476 (diff) |
automated merge
Diffstat (limited to 'indra/newview/llwearableitemslist.cpp')
-rw-r--r-- | indra/newview/llwearableitemslist.cpp | 84 |
1 files changed, 64 insertions, 20 deletions
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 35abbc0c4d..6a9a00f1c1 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -465,6 +465,29 @@ std::string LLPanelDummyClothingListItem::wearableTypeToString(LLWearableType::E ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// +LLWearableItemTypeNameComparator::LLWearableTypeOrder::LLWearableTypeOrder(LLWearableItemTypeNameComparator::ETypeListOrder order_priority, bool sort_asset_by_name, bool sort_wearable_by_name): + mOrderPriority(order_priority), + mSortAssetTypeByName(sort_asset_by_name), + mSortWearableTypeByName(sort_wearable_by_name) +{ +} + +LLWearableItemTypeNameComparator::LLWearableItemTypeNameComparator() +{ + // By default the sort order conforms the order by spec of MY OUTFITS items list: + // 1. CLOTHING - sorted by name + // 2. OBJECT - sorted by type + // 3. BODYPART - sorted by name + mWearableOrder[LLAssetType::AT_CLOTHING] = LLWearableTypeOrder(ORDER_RANK_1, false, false); + mWearableOrder[LLAssetType::AT_OBJECT] = LLWearableTypeOrder(ORDER_RANK_2, true, true); + mWearableOrder[LLAssetType::AT_BODYPART] = LLWearableTypeOrder(ORDER_RANK_3, false, true); +} + +void LLWearableItemTypeNameComparator::setOrder(LLAssetType::EType items_of_type, LLWearableItemTypeNameComparator::ETypeListOrder order_priority, bool sort_asset_items_by_name, bool sort_wearable_items_by_name) +{ + mWearableOrder[items_of_type] = LLWearableTypeOrder(order_priority, sort_asset_items_by_name, sort_wearable_items_by_name); +} + /*virtual*/ bool LLWearableItemNameComparator::doCompare(const LLPanelInventoryListItemBase* wearable_item1, const LLPanelInventoryListItemBase* wearable_item2) const { @@ -493,7 +516,7 @@ bool LLWearableItemTypeNameComparator::doCompare(const LLPanelInventoryListItemB return item_type_order1 < item_type_order2; } - if (item_type_order1 & TLO_SORTABLE_BY_NAME) + if (sortAssetTypeByName(item_type1)) { // If both items are of the same asset type except AT_CLOTHING and AT_BODYPART // we can compare them by name. @@ -505,38 +528,61 @@ bool LLWearableItemTypeNameComparator::doCompare(const LLPanelInventoryListItemB if (item_wearable_type1 != item_wearable_type2) { - // If items are of different clothing types they are compared - // by clothing types order determined in LLWearableType::EType. + // If items are of different LLWearableType::EType types they are compared + // by LLWearableType::EType. types order determined in LLWearableType::EType. return item_wearable_type1 < item_wearable_type2; } else { // If both items are of the same clothing type they are compared - // by description and place in reverse order i.e. outer layer item - // on top. + // by description and place in reverse order (i.e. outer layer item + // on top) OR by name + if(sortWearableTypeByName(item_type1)) + { + return LLWearableItemNameComparator::doCompare(wearable_item1, wearable_item2); + } return wearable_item1->getDescription() > wearable_item2->getDescription(); } } -// static -LLWearableItemTypeNameComparator::ETypeListOrder LLWearableItemTypeNameComparator::getTypeListOrder(LLAssetType::EType item_type) +LLWearableItemTypeNameComparator::ETypeListOrder LLWearableItemTypeNameComparator::getTypeListOrder(LLAssetType::EType item_type) const { - switch (item_type) + wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type); + + if(const_it == mWearableOrder.end()) { - case LLAssetType::AT_OBJECT: - return TLO_ATTACHMENT; + llwarns<<"Absent information about order rang of items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl; + return ORDER_RANK_UNKNOWN; + } - case LLAssetType::AT_CLOTHING: - return TLO_CLOTHING; + return const_it->second.mOrderPriority; +} - case LLAssetType::AT_BODYPART: - return TLO_BODYPART; +bool LLWearableItemTypeNameComparator::sortAssetTypeByName(LLAssetType::EType item_type) const +{ + wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type); - default: - return TLO_UNKNOWN; + if(const_it == mWearableOrder.end()) + { + llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl; + return true; } + + return const_it->second.mSortAssetTypeByName; } +bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType item_type) const +{ + wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type); + + if(const_it == mWearableOrder.end()) + { + llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl; + return true; + } + + return const_it->second.mSortWearableTypeByName; +} ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// @@ -676,13 +722,11 @@ LLContextMenu* LLWearableItemsList::ContextMenu::createMenu() const uuid_vec_t& ids = mUUIDs; // selected items IDs LLUUID selected_id = ids.front(); // ID of the first selected item - functor_t wear = boost::bind(&LLAppearanceMgr::wearItemOnAvatar, LLAppearanceMgr::getInstance(), _1, true, true, LLPointer<LLInventoryCallback>(NULL)); - functor_t add = boost::bind(&LLAppearanceMgr::wearItemOnAvatar, LLAppearanceMgr::getInstance(), _1, true, false, LLPointer<LLInventoryCallback>(NULL)); functor_t take_off = boost::bind(&LLAppearanceMgr::removeItemFromAvatar, LLAppearanceMgr::getInstance(), _1); // Register handlers common for all wearable types. - registrar.add("Wearable.Wear", boost::bind(handleMultiple, wear, ids)); - registrar.add("Wearable.Add", boost::bind(handleMultiple, add, ids)); + registrar.add("Wearable.Wear", boost::bind(wear_multiple, ids, false)); + registrar.add("Wearable.Add", boost::bind(wear_multiple, ids, true)); registrar.add("Wearable.Edit", boost::bind(handleMultiple, LLAgentWearables::editWearable, ids)); registrar.add("Wearable.CreateNew", boost::bind(createNewWearable, selected_id)); registrar.add("Wearable.ShowOriginal", boost::bind(show_item_original, selected_id)); |