summaryrefslogtreecommitdiff
path: root/indra/newview/llfolderviewmodelinventory.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2013-01-07 17:42:11 -0800
committerMerov Linden <merov@lindenlab.com>2013-01-07 17:42:11 -0800
commitd68f4ff646378070c1a92b3dc53f791454395356 (patch)
treee1b251d2fd2f2c20f6cb497cb83d9b17479c23fa /indra/newview/llfolderviewmodelinventory.cpp
parent3d0ec3da5baea6bb2b9b72707a884ac7b516c4fd (diff)
CHUI-659 : WIP : Reimplemented favorite landmark sorting to follow favorites bar index sorting.
Diffstat (limited to 'indra/newview/llfolderviewmodelinventory.cpp')
-rw-r--r--indra/newview/llfolderviewmodelinventory.cpp53
1 files changed, 23 insertions, 30 deletions
diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp
index 8a4b4bae84..429315e33f 100644
--- a/indra/newview/llfolderviewmodelinventory.cpp
+++ b/indra/newview/llfolderviewmodelinventory.cpp
@@ -29,6 +29,7 @@
#include "llinventorymodelbackgroundfetch.h"
#include "llinventorypanel.h"
#include "lltooldraganddrop.h"
+#include "llfavoritesbar.h"
//
// class LLFolderViewModelInventory
@@ -236,39 +237,31 @@ const LLFolderViewModelInventory* LLInventoryPanel::getFolderViewModel() const
bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, const LLFolderViewModelItemInventory* const& b) const
{
- // ignore sort order for landmarks in the Favorites folder.
- // they should be always sorted as in Favorites bar. See EXT-719
- //TODO RN: fix sorting in favorites folder
- //if (a->getSortGroup() == SG_ITEM
- // && b->getSortGroup() == SG_ITEM
- // && a->getInventoryType() == LLInventoryType::IT_LANDMARK
- // && b->getInventoryType() == LLInventoryType::IT_LANDMARK)
- //{
-
- // static const LLUUID& favorites_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
-
- // LLUUID a_uuid = a->getParentFolder()->getUUID();
- // LLUUID b_uuid = b->getParentFolder()->getUUID();
-
- // if ((a_uuid == favorites_folder_id && b_uuid == favorites_folder_id))
- // {
- // // *TODO: mantipov: probably it is better to add an appropriate method to LLFolderViewItem
- // // or to LLInvFVBridge
- // LLViewerInventoryItem* aitem = (static_cast<const LLItemBridge*>(a))->getItem();
- // LLViewerInventoryItem* bitem = (static_cast<const LLItemBridge*>(b))->getItem();
- // if (!aitem || !bitem)
- // return false;
- // S32 a_sort = aitem->getSortField();
- // S32 b_sort = bitem->getSortField();
- // return a_sort < b_sort;
- // }
- //}
+ // Ignore sort order for landmarks in the Favorites folder.
+ // In that folder, landmarks should be always sorted as in the Favorites bar. See EXT-719
+ if (a->getSortGroup() == SG_ITEM
+ && b->getSortGroup() == SG_ITEM
+ && a->getInventoryType() == LLInventoryType::IT_LANDMARK
+ && b->getInventoryType() == LLInventoryType::IT_LANDMARK)
+ {
+ static const LLUUID& favorites_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
+ // If both landmarks are in the favorite folder...
+ if (gInventory.isObjectDescendentOf(a->getUUID(), favorites_folder_id) && gInventory.isObjectDescendentOf(b->getUUID(), favorites_folder_id))
+ {
+ // Get their index in that folder
+ S32 a_sort = LLFavoritesOrderStorage::instance().getSortIndex(a->getUUID());
+ S32 b_sort = LLFavoritesOrderStorage::instance().getSortIndex(b->getUUID());
+ // Note: since there are both in the favorite, we shouldn't get negative index value...
+ if (!((a_sort < 0) && (b_sort < 0)))
+ {
+ return a_sort < b_sort;
+ }
+ }
+ }
// We sort by name if we aren't sorting by date
// OR if these are folders and we are sorting folders by name.
- bool by_name = (!mByDate
- || (mFoldersByName
- && (a->getSortGroup() != SG_ITEM)));
+ bool by_name = (!mByDate || (mFoldersByName && (a->getSortGroup() != SG_ITEM)));
if (a->getSortGroup() != b->getSortGroup())
{