diff options
author | Loren Shih <seraph@lindenlab.com> | 2010-05-07 13:44:03 -0400 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2010-05-07 13:44:03 -0400 |
commit | 183122bc1dae8832c3dd728bfe76144165a0d2d7 (patch) | |
tree | 81cb6ba53d87923afc5651cf9ce017d50013f57c /indra/newview/llinventorybridge.cpp | |
parent | de0773fcf73b9a1889366d3c3608e5775f7bb89d (diff) |
EXT-7269 : FIXED : Issue warning dialog when item is deleted that has links pointing to it
Warning now comes up if you try to delete an item that has any item links pointing to it (in memory). This assumes that the viewer actually knows about those links, which is true at least in 2.0 since links only appear in Outfits folders and this code causes those to be fetched into memory on startup.
Diffstat (limited to 'indra/newview/llinventorybridge.cpp')
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 228ab7ebd6..a979454938 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1405,13 +1405,56 @@ BOOL LLItemBridge::removeItem() { return FALSE; } + + // move it to the trash LLPreview::hide(mUUID, TRUE); LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; - const LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); + const LLUUID& trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); + LLViewerInventoryItem* item = getItem(); + if (!item) return FALSE; + + // Already in trash + if (model->isObjectDescendentOf(mUUID, trash_id)) return FALSE; + + LLNotification::Params params("ConfirmItemDeleteHasLinks"); + params.functor.function(boost::bind(&LLItemBridge::confirmRemoveItem, this, _1, _2)); + + if (!item->getIsLinkType()) + { + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + LLLinkedItemIDMatches is_linked_item_match(mUUID); + gInventory.collectDescendentsIf(gInventory.getRootFolderID(), + cat_array, + item_array, + LLInventoryModel::INCLUDE_TRASH, + is_linked_item_match); + U32 num_links = cat_array.size() + item_array.size(); + if (num_links > 0) + { + LLNotifications::instance().add(params); + return FALSE; + } + } + + LLNotifications::instance().forceResponse(params, 0); + return TRUE; +} + +BOOL LLItemBridge::confirmRemoveItem(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) return FALSE; + + LLInventoryModel* model = getInventoryModel(); + if (!model) return FALSE; + LLViewerInventoryItem* item = getItem(); + if (!item) return FALSE; + const LLUUID& trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); // if item is not already in trash if(item && !model->isObjectDescendentOf(mUUID, trash_id)) { @@ -1420,11 +1463,7 @@ BOOL LLItemBridge::removeItem() // delete was successful return TRUE; } - else - { - // tried to delete already item in trash (should purge?) - return FALSE; - } + return FALSE; } BOOL LLItemBridge::isItemCopyable() const |