diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-10-17 01:17:51 +0300 |
---|---|---|
committer | akleshchev <117672381+akleshchev@users.noreply.github.com> | 2023-10-17 21:26:39 +0300 |
commit | 7d82ee8075e81a6d3640103b68e98a6a2cbbe623 (patch) | |
tree | b51e458810b38149f4a7d13a75406efb5ff000f8 /indra | |
parent | ce83f77e7a5f32ac00b0a563fcf68ff98957f684 (diff) |
SL-20232 Allow deletion of folders with worn content in gallery view #4
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 86 | ||||
-rw-r--r-- | indra/newview/llinventorygallerymenu.cpp | 7 |
2 files changed, 73 insertions, 20 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 23a00e2e51..058bbde8b9 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1866,29 +1866,49 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response { bool has_worn = notification["payload"]["has_worn"].asBoolean(); uuid_vec_t worn; - for (const LLUUID& id : selected_ids) + uuid_vec_t deletion_list; + for (const LLUUID& obj_id : selected_ids) { - LLInventoryObject* obj = gInventory.getObject(id); - if (!obj) + LLViewerInventoryCategory* cat = gInventory.getCategory(obj_id); + if (cat) { - return; - } - if (obj->getType() == LLAssetType::AT_CATEGORY) - { - if (get_is_category_removable(&gInventory, id)) + bool cat_has_worn = false; + if (has_worn) { - gInventory.removeCategory(id); + LLInventoryModel::cat_array_t categories; + LLInventoryModel::item_array_t items; + + gInventory.collectDescendents(obj_id, categories, items, FALSE); + + for (LLInventoryModel::item_array_t::value_type& item : items) + { + if (get_is_item_worn(item)) + { + worn.push_back(item->getUUID()); + cat_has_worn = true; + } + } + } + if (cat_has_worn) + { + deletion_list.push_back(obj_id); + } + else + { + gInventory.removeCategory(obj_id); } } - else + LLViewerInventoryItem* item = gInventory.getItem(obj_id); + if (item) { - if (get_is_item_removable(&gInventory, id, true)) + if (has_worn && get_is_item_worn(item)) { - gInventory.removeItem(id); + worn.push_back(item->getUUID()); + deletion_list.push_back(item->getUUID()); } - else if (has_worn && get_is_item_worn(id)) + else { - worn.push_back(id); + gInventory.removeItem(obj_id); } } } @@ -1897,9 +1917,9 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response { // should fire once after every item gets detached LLAppearanceMgr::instance().removeItemsFromAvatar(worn, - [worn]() + [deletion_list]() { - for (const LLUUID& id : worn) + for (const LLUUID& id : deletion_list) { remove_inventory_item(id, NULL); } @@ -1914,10 +1934,40 @@ void LLInventoryGallery::deleteSelection() bool needs_replacement = false; for (const LLUUID& id : mSelectedItemIDs) { - if (get_is_item_worn(id)) + LLViewerInventoryCategory* cat = gInventory.getCategory(id); + if (cat) + { + LLInventoryModel::cat_array_t categories; + LLInventoryModel::item_array_t items; + + gInventory.collectDescendents(id, categories, items, FALSE); + + for (LLInventoryModel::item_array_t::value_type& item : items) + { + if (get_is_item_worn(item)) + { + has_worn = true; + LLWearableType::EType type = item->getWearableType(); + if (type == LLWearableType::WT_SHAPE + || type == LLWearableType::WT_SKIN + || type == LLWearableType::WT_HAIR + || type == LLWearableType::WT_EYES) + { + needs_replacement = true; + break; + } + } + } + if (needs_replacement) + { + break; + } + } + + LLViewerInventoryItem* item = gInventory.getItem(id); + if (item && get_is_item_worn(item)) { has_worn = true; - const LLViewerInventoryItem* item = gInventory.getItem(id); LLWearableType::EType type = item->getWearableType(); if (type == LLWearableType::WT_SHAPE || type == LLWearableType::WT_SKIN diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 49969e1a52..2bca33dec4 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -425,7 +425,6 @@ bool is_category_removable(const LLUUID &folder_id, bool check_worn) return true; } - void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* menu) { LLUUID selected_id = mUUIDs.front(); @@ -581,11 +580,15 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("Cut")); items.push_back(std::string("Delete")); - if(!is_category_removable(selected_id, true)) + if(!is_category_removable(selected_id, false)) { disabled_items.push_back(std::string("Delete")); disabled_items.push_back(std::string("Cut")); } + else if (!is_category_removable(selected_id, true)) + { + disabled_items.push_back(std::string("Cut")); + } if(!is_inbox) { |