diff options
author | Sergei Litovchuk <slitovchuk@productengine.com> | 2010-06-29 20:07:33 +0300 |
---|---|---|
committer | Sergei Litovchuk <slitovchuk@productengine.com> | 2010-06-29 20:07:33 +0300 |
commit | a7fba99d55f335f3f366cac351b782b803cdf349 (patch) | |
tree | 4aea46312faa29e23581283f1268ed22ca1a8117 /indra/newview/llwearableitemslist.cpp | |
parent | b54fd9d6855c8547ce03beacf1ef04eb6396e75e (diff) |
EXT-7676 FIXED Added items sorting from gear menu for 'Add Wearable'.
- Added new gear menu when 'Add Wearable' panel is open in 'Edit Outfit'.
- Added wearable items list comparator to sort by wearable creation date.
- Added storing sorting type in viewer settings.
Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/661/.
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview/llwearableitemslist.cpp')
-rw-r--r-- | indra/newview/llwearableitemslist.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index cf165f8f66..17b871338f 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -437,11 +437,27 @@ LLWearableItemTypeNameComparator::ETypeListOrder LLWearableItemTypeNameComparato } } +/*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 const LLWearableItemNameComparator WEARABLE_NAME_COMPARATOR; +static const LLWearableItemCreationDateComparator WEARABLE_CREATION_DATE_COMPARATOR; static const LLDefaultChildRegistry::Register<LLWearableItemsList> r("wearable_items_list"); @@ -453,7 +469,7 @@ LLWearableItemsList::Params::Params() LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p) : LLInventoryItemsList(p) { - setComparator(&WEARABLE_TYPE_NAME_COMPARATOR); + setSortOrder(E_SORT_BY_TYPE, false); mIsStandalone = p.standalone; if (mIsStandalone) { @@ -553,6 +569,32 @@ 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: + 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 ////////////////////////////////////////////////////////////////////////// |