summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorybridge.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventorybridge.cpp')
-rw-r--r--indra/newview/llinventorybridge.cpp261
1 files changed, 122 insertions, 139 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 1fd069f195..c024304f26 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;
@@ -461,11 +465,15 @@ BOOL LLInvFVBridge::isClipboardPasteableAsLink() const
}
void hide_context_entries(LLMenuGL& menu,
- const std::vector<std::string> &entries_to_show,
- const std::vector<std::string> &disabled_entries)
+ const menuentry_vec_t &entries_to_show,
+ const menuentry_vec_t &disabled_entries)
{
const LLView::child_list_t *list = menu.getChildList();
+ // For removing double separators or leading separator. Start at true so that
+ // if the first element is a separator, it will not be shown.
+ BOOL is_previous_entry_separator = TRUE;
+
LLView::child_list_t::const_iterator itor;
for (itor = list->begin(); itor != list->end(); ++itor)
{
@@ -480,7 +488,7 @@ void hide_context_entries(LLMenuGL& menu,
bool found = false;
- std::vector<std::string>::const_iterator itor2;
+ menuentry_vec_t::const_iterator itor2;
for (itor2 = entries_to_show.begin(); itor2 != entries_to_show.end(); ++itor2)
{
if (*itor2 == name)
@@ -488,6 +496,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);
@@ -508,8 +527,8 @@ void hide_context_entries(LLMenuGL& menu,
// Helper for commonly-used entries
void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
- std::vector<std::string> &items,
- std::vector<std::string> &disabled_items, U32 flags)
+ menuentry_vec_t &items,
+ menuentry_vec_t &disabled_items, U32 flags)
{
const LLInventoryObject *obj = getInventoryObject();
@@ -565,8 +584,12 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
}
}
- items.push_back(std::string("Paste"));
- if (!isClipboardPasteable() || (flags & FIRST_SELECTED_ITEM) == 0)
+ // Don't allow items to be pasted directly into the COF.
+ if (!isCOFFolder())
+ {
+ items.push_back(std::string("Paste"));
+ }
+ if (!isClipboardPasteable() || ((flags & FIRST_SELECTED_ITEM) == 0))
{
disabled_items.push_back(std::string("Paste"));
}
@@ -582,16 +605,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
items.push_back(std::string("Paste Separator"));
- if (obj && obj->getIsLinkType() && !get_is_item_worn(mUUID))
- {
- items.push_back(std::string("Remove Link"));
- }
-
- 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)
@@ -603,16 +617,11 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
lldebugs << "LLInvFVBridge::buildContextMenu()" << llendl;
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{
@@ -624,6 +633,53 @@ void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
hide_context_entries(menu, items, disabled_items);
}
+void LLInvFVBridge::addTrashContextMenuOptions(menuentry_vec_t &items,
+ menuentry_vec_t &disabled_items)
+{
+ const LLInventoryObject *obj = getInventoryObject();
+ if (obj && obj->getIsLinkType())
+ {
+ items.push_back(std::string("Find Original"));
+ if (isLinkedObjectMissing())
+ {
+ disabled_items.push_back(std::string("Find Original"));
+ }
+ }
+ items.push_back(std::string("Purge Item"));
+ if (!isItemRemovable())
+ {
+ disabled_items.push_back(std::string("Purge Item"));
+ }
+ 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
{
@@ -2439,7 +2495,7 @@ void LLFolderBridge::staticFolderOptionsMenu()
void LLFolderBridge::folderOptionsMenu()
{
- std::vector<std::string> disabled_items;
+ menuentry_vec_t disabled_items;
LLInventoryModel* model = getInventoryModel();
if(!model) return;
@@ -2457,7 +2513,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.
@@ -2572,7 +2628,7 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
lldebugs << "LLFolderBridge::buildContextMenu()" << llendl;
-// std::vector<std::string> disabled_items;
+// menuentry_vec_t disabled_items;
LLInventoryModel* model = getInventoryModel();
if(!model) return;
const LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH);
@@ -2589,17 +2645,11 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
// This is the trash.
mItems.push_back(std::string("Empty Trash"));
}
- else if(model->isObjectDescendentOf(mUUID, trash_id))
+ else if(isItemInTrash())
{
// This is a folder in the trash.
mItems.clear(); // clear any items that used to exist
- mItems.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- mDisabledItems.push_back(std::string("Purge Item"));
- }
-
- mItems.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(mItems, mDisabledItems);
}
else if(isAgentInventory()) // do not allow creating in library
{
@@ -2633,11 +2683,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()))
@@ -3206,17 +3256,11 @@ bool LLTextureBridge::canSaveTexture(void)
void LLTextureBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
lldebugs << "LLTextureBridge::buildContextMenu()" << llendl;
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{
@@ -3299,18 +3343,12 @@ void LLSoundBridge::openSoundPreview(void* which)
void LLSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
lldebugs << "LLSoundBridge::buildContextMenu()" << llendl;
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{
@@ -3347,19 +3385,13 @@ LLUIImagePtr LLLandmarkBridge::getIcon() const
void LLLandmarkBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
lldebugs << "LLLandmarkBridge::buildContextMenu()" << llendl;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{
@@ -3573,18 +3605,12 @@ void LLCallingCardBridge::openItem()
void LLCallingCardBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
lldebugs << "LLCallingCardBridge::buildContextMenu()" << llendl;
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{
@@ -3839,17 +3865,11 @@ BOOL LLGestureBridge::removeItem()
void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
lldebugs << "LLGestureBridge::buildContextMenu()" << llendl;
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{
@@ -3901,19 +3921,13 @@ LLUIImagePtr LLAnimationBridge::getIcon() const
void LLAnimationBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
lldebugs << "LLAnimationBridge::buildContextMenu()" << llendl;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{
@@ -4182,17 +4196,11 @@ static LLNotificationFunctorRegistration confirm_replace_attachment_rez_reg("Rep
void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{
@@ -4218,6 +4226,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())
@@ -4598,17 +4607,11 @@ void LLWearableBridge::openItem()
void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
lldebugs << "LLWearableBridge::buildContextMenu()" << llendl;
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
else
{ // FWIW, it looks like SUPPRESS_OPEN_ITEM is not set anywhere
@@ -5309,30 +5312,20 @@ void LLLinkItemBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
// *TODO: Translate
lldebugs << "LLLink::buildContextMenu()" << llendl;
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
items.push_back(std::string("Find Original"));
disabled_items.push_back(std::string("Find Original"));
if(isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
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);
}
@@ -5363,27 +5356,17 @@ void LLLinkFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
// *TODO: Translate
lldebugs << "LLLink::buildContextMenu()" << llendl;
- std::vector<std::string> items;
- std::vector<std::string> disabled_items;
+ menuentry_vec_t items;
+ menuentry_vec_t disabled_items;
- if(isItemInTrash())
+ if (isItemInTrash())
{
- items.push_back(std::string("Purge Item"));
- if (!isItemRemovable())
- {
- disabled_items.push_back(std::string("Purge Item"));
- }
-
- items.push_back(std::string("Restore Item"));
+ addTrashContextMenuOptions(items, disabled_items);
}
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);
}