summaryrefslogtreecommitdiff
path: root/indra/newview/llinventoryfunctions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventoryfunctions.cpp')
-rw-r--r--indra/newview/llinventoryfunctions.cpp106
1 files changed, 92 insertions, 14 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 27edc8148e..67240ac7e7 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -529,7 +529,11 @@ BOOL get_is_item_worn(const LLUUID& id)
const LLViewerInventoryItem* item = gInventory.getItem(id);
if (!item)
return FALSE;
-
+
+ if (item->getIsLinkType() && !gInventory.getItem(item->getLinkedUUID()))
+ {
+ return FALSE;
+ }
// Consider the item as worn if it has links in COF.
if (LLAppearanceMgr::instance().isLinkedInCOF(id))
{
@@ -787,7 +791,7 @@ void show_item_original(const LLUUID& item_uuid)
LLPanelMainInventory* main_inventory = sidepanel_inventory->getMainInventoryPanel();
if (main_inventory)
{
- main_inventory->resetFilters();
+ main_inventory->resetAllItemsFilters();
}
reset_inventory_filter();
@@ -795,6 +799,7 @@ void show_item_original(const LLUUID& item_uuid)
{
LLFloaterReg::toggleInstanceOrBringToFront("inventory");
}
+ sidepanel_inventory->showInventoryPanel();
const LLUUID inbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_INBOX);
if (gInventory.isObjectDescendentOf(gInventory.getLinkedItemID(item_uuid), inbox_id))
@@ -862,6 +867,9 @@ LLUUID create_folder_for_item(LLInventoryItem* item, const LLUUID& destFolderId)
S32 depth_nesting_in_marketplace(LLUUID cur_uuid)
{
// Get the marketplace listings root, exit with -1 (i.e. not under the marketplace listings root) if none
+ // Todo: findCategoryUUIDForType is somewhat expensive with large
+ // flat root folders yet we use depth_nesting_in_marketplace at
+ // every turn, find a way to correctly cache this id.
const LLUUID marketplace_listings_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
if (marketplace_listings_uuid.isNull())
{
@@ -1403,9 +1411,6 @@ bool move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol
LLNotificationsUtil::add("MerchantPasteFailed", subs);
return false;
}
-
- // Get the parent folder of the moved item : we may have to update it
- LLUUID src_folder = viewer_inv_item->getParentUUID();
if (copy)
{
@@ -1504,7 +1509,12 @@ void dump_trace(std::string& message, S32 depth, LLError::ELevel log_level)
// This function does no deletion of listings but a mere audit and raises issues to the user (through the
// optional callback cb). It also returns a boolean, true if things validate, false if issues are raised.
// The only inventory changes that are done is to move and sort folders containing no-copy items to stock folders.
-bool validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_t cb, bool fix_hierarchy, S32 depth)
+bool validate_marketplacelistings(
+ LLInventoryCategory* cat,
+ validation_callback_t cb,
+ bool fix_hierarchy,
+ S32 depth,
+ bool notify_observers)
{
#if 0
// Used only for debug
@@ -1570,7 +1580,7 @@ bool validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_
LLUUID folder_uuid = gInventory.createNewCategory(parent_uuid, LLFolderType::FT_NONE, cat->getName());
LLInventoryCategory* new_cat = gInventory.getCategory(folder_uuid);
gInventory.changeCategoryParent(viewer_cat, folder_uuid, false);
- result &= validate_marketplacelistings(new_cat, cb, fix_hierarchy, depth + 1);
+ result &= validate_marketplacelistings(new_cat, cb, fix_hierarchy, depth + 1, notify_observers);
return result;
}
else
@@ -1740,7 +1750,10 @@ bool validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_
// Next type
update_marketplace_category(parent_uuid);
update_marketplace_category(folder_uuid);
- gInventory.notifyObservers();
+ if (notify_observers)
+ {
+ gInventory.notifyObservers();
+ }
items_vector_it++;
}
}
@@ -1754,7 +1767,7 @@ bool validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_
{
LLViewerInventoryCategory * viewer_cat = (LLViewerInventoryCategory *) (*iter);
gInventory.changeCategoryParent(viewer_cat, parent_uuid, false);
- result &= validate_marketplacelistings(viewer_cat, cb, fix_hierarchy, depth);
+ result &= validate_marketplacelistings(viewer_cat, cb, fix_hierarchy, depth, false);
}
}
}
@@ -1826,7 +1839,10 @@ bool validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_
cb(message,depth,LLError::LEVEL_WARN);
}
gInventory.removeCategory(cat->getUUID());
- gInventory.notifyObservers();
+ if (notify_observers)
+ {
+ gInventory.notifyObservers();
+ }
return result && !has_bad_items;
}
}
@@ -1840,11 +1856,14 @@ bool validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_
for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++)
{
LLInventoryCategory* category = *iter;
- result &= validate_marketplacelistings(category, cb, fix_hierarchy, depth + 1);
+ result &= validate_marketplacelistings(category, cb, fix_hierarchy, depth + 1, false);
}
update_marketplace_category(cat->getUUID(), true, true);
- gInventory.notifyObservers();
+ if (notify_observers)
+ {
+ gInventory.notifyObservers();
+ }
return result && !has_bad_items;
}
@@ -2583,8 +2602,67 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root
}
std::set<LLUUID> selected_uuid_set = LLAvatarActions::getInventorySelectedUUIDs();
+
+ // copy list of applicable items into a vector for bulk handling
uuid_vec_t ids;
- std::copy(selected_uuid_set.begin(), selected_uuid_set.end(), std::back_inserter(ids));
+ if (action == "wear" || action == "wear_add")
+ {
+ const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+ const LLUUID mp_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
+ std::copy_if(selected_uuid_set.begin(),
+ selected_uuid_set.end(),
+ std::back_inserter(ids),
+ [trash_id, mp_id](LLUUID id)
+ {
+ if (get_is_item_worn(id)
+ || LLAppearanceMgr::instance().getIsInCOF(id)
+ || gInventory.isObjectDescendentOf(id, trash_id))
+ {
+ return false;
+ }
+ if (mp_id.notNull() && gInventory.isObjectDescendentOf(id, mp_id))
+ {
+ return false;
+ }
+ LLInventoryObject* obj = (LLInventoryObject*)gInventory.getObject(id);
+ if (!obj)
+ {
+ return false;
+ }
+ if (obj->getIsLinkType() && gInventory.isObjectDescendentOf(obj->getLinkedUUID(), trash_id))
+ {
+ return false;
+ }
+ if (obj->getIsLinkType() && LLAssetType::lookupIsLinkType(obj->getType()))
+ {
+ // missing
+ return false;
+ }
+ return true;
+ }
+ );
+ }
+ else if (isRemoveAction(action))
+ {
+ std::copy_if(selected_uuid_set.begin(),
+ selected_uuid_set.end(),
+ std::back_inserter(ids),
+ [](LLUUID id)
+ {
+ return get_is_item_worn(id);
+ }
+ );
+ }
+ else
+ {
+ for (std::set<LLFolderViewItem*>::iterator it = selected_items.begin(), end_it = selected_items.end();
+ it != end_it;
+ ++it)
+ {
+ ids.push_back(static_cast<LLFolderViewModelItemInventory*>((*it)->getViewModelItem())->getUUID());
+ }
+ }
+
// Check for actions that get handled in bulk
if (action == "wear")
{
@@ -2643,7 +2721,7 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root
}
else if ("ungroup_folder_items" == action)
{
- if (selected_uuid_set.size() == 1)
+ if (ids.size() == 1)
{
LLInventoryCategory* inv_cat = gInventory.getCategory(*ids.begin());
if (!inv_cat || LLFolderType::lookupIsProtectedType(inv_cat->getPreferredType()))