From e0855e524941e476950eb17510503284079229da Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 17 Dec 2009 18:34:50 +0200 Subject: Fixed major bug EXT-3498 (Sorting not working correctly in Favorites Bar) - added sorting of Favorites items before reordering --HG-- branch : product-engine --- indra/newview/llinventorybridge.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index bacc685130..35ae4dee8e 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2929,6 +2929,27 @@ LLInventoryModel::item_array_t::iterator findItemByUUID(LLInventoryModel::item_a return result; } +// See also LLInventorySort where landmarks in the Favorites folder are sorted. +class LLViewerInventoryItemSort +{ +public: + bool operator()(const LLPointer& a, const LLPointer& b) + { + return a->getSortField() < b->getSortField(); + } +}; + +/** + * Sorts passed items by LLViewerInventoryItem sort field. + * + * @param[in, out] items - array of items, not sorted. + */ +void rearrange_item_order_by_sort_field(LLInventoryModel::item_array_t& items) +{ + static LLViewerInventoryItemSort sort_functor; + std::sort(items.begin(), items.end(), sort_functor); +} + void updateItemsOrder(LLInventoryModel::item_array_t& items, const LLUUID& srcItemId, const LLUUID& destItemId) { LLViewerInventoryItem* srcItem = gInventory.getItem(srcItemId); @@ -3044,6 +3065,9 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, LLUUID srcItemId = inv_item->getUUID(); LLUUID destItemId = itemp->getListener()->getUUID(); + // ensure items are sorted properly before changing order. EXT-3498 + rearrange_item_order_by_sort_field(items); + // update order updateItemsOrder(items, srcItemId, destItemId); -- cgit v1.2.3