From 126bfa4877303b47abbc99f09c09a931c20cbd3b Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Fri, 31 Mar 2023 15:23:11 +0300 Subject: SL-19379 WIP fix for displaying folder link items, added correct action for 'paste as link' --- indra/newview/llinventorygallery.cpp | 36 +++++++++++++++++++------------- indra/newview/llinventorygallerymenu.cpp | 30 ++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 8c49cd5a4b..499d51c431 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -222,6 +222,9 @@ void LLInventoryGallery::updateRootFolder() } } + const LLUUID cof = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); + mCategoriesObserver->addCategory(cof, boost::bind(&LLInventoryGallery::onCOFChanged, this)); + if (!mGalleryCreated) { initGallery(); @@ -243,9 +246,6 @@ void LLInventoryGallery::initGallery() } reArrangeRows(); mGalleryCreated = true; - - const LLUUID cof = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); - mCategoriesObserver->addCategory(cof, boost::bind(&LLInventoryGallery::onCOFChanged, this)); } } @@ -646,7 +646,14 @@ void LLInventoryGallery::updateAddedItem(LLUUID item_id) LLInventoryType::EType inventory_type(LLInventoryType::IT_CATEGORY); U32 misc_flags = 0; bool is_worn = false; - if (LLAssetType::AT_CATEGORY == obj->getType()) + LLInventoryItem* inv_item = gInventory.getItem(item_id); + if (inv_item) + { + inventory_type = inv_item->getInventoryType(); + misc_flags = inv_item->getFlags(); + is_worn = LLAppearanceMgr::instance().isLinkedInCOF(item_id); + } + else if (LLAssetType::AT_CATEGORY == obj->getType()) { name = get_localized_folder_name(item_id); if(thumbnail_id.isNull()) @@ -654,16 +661,6 @@ void LLInventoryGallery::updateAddedItem(LLUUID item_id) thumbnail_id = getOutfitImageID(item_id); } } - else - { - LLInventoryItem* inv_item = gInventory.getItem(item_id); - if (inv_item) - { - inventory_type = inv_item->getInventoryType(); - misc_flags = inv_item->getFlags(); - is_worn = LLAppearanceMgr::instance().isLinkedInCOF(item_id); - } - } LLInventoryGalleryItem* item = buildGalleryItem(name, item_id, obj->getType(), thumbnail_id, inventory_type, misc_flags, obj->getIsLinkType(), is_worn); mItemMap.insert(LLInventoryGallery::gallery_item_map_t::value_type(item_id, item)); @@ -1049,7 +1046,16 @@ void LLInventoryGalleryItem::setType(LLAssetType::EType type, LLInventoryType::E if(mIsFolder) { mSortGroup = SG_NORMAL_FOLDER; - LLViewerInventoryCategory * cat = gInventory.getCategory(mUUID); + LLUUID folder_id = mUUID; + if(mIsLink) + { + LLInventoryObject* obj = gInventory.getObject(mUUID); + if (obj) + { + folder_id = obj->getLinkedUUID(); + } + } + LLViewerInventoryCategory* cat = gInventory.getCategory(folder_id); if (cat) { LLFolderType::EType preferred_type = cat->getPreferredType(); diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 21f7b06534..e91ec78730 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -250,9 +250,35 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } } } - else if ("paste_as_link" == action) + else if ("paste_link" == action) { - link_inventory_object(selected_id, obj, LLPointer(NULL)); + const LLUUID ¤t_outfit_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); + const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); + const LLUUID &my_outifts_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + + const BOOL move_is_into_current_outfit = (selected_id == current_outfit_id); + const BOOL move_is_into_my_outfits = (selected_id == my_outifts_id) || gInventory.isObjectDescendentOf(selected_id, my_outifts_id); + const BOOL move_is_into_marketplacelistings = gInventory.isObjectDescendentOf(selected_id, marketplacelistings_id); + + if (move_is_into_marketplacelistings || move_is_into_current_outfit || move_is_into_my_outfits) + { + return; + } + + std::vector objects; + LLClipboard::instance().pasteFromClipboard(objects); + for (std::vector::const_iterator iter = objects.begin(); + iter != objects.end(); + ++iter) + { + const LLUUID &object_id = (*iter); + if (LLConstPointer link_obj = gInventory.getObject(object_id)) + { + link_inventory_object(selected_id, link_obj, LLPointer(NULL)); + } + } + + LLClipboard::instance().setCutMode(false); } else if ("rename" == action) { -- cgit v1.2.3