diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-06-09 22:04:52 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-06-09 22:04:52 +0300 |
commit | 5c6a2779c498e69e36276700283ccfb4bdbfd438 (patch) | |
tree | 63b64b5468d7e0b201d4d72fa18f56691db4f2f6 /indra | |
parent | aede902040625b145d36812a3ef29e7677cb1154 (diff) |
SL-19826 Pasting folders in Single folder should highlight pasted folder
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 30 | ||||
-rw-r--r-- | indra/newview/llinventoryfunctions.h | 1 | ||||
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 150 | ||||
-rw-r--r-- | indra/newview/llinventorygallery.h | 2 | ||||
-rw-r--r-- | indra/newview/llinventorygallerymenu.cpp | 97 |
5 files changed, 152 insertions, 128 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 0b024536ae..034488c011 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -401,14 +401,32 @@ void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::s } void copy_inventory_category(LLInventoryModel* model, - LLViewerInventoryCategory* cat, - const LLUUID& parent_id, - const LLUUID& root_copy_id, - bool move_no_copy_items ) + LLViewerInventoryCategory* cat, + const LLUUID& parent_id, + const LLUUID& root_copy_id, + bool move_no_copy_items) +{ + // Create the initial folder + inventory_func_type func = [model, cat, root_copy_id, move_no_copy_items](const LLUUID& new_id) + { + copy_inventory_category_content(new_id, model, cat, root_copy_id, move_no_copy_items); + }; + gInventory.createNewCategory(parent_id, LLFolderType::FT_NONE, cat->getName(), func, cat->getThumbnailUUID()); +} + +void copy_inventory_category(LLInventoryModel* model, + LLViewerInventoryCategory* cat, + const LLUUID& parent_id, + const LLUUID& root_copy_id, + bool move_no_copy_items, + inventory_func_type callback) { // Create the initial folder - // D567 needs to handle new fields - inventory_func_type func = boost::bind(©_inventory_category_content, _1, model, cat, root_copy_id, move_no_copy_items); + inventory_func_type func = [model, cat, root_copy_id, move_no_copy_items, callback](const LLUUID &new_id) + { + copy_inventory_category_content(new_id, model, cat, root_copy_id, move_no_copy_items); + callback(new_id); + }; gInventory.createNewCategory(parent_id, LLFolderType::FT_NONE, cat->getName(), func, cat->getThumbnailUUID()); } diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 914d9da620..f19cadaded 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -75,6 +75,7 @@ void update_all_marketplace_count(); void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name); void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& parent_id, const LLUUID& root_copy_id = LLUUID::null, bool move_no_copy_items = false); +void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& parent_id, const LLUUID& root_copy_id, bool move_no_copy_items, inventory_func_type callback); void copy_inventory_category_content(const LLUUID& new_cat_uuid, LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& root_copy_id, bool move_no_copy_items); diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 358b4e457a..412e9e9c0b 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -709,7 +709,9 @@ void LLInventoryGallery::onIdle(void* userdata) if (self->mItemToSelect.notNull()) { - self->changeItemSelection(self->mItemToSelect, true); + LLUUID item_to_select = self->mItemToSelect; + self->mItemToSelect = LLUUID::null; + self->changeItemSelection(item_to_select, true); } if (self->mItemToSelect.isNull()) @@ -879,12 +881,14 @@ void LLInventoryGallery::onThumbnailAdded(LLUUID item_id) BOOL LLInventoryGallery::handleRightMouseDown(S32 x, S32 y, MASK mask) { - if(mItemMap[mSelectedItemID]) + LLUUID old_selection = mSelectedItemID; + BOOL res = LLPanel::handleRightMouseDown(x, y, mask); + if (!res) { - mItemMap[mSelectedItemID]->setFocus(false); + clearSelection(); + mItemMap[old_selection]->setFocus(false); } - clearSelection(); - BOOL res = LLPanel::handleRightMouseDown(x, y, mask); + if (mSelectedItemID.isNull()) { if (mInventoryGalleryMenu && mFolderID.notNull()) @@ -1125,24 +1129,30 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_ mItemToSelect = item_id; return; } - if (mSelectedItemID != item_id) + if (mSelectedItemID == item_id) { - if (mItemMap[mSelectedItemID]) - { - mItemMap[mSelectedItemID]->setSelected(FALSE); - } - if (mItemMap[item_id]) - { - mItemMap[item_id]->setSelected(TRUE); - } - mSelectedItemID = item_id; - signalSelectionItemID(item_id); + return; + } + if (mNeedsArrange && item_id.notNull() && scroll_to_selection) + { + mItemToSelect = item_id; + return; + } - mItemToSelect = LLUUID::null; - if(scroll_to_selection) - { - scrollToShowItem(mSelectedItemID); - } + if (mItemMap[mSelectedItemID]) + { + mItemMap[mSelectedItemID]->setSelected(FALSE); + } + if (mItemMap[item_id]) + { + mItemMap[item_id]->setSelected(TRUE); + } + mSelectedItemID = item_id; + signalSelectionItemID(item_id); + + if (scroll_to_selection) + { + scrollToShowItem(mSelectedItemID); } } @@ -1241,6 +1251,11 @@ BOOL LLInventoryGallery::canCut() const void LLInventoryGallery::paste() { + if (!LLClipboard::instance().hasContents()) + { + return; + } + const LLUUID& marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); if (gInventory.isObjectDescendentOf(mSelectedItemID, marketplacelistings_id)) { @@ -1254,6 +1269,20 @@ void LLInventoryGallery::paste() std::vector<LLUUID> objects; LLClipboard::instance().pasteFromClipboard(objects); + + LLHandle<LLPanel> handle = getHandle(); + std::function <void(const LLUUID)> on_copy_callback = [handle](const LLUUID& inv_item) + { + LLInventoryGallery* panel = (LLInventoryGallery*)handle.get(); + if (panel) + { + // Scroll to pasted item and highlight it + // Should it only highlight the last one? + panel->changeItemSelection(inv_item, true); + } + }; + LLPointer<LLInventoryCallback> cb = new LLBoostFuncInventoryCallback(on_copy_callback); + for (std::vector<LLUUID>::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) { const LLUUID& item_id = (*iter); @@ -1268,10 +1297,12 @@ void LLInventoryGallery::paste() if (is_cut_mode) { gInventory.changeCategoryParent(cat, dest, false); + // Don't select immediately, wait for item to arrive + mItemToSelect = item_id; } else { - copy_inventory_category(&gInventory, cat, dest); + copy_inventory_category(&gInventory, cat, dest, LLUUID::null, false, on_copy_callback); } } else @@ -1282,13 +1313,14 @@ void LLInventoryGallery::paste() if (is_cut_mode) { gInventory.changeItemParent(item, dest, false); + // Don't select immediately, wait for item to arrive + mItemToSelect = item_id; } else { if (item->getIsLinkType()) { - link_inventory_object(dest, item_id, - LLPointer<LLInventoryCallback>(NULL)); + link_inventory_object(dest, item_id, cb); } else { @@ -1298,13 +1330,13 @@ void LLInventoryGallery::paste() item->getUUID(), dest, std::string(), - LLPointer<LLInventoryCallback>(NULL)); + cb); } } } } } - // todo: scroll to item on arrival + LLClipboard::instance().setCutMode(false); } @@ -1379,6 +1411,66 @@ void LLInventoryGallery::deleteSelection() LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGallery::onDelete, _1, _2, mSelectedItemID)); } +void LLInventoryGallery::pasteAsLink() +{ + if (!LLClipboard::instance().hasContents()) + { + return; + } + + const LLUUID& current_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); + + LLUUID dest; + LLInventoryObject* obj = gInventory.getObject(mSelectedItemID); + if (obj && obj->getType() == LLAssetType::AT_CATEGORY) + { + dest = mSelectedItemID; + } + else + { + dest = mFolderID; + } + + const BOOL move_is_into_current_outfit = (dest == current_outfit_id); + const BOOL move_is_into_my_outfits = (dest == my_outifts_id) || gInventory.isObjectDescendentOf(dest, my_outifts_id); + const BOOL move_is_into_marketplacelistings = gInventory.isObjectDescendentOf(dest, marketplacelistings_id); + + if (move_is_into_marketplacelistings || move_is_into_current_outfit || move_is_into_my_outfits) + { + return; + } + std::vector<LLUUID> objects; + LLClipboard::instance().pasteFromClipboard(objects); + + LLHandle<LLPanel> handle = getHandle(); + std::function <void(const LLUUID)> on_link_callback = [handle](const LLUUID& inv_item) + { + LLInventoryGallery *panel = (LLInventoryGallery*)handle.get(); + if (panel) + { + // Scroll to pasted item and highlight it + // Should it only highlight the last one? + panel->changeItemSelection(inv_item, true); + } + }; + LLPointer<LLInventoryCallback> cb = new LLBoostFuncInventoryCallback(on_link_callback); + + for (std::vector<LLUUID>::const_iterator iter = objects.begin(); + iter != objects.end(); + ++iter) + { + const LLUUID& object_id = (*iter); + if (LLConstPointer<LLInventoryObject> link_obj = gInventory.getObject(object_id)) + { + link_inventory_object(dest, link_obj, cb); + } + } + + LLClipboard::instance().setCutMode(false); +} + void LLInventoryGallery::claimEditHandler() { gEditMenuHandler = this; @@ -1970,7 +2062,8 @@ BOOL LLInventoryGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) setFocus(TRUE); mGallery->claimEditHandler(); - return LLUICtrl::handleRightMouseDown(x, y, mask); + LLUICtrl::handleRightMouseDown(x, y, mask); + return TRUE; } BOOL LLInventoryGalleryItem::handleMouseUp(S32 x, S32 y, MASK mask) @@ -2238,6 +2331,7 @@ BOOL LLInventoryGallery::baseHandleDragAndDrop(LLUUID dest_id, BOOL drop, accepted = dragItemIntoFolder(dest_id, inv_item, drop, tooltip_msg, true); if (accepted && drop) { + // Don't select immediately, wait for item to arrive mItemToSelect = inv_item->getUUID(); } break; @@ -2257,7 +2351,7 @@ BOOL LLInventoryGallery::baseHandleDragAndDrop(LLUUID dest_id, BOOL drop, { accepted = dragItemIntoFolder(dest_id, inv_item, drop, tooltip_msg, TRUE); } - if (accepted && drop) + if (accepted && drop && inv_item) { mItemToSelect = inv_item->getUUID(); } diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h index 3797b9bc61..e71e2eddcd 100644 --- a/indra/newview/llinventorygallery.h +++ b/indra/newview/llinventorygallery.h @@ -149,8 +149,10 @@ public: void paste() override; BOOL canPaste() const override; + // Copy & paste & delete static void onDelete(const LLSD& notification, const LLSD& response, const LLUUID& selected_id); void deleteSelection(); + void pasteAsLink(); void claimEditHandler(); static bool isItemCopyable(const LLUUID & item_id); diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 54b9294ce1..68ead64839 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -71,8 +71,6 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU LLInventoryObject* obj = gInventory.getObject(selected_id); if(!obj) return; - bool is_folder = (obj->getType() == LLAssetType::AT_CATEGORY); - if ("open_selected_folder" == action) { mGallery->setRootFolder(selected_id); @@ -141,72 +139,9 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("paste" == action) { + if (mGallery->canPaste()) { - const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); - if(gInventory.isObjectDescendentOf(selected_id, marketplacelistings_id)) - { - return; - } - - bool is_cut_mode = (LLClipboard::instance().isCutMode()); - { - LLUUID dest = is_folder ? selected_id : obj->getParentUUID(); - - std::vector<LLUUID> objects; - LLClipboard::instance().pasteFromClipboard(objects); - for (std::vector<LLUUID>::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) - { - const LLUUID& item_id = (*iter); - if(gInventory.isObjectDescendentOf(item_id, marketplacelistings_id) && (LLMarketplaceData::instance().isInActiveFolder(item_id) || - LLMarketplaceData::instance().isListedAndActive(item_id))) - { - return; - } - LLViewerInventoryCategory* cat = gInventory.getCategory(item_id); - if (cat) - { - if(is_cut_mode) - { - gInventory.changeCategoryParent(cat, dest, false); - } - else - { - copy_inventory_category(&gInventory, cat, dest); - } - } - else - { - LLViewerInventoryItem* item = gInventory.getItem(item_id); - if (item) - { - if(is_cut_mode) - { - gInventory.changeItemParent(item, dest, false); - } - else - { - if (item->getIsLinkType()) - { - link_inventory_object(dest, item_id, - LLPointer<LLInventoryCallback>(NULL)); - } - else - { - copy_inventory_item( - gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - dest, - std::string(), - LLPointer<LLInventoryCallback>(NULL)); - } - } - } - } - } - LLClipboard::instance().setCutMode(false); - } - + mGallery->paste(); } } else if ("delete" == action) @@ -222,33 +157,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("paste_link" == action) { - 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; - } - LLUUID dest = is_folder ? selected_id : obj->getParentUUID(); - std::vector<LLUUID> objects; - LLClipboard::instance().pasteFromClipboard(objects); - for (std::vector<LLUUID>::const_iterator iter = objects.begin(); - iter != objects.end(); - ++iter) - { - const LLUUID &object_id = (*iter); - if (LLConstPointer<LLInventoryObject> link_obj = gInventory.getObject(object_id)) - { - link_inventory_object(dest, link_obj, LLPointer<LLInventoryCallback>(NULL)); - } - } - - LLClipboard::instance().setCutMode(false); + mGallery->pasteAsLink(); } else if ("rename" == action) { |