summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorybridge.cpp
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2010-02-04 18:38:47 -0500
committerLoren Shih <seraph@lindenlab.com>2010-02-04 18:38:47 -0500
commit14d77a36d4392cd51a0887d957905ce4c532ba38 (patch)
tree9dcb08f0ea27a8f7f63a02580ec49ae295342d8a /indra/newview/llinventorybridge.cpp
parentc25915b39eda279306b8273da4c8ec60fcccb822 (diff)
EXT-4993 : Deleting an item from the COF in Inventory Floater keeps it worn
EXT-4997 : Centralize right-click menu options for delete/remove link EXT-4998 : Automatically reject double separators from right click menu Disabled/hid delete button from COF right-click menu, also means that trash icon is disabled. Added generalized function to remove consecutive separators from right-click menu. Made a minor cosmetic change to have all code duplication for adding "delete" menu item instead call a common function.
Diffstat (limited to 'indra/newview/llinventorybridge.cpp')
-rw-r--r--indra/newview/llinventorybridge.cpp77
1 files changed, 50 insertions, 27 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index c1259aa89a..f6089f3533 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -181,10 +181,14 @@ BOOL LLInvFVBridge::isItemRemovable() const
{
return FALSE;
}
+
+ // Can't delete an item that's in the library.
if(!model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID()))
{
return FALSE;
}
+
+ // Disable delete from COF folder; have users explicitly choose "detach/take off".
if (LLAppearanceManager::instance().getIsProtectedCOFItem(mUUID))
{
return FALSE;
@@ -466,6 +470,8 @@ void hide_context_entries(LLMenuGL& menu,
{
const LLView::child_list_t *list = menu.getChildList();
+ BOOL is_previous_entry_separator = FALSE;
+
LLView::child_list_t::const_iterator itor;
for (itor = list->begin(); itor != list->end(); ++itor)
{
@@ -488,6 +494,17 @@ void hide_context_entries(LLMenuGL& menu,
found = true;
}
}
+
+ // Don't allow multiple separators in a row (e.g. such as if there are no items
+ // between two separators).
+ if (found)
+ {
+ const BOOL is_entry_separator = (dynamic_cast<LLMenuItemSeparatorGL *>(*itor) != NULL);
+ if (is_entry_separator && is_previous_entry_separator)
+ found = false;
+ is_previous_entry_separator = is_entry_separator;
+ }
+
if (!found)
{
(*itor)->setVisible(FALSE);
@@ -582,20 +599,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
items.push_back(std::string("Paste Separator"));
- // "Remove link" and "Delete" are the same operation.
- if (obj && obj->getIsLinkType() && !get_is_item_worn(mUUID))
- {
- items.push_back(std::string("Remove Link"));
- }
- else
- {
- items.push_back(std::string("Delete"));
- }
-
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Delete"));
- }
+ addDeleteContextMenuOptions(items, disabled_items);
// If multiple items are selected, disable properties (if it exists).
if ((flags & FIRST_SELECTED_ITEM) == 0)
@@ -643,6 +647,32 @@ void LLInvFVBridge::addTrashContextMenuOptions(menuentry_vec_t &items,
items.push_back(std::string("Restore Item"));
}
+void LLInvFVBridge::addDeleteContextMenuOptions(menuentry_vec_t &items,
+ menuentry_vec_t &disabled_items)
+{
+ // Don't allow delete as a direct option from COF folder.
+ if (isCOFFolder())
+ {
+ return;
+ }
+
+ const LLInventoryObject *obj = getInventoryObject();
+
+ // "Remove link" and "Delete" are the same operation.
+ if (obj && obj->getIsLinkType() && !get_is_item_worn(mUUID))
+ {
+ items.push_back(std::string("Remove Link"));
+ }
+ else
+ {
+ items.push_back(std::string("Delete"));
+ }
+
+ if (!isItemRemovable())
+ {
+ disabled_items.push_back(std::string("Delete"));
+ }
+}
// *TODO: remove this
BOOL LLInvFVBridge::startDrag(EDragAndDropType* type, LLUUID* id) const
@@ -2477,7 +2507,7 @@ void LLFolderBridge::folderOptionsMenu()
if (is_sidepanel)
{
mItems.push_back("Rename");
- mItems.push_back("Delete");
+ addDeleteContextMenuOptions(mItems, disabled_items);
}
// Only enable calling-card related options for non-system folders.
@@ -2647,11 +2677,11 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
else
{
// Want some but not all of the items from getClipboardEntries for outfits.
- if (cat && cat->getPreferredType()==LLFolderType::FT_OUTFIT)
+ if (cat && (cat->getPreferredType() == LLFolderType::FT_OUTFIT))
{
mItems.push_back(std::string("Rename"));
- mItems.push_back(std::string("Delete"));
+ addDeleteContextMenuOptions(mItems, mDisabledItems);
// EXT-4030: disallow deletion of currently worn outfit
const LLViewerInventoryItem *base_outfit_link = LLAppearanceManager::instance().getBaseOutfitLink();
if (base_outfit_link && (cat == base_outfit_link->getLinkedCategory()))
@@ -4190,6 +4220,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
if( get_is_item_worn( mUUID ) )
{
+ items.push_back(std::string("Attach Separator"));
items.push_back(std::string("Detach From Yourself"));
}
else if (!isItemInTrash() && !isLinkedObjectInTrash() && !isLinkedObjectMissing())
@@ -5281,11 +5312,7 @@ void LLLinkItemBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
else
{
items.push_back(std::string("Properties"));
- items.push_back(std::string("Delete"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Delete"));
- }
+ addDeleteContextMenuOptions(items, disabled_items);
}
hide_context_entries(menu, items, disabled_items);
}
@@ -5326,11 +5353,7 @@ void LLLinkFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
else
{
items.push_back(std::string("Find Original"));
- items.push_back(std::string("Delete"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Delete"));
- }
+ addDeleteContextMenuOptions(items, disabled_items);
}
hide_context_entries(menu, items, disabled_items);
}