summaryrefslogtreecommitdiff
path: root/indra/newview/llwearableitemslist.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-08-03 13:35:33 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-08-03 13:35:33 +0100
commit6bff1b1444dca9c0230fd5996b9136cb2f76c8f1 (patch)
tree1945871fd38361534236096995d51fef9a5130ac /indra/newview/llwearableitemslist.cpp
parent665274abad307e8c5fff38660e3cd7e9a912abe4 (diff)
parent48ccc7ccfbe3e94f9dd78ced588e0a76d03fe070 (diff)
merge from PE's viewer-trunk
Diffstat (limited to 'indra/newview/llwearableitemslist.cpp')
-rw-r--r--indra/newview/llwearableitemslist.cpp53
1 files changed, 51 insertions, 2 deletions
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 34f6fbebd6..c9130b56b4 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -583,11 +583,28 @@ bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType
return const_it->second.mSortWearableTypeByName;
}
+
+/*virtual*/
+bool LLWearableItemCreationDateComparator::doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const
+{
+ time_t date1 = item1->getCreationDate();
+ time_t date2 = item2->getCreationDate();
+
+ if (date1 == date2)
+ {
+ return LLWearableItemNameComparator::doCompare(item1, item2);
+ }
+
+ return date1 > date2;
+}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-static const LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
+static LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
+static const LLWearableItemTypeNameComparator WEARABLE_TYPE_LAYER_COMPARATOR;
+static const LLWearableItemNameComparator WEARABLE_NAME_COMPARATOR;
+static const LLWearableItemCreationDateComparator WEARABLE_CREATION_DATE_COMPARATOR;
static const LLDefaultChildRegistry::Register<LLWearableItemsList> r("wearable_items_list");
@@ -599,7 +616,7 @@ LLWearableItemsList::Params::Params()
LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p)
: LLInventoryItemsList(p)
{
- setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
+ setSortOrder(E_SORT_BY_TYPE_LAYER, false);
mIsStandalone = p.standalone;
if (mIsStandalone)
{
@@ -699,6 +716,38 @@ void LLWearableItemsList::onRightClick(S32 x, S32 y)
ContextMenu::instance().show(this, selected_uuids, x, y);
}
+void LLWearableItemsList::setSortOrder(ESortOrder sort_order, bool sort_now)
+{
+ switch (sort_order)
+ {
+ case E_SORT_BY_MOST_RECENT:
+ setComparator(&WEARABLE_CREATION_DATE_COMPARATOR);
+ break;
+ case E_SORT_BY_NAME:
+ setComparator(&WEARABLE_NAME_COMPARATOR);
+ break;
+ case E_SORT_BY_TYPE_LAYER:
+ setComparator(&WEARABLE_TYPE_LAYER_COMPARATOR);
+ break;
+ case E_SORT_BY_TYPE_NAME:
+ {
+ WEARABLE_TYPE_NAME_COMPARATOR.setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANK_1, false, true);
+ setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
+ break;
+ }
+
+ // No "default:" to raise compiler warning
+ // if we're not handling something
+ }
+
+ mSortOrder = sort_order;
+
+ if (sort_now)
+ {
+ sort();
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
/// ContextMenu
//////////////////////////////////////////////////////////////////////////