Fixed low bug EXT-4311 (Order of items in 'Favorites Bar' folder remains non-changed if change its order in the 'Favorites Bar')

-- reason: there was two places where identical resorting of Favorite landmarks functionality was implemented: InventoryBridge & Favorite bar.
    It was not impelnmented properly in favorites bar: LLInventoryObserver::SORT flag was not set after d-n-d.
-- fix: moved identical functionality to update & save order of Favorite landmarks from these places to Inventory Panel

--HG--
branch : product-engine
meow-7.2.2
Mike Antipov 2010-01-15 18:02:42 +02:00
parent 7aa96279fe
commit 6e67ac5e02
5 changed files with 80 additions and 95 deletions

View File

@ -508,14 +508,14 @@ void LLFavoritesBarCtrl::handleExistingFavoriteDragAndDrop(S32 x, S32 y)
if (dest)
{
updateItemsOrder(mItems, mDragItemId, dest->getLandmarkId());
LLInventoryModel::updateItemsOrder(mItems, mDragItemId, dest->getLandmarkId());
}
else
{
mItems.push_back(gInventory.getItem(mDragItemId));
}
saveItemsOrder(mItems);
gInventory.saveItemsOrder(mItems);
LLToggleableMenu* menu = (LLToggleableMenu*) mPopupMenuHandle.get();
@ -1193,25 +1193,6 @@ BOOL LLFavoritesBarCtrl::needToSaveItemsOrder(const LLInventoryModel::item_array
return result;
}
void LLFavoritesBarCtrl::saveItemsOrder(LLInventoryModel::item_array_t& items)
{
int sortField = 0;
// current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
for (LLInventoryModel::item_array_t::iterator i = items.begin(); i != items.end(); ++i)
{
LLViewerInventoryItem* item = *i;
item->setSortField(++sortField);
item->setComplete(TRUE);
item->updateServer(FALSE);
gInventory.updateItem(item);
}
gInventory.notifyObservers();
}
LLInventoryModel::item_array_t::iterator LLFavoritesBarCtrl::findItemByUUID(LLInventoryModel::item_array_t& items, const LLUUID& id)
{
LLInventoryModel::item_array_t::iterator result = items.end();
@ -1228,15 +1209,6 @@ LLInventoryModel::item_array_t::iterator LLFavoritesBarCtrl::findItemByUUID(LLIn
return result;
}
void LLFavoritesBarCtrl::updateItemsOrder(LLInventoryModel::item_array_t& items, const LLUUID& srcItemId, const LLUUID& destItemId)
{
LLViewerInventoryItem* srcItem = gInventory.getItem(srcItemId);
LLViewerInventoryItem* destItem = gInventory.getItem(destItemId);
items.erase(findItemByUUID(items, srcItem->getUUID()));
items.insert(findItemByUUID(items, destItem->getUUID()), srcItem);
}
void LLFavoritesBarCtrl::insertBeforeItem(LLInventoryModel::item_array_t& items, const LLUUID& beforeItemId, LLViewerInventoryItem* insertedItem)
{
LLViewerInventoryItem* beforeItem = gInventory.getItem(beforeItemId);

View File

@ -126,16 +126,7 @@ private:
// checks if the current order of the favorites items must be saved
BOOL needToSaveItemsOrder(const LLInventoryModel::item_array_t& items);
// saves current order of the favorites items
void saveItemsOrder(LLInventoryModel::item_array_t& items);
/*
* changes favorites items order by insertion of the item identified by srcItemId
* BEFORE the item identified by destItemId. both items must exist in items array.
*/
void updateItemsOrder(LLInventoryModel::item_array_t& items, const LLUUID& srcItemId, const LLUUID& destItemId);
/*
/**
* inserts an item identified by insertedItemId BEFORE an item identified by beforeItemId.
* this function assumes that an item identified by insertedItemId doesn't exist in items array.
*/

View File

@ -2931,50 +2931,6 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response
return false;
}
/*
Next functions intended to reorder items in the inventory folder and save order on server
Is now used for Favorites folder.
*TODO: refactoring is needed with Favorites Bar functionality. Probably should be moved in LLInventoryModel
*/
void saveItemsOrder(LLInventoryModel::item_array_t& items)
{
int sortField = 0;
// current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
for (LLInventoryModel::item_array_t::iterator i = items.begin(); i != items.end(); ++i)
{
LLViewerInventoryItem* item = *i;
item->setSortField(++sortField);
item->setComplete(TRUE);
item->updateServer(FALSE);
gInventory.updateItem(item);
// Tell the parent folder to refresh its sort order.
gInventory.addChangedMask(LLInventoryObserver::SORT, item->getParentUUID());
}
gInventory.notifyObservers();
}
LLInventoryModel::item_array_t::iterator findItemByUUID(LLInventoryModel::item_array_t& items, const LLUUID& id)
{
LLInventoryModel::item_array_t::iterator result = items.end();
for (LLInventoryModel::item_array_t::iterator i = items.begin(); i != items.end(); ++i)
{
if ((*i)->getUUID() == id)
{
result = i;
break;
}
}
return result;
}
// See also LLInventorySort where landmarks in the Favorites folder are sorted.
class LLViewerInventoryItemSort
{
@ -2996,15 +2952,6 @@ void rearrange_item_order_by_sort_field(LLInventoryModel::item_array_t& items)
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);
LLViewerInventoryItem* destItem = gInventory.getItem(destItemId);
items.erase(findItemByUUID(items, srcItem->getUUID()));
items.insert(findItemByUUID(items, destItem->getUUID()), srcItem);
}
BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
BOOL drop)
{
@ -3103,9 +3050,9 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
rearrange_item_order_by_sort_field(items);
// update order
updateItemsOrder(items, srcItemId, destItemId);
LLInventoryModel::updateItemsOrder(items, srcItemId, destItemId);
saveItemsOrder(items);
gInventory.saveItemsOrder(items);
}
}
else if (favorites_id == mUUID) // if target is the favorites folder we use copy

View File

@ -3622,6 +3622,57 @@ BOOL LLInventoryModel::getIsFirstTimeInViewer2()
return sFirstTimeInViewer2;
}
static LLInventoryModel::item_array_t::iterator find_item_iter_by_uuid(LLInventoryModel::item_array_t& items, const LLUUID& id)
{
LLInventoryModel::item_array_t::iterator result = items.end();
for (LLInventoryModel::item_array_t::iterator i = items.begin(); i != items.end(); ++i)
{
if ((*i)->getUUID() == id)
{
result = i;
break;
}
}
return result;
}
// static
void LLInventoryModel::updateItemsOrder(LLInventoryModel::item_array_t& items, const LLUUID& src_item_id, const LLUUID& dest_item_id)
{
LLInventoryModel::item_array_t::iterator it_src = find_item_iter_by_uuid(items, src_item_id);
LLInventoryModel::item_array_t::iterator it_dest = find_item_iter_by_uuid(items, dest_item_id);
if (it_src == items.end() || it_dest == items.end()) return;
LLViewerInventoryItem* src_item = *it_src;
items.erase(it_src);
items.insert(it_dest, src_item);
}
void LLInventoryModel::saveItemsOrder(const LLInventoryModel::item_array_t& items)
{
int sortField = 0;
// current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
for (item_array_t::const_iterator i = items.begin(); i != items.end(); ++i)
{
LLViewerInventoryItem* item = *i;
item->setSortField(++sortField);
item->setComplete(TRUE);
item->updateServer(FALSE);
updateItem(item);
// Tell the parent folder to refresh its sort order.
addChangedMask(LLInventoryObserver::SORT, item->getParentUUID());
}
notifyObservers();
}
//----------------------------------------------------------------------------
// *NOTE: DEBUG functionality

View File

@ -384,6 +384,30 @@ public:
void setLibraryOwnerID(const LLUUID& id);
void setLibraryRootFolderID(const LLUUID& id);
/**
* Changes items order by insertion of the item identified by src_item_id
* BEFORE the item identified by dest_item_id. Both items must exist in items array.
*
* Sorting is stored after method is finished. Only src_item_id is moved before dest_item_id.
*
* @param[in, out] items - vector with items to be updated. It should be sorted in a right way
* before calling this method.
* @param src_item_id - LLUUID of inventory item to be moved in new position
* @param dest_item_id - LLUUID of inventory item before which source item should be placed.
*/
static void updateItemsOrder(LLInventoryModel::item_array_t& items, const LLUUID& src_item_id, const LLUUID& dest_item_id);
/**
* Saves current order of the passed items using inventory item sort field.
*
* It reset items' sort fields and saves them on server.
* Is used to save order for Favorites folder.
*
* @param[in] items vector of items in order to be saved.
*/
void saveItemsOrder(const LLInventoryModel::item_array_t& items);
protected:
// Internal methods which add inventory and make sure that all of