From 7fa791280ac511de6c65d287e63301a3f4c22475 Mon Sep 17 00:00:00 2001 From: Beq Date: Fri, 28 Dec 2018 17:58:23 +0000 Subject: [PATCH] FIRE-17695 - Bulk delete links capability --- indra/newview/llfloaterlinkreplace.cpp | 145 +++++++++++++++--- indra/newview/llfloaterlinkreplace.h | 4 + .../default/xui/en/floater_linkreplace.xml | 31 +++- 3 files changed, 158 insertions(+), 22 deletions(-) diff --git a/indra/newview/llfloaterlinkreplace.cpp b/indra/newview/llfloaterlinkreplace.cpp index 10cce3bd22..d41e21375d 100644 --- a/indra/newview/llfloaterlinkreplace.cpp +++ b/indra/newview/llfloaterlinkreplace.cpp @@ -52,12 +52,16 @@ LLFloaterLinkReplace::~LLFloaterLinkReplace() BOOL LLFloaterLinkReplace::postBuild() { + childSetVisible("delete_text", false); // FIRE-17695 - Delete links capability mStartBtn = getChild("btn_start"); mStartBtn->setCommitCallback(boost::bind(&LLFloaterLinkReplace::onStartClicked, this)); mRefreshBtn = getChild("btn_refresh"); mRefreshBtn->setCommitCallback(boost::bind(&LLFloaterLinkReplace::checkEnableStart, this)); - + // FIRE-17695 - Delete links capability + mDeleteOnlyToggle = getChild("delete_links_only"); + mDeleteOnlyToggle->setCommitCallback(boost::bind(&LLFloaterLinkReplace::onDeleteOnlyToggle, this)); + // mSourceEditor = getChild("source_uuid_editor"); mTargetEditor = getChild("target_uuid_editor"); @@ -92,10 +96,38 @@ void LLFloaterLinkReplace::onSourceItemDrop(const LLUUID& source_item_id) void LLFloaterLinkReplace::onTargetItemDrop(const LLUUID& target_item_id) { - mTargetUUID = target_item_id; + // FIRE-17695 - option to bulk delete links. + //mTargetUUID = target_item_id; + //checkEnableStart(); + if (!mDeleteOnly) + { + mTargetUUID = target_item_id; + checkEnableStart(); + } + else + { + mTargetEditor->setItem(nullptr); + mTargetEditor->setText(getString("DeleteNotReplace")); + mTargetUUID = LLUUID::null; + } + // +} +// FIRE-17695 - Delete links capability +void LLFloaterLinkReplace::onDeleteOnlyToggle() +{ + auto enabled = mDeleteOnlyToggle->getValue().asBoolean(); + mTargetEditor->setEnabled(!enabled); + mTargetEditor->setVisible(!enabled); + childSetVisible("target_label", !enabled); + childSetVisible("delete_text", enabled); + mDeleteOnly = enabled; + if (mDeleteOnly){ + mTargetEditor->setItem(nullptr); + mTargetUUID = LLUUID::null; + } checkEnableStart(); } - +// void LLFloaterLinkReplace::updateFoundLinks() { LLInventoryModel::item_array_t items; @@ -123,20 +155,36 @@ void LLFloaterLinkReplace::checkEnableStart() { updateFoundLinks(); } + // FIRE-17695 - Delete links capability + // mStartBtn->setEnabled(mRemainingItems > 0 && mSourceUUID.notNull() && mTargetUUID.notNull() && mSourceUUID != mTargetUUID); + auto enable=bool{ mRemainingItems > 0 && ( + (mDeleteOnly && mSourceUUID.notNull() ) || + (mSourceUUID.notNull() && mTargetUUID.notNull() && mSourceUUID != mTargetUUID)) }; - mStartBtn->setEnabled(mRemainingItems > 0 && mSourceUUID.notNull() && mTargetUUID.notNull() && mSourceUUID != mTargetUUID); + mStartBtn->setEnabled(enable); + // } void LLFloaterLinkReplace::onStartClicked() { LL_INFOS() << "Starting inventory link replace" << LL_ENDL; - - if (mSourceUUID.isNull() || mTargetUUID.isNull()) + // FIRE-17695 - option to bulk delete links. + // if (mSourceUUID.isNull() || mTargetUUID.isNull()) + if (!mDeleteOnly && (mSourceUUID.isNull() || mTargetUUID.isNull())) + // { LL_WARNS() << "Cannot replace. Either source or target UUID is null." << LL_ENDL; return; } + // FIRE-17695 - option to bulk delete links. + if (!mDeleteOnly && mSourceUUID.isNull()) + { + LL_WARNS() << "Cannot delete links. Source UUID is null." << LL_ENDL; + return; + } + // + if (mSourceUUID == mTargetUUID) { LL_WARNS() << "Cannot replace. Source and target are identical." << LL_ENDL; @@ -154,8 +202,29 @@ void LLFloaterLinkReplace::onStartClicked() if (mRemainingInventoryItems.size() > 0) { + // FIRE-17695 - option to bulk delete links. + // LLViewerInventoryItem* target_item = gInventory.getItem(mTargetUUID); + //if (target_item) + //{ + // mRemainingItems = (U32)mRemainingInventoryItems.size(); + + // LLStringUtil::format_map_t args; + // args["NUM"] = llformat("%d", mRemainingItems); + // mStatusText->setText(getString("ItemsRemaining", args)); + + // mStartBtn->setEnabled(FALSE); + // mRefreshBtn->setEnabled(FALSE); + + // mEventTimer.start(); + // tick(); + //} + //else + //{ + // mStatusText->setText(getString("TargetNotFound")); + // LL_WARNS() << "Link replace target not found." << LL_ENDL; + //} LLViewerInventoryItem* target_item = gInventory.getItem(mTargetUUID); - if (target_item) + if (target_item || mDeleteOnly) { mRemainingItems = (U32)mRemainingInventoryItems.size(); @@ -174,6 +243,7 @@ void LLFloaterLinkReplace::onStartClicked() mStatusText->setText(getString("TargetNotFound")); LL_WARNS() << "Link replace target not found." << LL_ENDL; } + // } } @@ -307,26 +377,63 @@ void LLFloaterLinkReplace::processBatch(LLInventoryModel::item_array_t items) if (source_item->getParentUUID() != cof_folder_id) { + // FIRE-17695 bulk delete unwanted links + //bool is_outfit_folder = gInventory.isObjectDescendentOf(source_item->getParentUUID(), outfit_folder_id); + //// If either the new or old item in the COF is a wearable, we need to update wearable ordering after the link has been replaced + //bool needs_wearable_ordering_update = (is_outfit_folder && source_item->getType() == LLAssetType::AT_CLOTHING) || target_item->getType() == LLAssetType::AT_CLOTHING; + //// Other items in the COF need a description update (description of the actual link item must be empty) + //bool needs_description_update = is_outfit_folder && target_item->getType() != LLAssetType::AT_CLOTHING; + + //LL_DEBUGS() << "is_outfit_folder = " << (is_outfit_folder ? "true" : "false") << LL_NEWLINE + // << "needs_wearable_ordering_update = " << (needs_wearable_ordering_update ? "true" : "false") << LL_NEWLINE + // << "needs_description_update = " << (needs_description_update ? "true" : "false") << LL_ENDL; + + //LLInventoryObject::const_object_list_t obj_array; + //obj_array.push_back(LLConstPointer(target_item)); + //LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(&LLFloaterLinkReplace::linkCreatedCallback, + // getDerivedHandle(), + // source_item->getUUID(), + // target_item->getUUID(), + // needs_wearable_ordering_update, + // needs_description_update, + // (is_outfit_folder ? source_item->getParentUUID() : LLUUID::null) )); + //link_inventory_array(source_item->getParentUUID(), obj_array, cb); + bool is_outfit_folder = gInventory.isObjectDescendentOf(source_item->getParentUUID(), outfit_folder_id); // If either the new or old item in the COF is a wearable, we need to update wearable ordering after the link has been replaced - bool needs_wearable_ordering_update = (is_outfit_folder && source_item->getType() == LLAssetType::AT_CLOTHING) || target_item->getType() == LLAssetType::AT_CLOTHING; + bool needs_wearable_ordering_update = (is_outfit_folder && source_item->getType() == LLAssetType::AT_CLOTHING) || (!mDeleteOnly && target_item->getType() == LLAssetType::AT_CLOTHING); // Other items in the COF need a description update (description of the actual link item must be empty) - bool needs_description_update = is_outfit_folder && target_item->getType() != LLAssetType::AT_CLOTHING; + bool needs_description_update = !mDeleteOnly && is_outfit_folder && target_item->getType() != LLAssetType::AT_CLOTHING; LL_DEBUGS() << "is_outfit_folder = " << (is_outfit_folder ? "true" : "false") << LL_NEWLINE << "needs_wearable_ordering_update = " << (needs_wearable_ordering_update ? "true" : "false") << LL_NEWLINE << "needs_description_update = " << (needs_description_update ? "true" : "false") << LL_ENDL; - LLInventoryObject::const_object_list_t obj_array; - obj_array.push_back(LLConstPointer(target_item)); - LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(&LLFloaterLinkReplace::linkCreatedCallback, - getDerivedHandle(), - source_item->getUUID(), - target_item->getUUID(), - needs_wearable_ordering_update, - needs_description_update, - (is_outfit_folder ? source_item->getParentUUID() : LLUUID::null) )); - link_inventory_array(source_item->getParentUUID(), obj_array, cb); + if (!mDeleteOnly) + { + LLInventoryObject::const_object_list_t obj_array; + obj_array.push_back(LLConstPointer(target_item)); + LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(&LLFloaterLinkReplace::linkCreatedCallback, + getDerivedHandle(), + source_item->getUUID(), + target_item->getUUID(), + needs_wearable_ordering_update, + needs_description_update, + (is_outfit_folder ? source_item->getParentUUID() : LLUUID::null))); + link_inventory_array(source_item->getParentUUID(), obj_array, cb); + } + else + { + LLUUID outfit_update_folder_id = LLUUID::null; + if (needs_wearable_ordering_update) + { + outfit_update_folder_id = outfit_folder_id; + } + LLPointer cb = new LLBoostFuncInventoryCallback(boost::bind(&LLFloaterLinkReplace::itemRemovedCallback, getDerivedHandle(), outfit_update_folder_id)); + remove_inventory_object(source_item->getUUID(), cb); + LL_INFOS() << "Requested delete of " << source_item->getUUID() << LL_ENDL; + } + // } else { diff --git a/indra/newview/llfloaterlinkreplace.h b/indra/newview/llfloaterlinkreplace.h index dd5c301206..e10febd1cd 100644 --- a/indra/newview/llfloaterlinkreplace.h +++ b/indra/newview/llfloaterlinkreplace.h @@ -33,6 +33,7 @@ #include "lllineeditor.h" #include "llinventoryfunctions.h" #include "llviewerinventory.h" +#include "llcheckboxctrl.h" // FIRE-17695 - Delete links capability class LLButton; class LLTextBox; @@ -104,12 +105,14 @@ private: void onSourceItemDrop(const LLUUID& source_item_id); void onTargetItemDrop(const LLUUID& target_item_id); + void onDeleteOnlyToggle();// FIRE-17695 - Delete links capability LLInventoryLinkReplaceDropTarget* mSourceEditor; LLInventoryLinkReplaceDropTarget* mTargetEditor; LLButton* mStartBtn; LLButton* mRefreshBtn; LLTextBox* mStatusText; + LLCheckBoxCtrl* mDeleteOnlyToggle;// FIRE-17695 - Delete links capability LLUUID mSourceUUID; LLUUID mTargetUUID; @@ -117,6 +120,7 @@ private: U32 mBatchSize; LLInventoryModel::item_array_t mRemainingInventoryItems; + bool mDeleteOnly;// FIRE-17695 - Delete links capability }; #endif // LL_FLOATERLINKREPLACE_H diff --git a/indra/newview/skins/default/xui/en/floater_linkreplace.xml b/indra/newview/skins/default/xui/en/floater_linkreplace.xml index 83d4de8993..3651f678b8 100644 --- a/indra/newview/skins/default/xui/en/floater_linkreplace.xml +++ b/indra/newview/skins/default/xui/en/floater_linkreplace.xml @@ -5,7 +5,7 @@ positioning="centered" title="Replace Inventory Links" width="333" - height="130" + height="150" save_rect="true" can_minimize="true" can_close="true"> @@ -27,6 +27,9 @@ Finished replacing inventory links. + + No replacement. + + + Links to this item will be removed. + + top_delta="0"> New: + Ready...