summaryrefslogtreecommitdiff
path: root/indra/newview/llwearableitemslist.cpp
diff options
context:
space:
mode:
authorKent Quirk <q@lindenlab.com>2010-07-30 10:11:55 -0400
committerKent Quirk <q@lindenlab.com>2010-07-30 10:11:55 -0400
commit19c0d6d4eaf21cbfc96d7057c11db35edf73f2fe (patch)
tree21984bc2d7a41ba2587a424499f97d3e6d527da4 /indra/newview/llwearableitemslist.cpp
parentfe8a5a007ab82f3d6a763c5cb133e1299d238632 (diff)
parent7a4174447a0762dcab2769d1401295b78c9341fd (diff)
Merge from q/viewer-release to dessie/viewer-release for 2.1.1 beta 1
Diffstat (limited to 'indra/newview/llwearableitemslist.cpp')
-rw-r--r--indra/newview/llwearableitemslist.cpp88
1 files changed, 66 insertions, 22 deletions
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 3887f64618..c01d7fa62f 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -365,6 +365,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
{
@@ -393,7 +416,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.
@@ -405,38 +428,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;
+}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -576,13 +622,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, true));
+ registrar.add("Wearable.Add", boost::bind(wear_multiple, ids, false));
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));
@@ -665,8 +709,8 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
bool standalone = mParent ? mParent->isStandalone() : false;
// *TODO: eliminate multiple traversals over the menu items
- setMenuItemVisible(menu, "wear_wear", n_already_worn == 0);
- setMenuItemEnabled(menu, "wear_wear", n_already_worn == 0);
+ setMenuItemVisible(menu, "wear_wear", n_already_worn == 0 && n_worn == 0);
+ setMenuItemEnabled(menu, "wear_wear", n_already_worn == 0 && n_worn == 0);
setMenuItemVisible(menu, "wear_add", mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0);
setMenuItemEnabled(menu, "wear_add", n_items == 1 && canAddWearable(ids.front()) && n_already_worn != 0);
setMenuItemVisible(menu, "wear_replace", n_worn == 0 && n_already_worn != 0);