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.cpp333
1 files changed, 196 insertions, 137 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index a6a5ecb8e7..d216872363 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -50,6 +50,8 @@
#include "llinventoryfunctions.h"
#include "llinventorymodel.h"
#include "llinventorypanel.h"
+#include "llnotifications.h"
+#include "llnotificationsutil.h"
#include "llpreviewanim.h"
#include "llpreviewgesture.h"
#include "llpreviewtexture.h"
@@ -62,6 +64,7 @@
#include "llviewerwindow.h"
#include "llvoavatarself.h"
#include "llwearablelist.h"
+#include "llpaneloutfitsinventory.h"
using namespace LLOldEvents;
@@ -171,16 +174,33 @@ time_t LLInvFVBridge::getCreationDate() const
return 0;
}
-// Can be destoryed (or moved to trash)
+// Can be destroyed (or moved to trash)
BOOL LLInvFVBridge::isItemRemovable()
{
- LLInventoryModel* model = getInventoryModel();
- if(!model) return FALSE;
- if(model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID()))
+ const LLInventoryModel* model = getInventoryModel();
+ if(!model)
+ {
+ return FALSE;
+ }
+ if(!model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID()))
+ {
+ return FALSE;
+ }
+ const LLInventoryObject *obj = model->getItem(mUUID);
+ if (obj && obj->getIsLinkType())
{
return TRUE;
}
- return FALSE;
+ if (gAgentWearables.isWearingItem(mUUID))
+ {
+ return FALSE;
+ }
+ const LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
+ if (avatar && avatar->isWearingAttachment(mUUID))
+ {
+ return FALSE;
+ }
+ return TRUE;
}
// Can be moved to another folder
@@ -475,6 +495,7 @@ void hide_context_entries(LLMenuGL& menu,
}
else
{
+ (*itor)->setVisible(TRUE);
for (itor2 = disabled_entries.begin(); itor2 != disabled_entries.end(); ++itor2)
{
if (*itor2 == name)
@@ -491,28 +512,39 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
std::vector<std::string> &items,
std::vector<std::string> &disabled_items, U32 flags)
{
- items.push_back(std::string("Rename"));
- if (!isItemRenameable() || (flags & FIRST_SELECTED_ITEM) == 0)
- {
- disabled_items.push_back(std::string("Rename"));
- }
-
- if (show_asset_id)
+ const LLInventoryObject *obj = getInventoryObject();
+ if (obj && obj->getIsLinkType())
{
- items.push_back(std::string("Copy Asset UUID"));
- if ( (! ( isItemPermissive() || gAgent.isGodlike() ) )
- || (flags & FIRST_SELECTED_ITEM) == 0)
+ items.push_back(std::string("Find Original"));
+ if (LLAssetType::lookupIsLinkType(obj->getType()))
{
- disabled_items.push_back(std::string("Copy Asset UUID"));
+ disabled_items.push_back(std::string("Find Original"));
}
}
-
- items.push_back(std::string("Copy Separator"));
-
- items.push_back(std::string("Copy"));
- if (!isItemCopyable())
+ else
{
- disabled_items.push_back(std::string("Copy"));
+ items.push_back(std::string("Rename"));
+ if (!isItemRenameable() || (flags & FIRST_SELECTED_ITEM) == 0)
+ {
+ disabled_items.push_back(std::string("Rename"));
+ }
+
+ if (show_asset_id)
+ {
+ items.push_back(std::string("Copy Asset UUID"));
+ if ( (! ( isItemPermissive() || gAgent.isGodlike() ) )
+ || (flags & FIRST_SELECTED_ITEM) == 0)
+ {
+ disabled_items.push_back(std::string("Copy Asset UUID"));
+ }
+ }
+ items.push_back(std::string("Copy Separator"));
+
+ items.push_back(std::string("Copy"));
+ if (!isItemCopyable())
+ {
+ disabled_items.push_back(std::string("Copy"));
+ }
}
items.push_back(std::string("Paste"));
@@ -1303,6 +1335,23 @@ void LLFolderBridge::selectItem()
}
+// Iterate through a folder's children to determine if
+// all the children are removable.
+class LLIsItemRemovable : public LLFolderViewFunctor
+{
+public:
+ LLIsItemRemovable() : mPassed(TRUE) {}
+ virtual void doFolder(LLFolderViewFolder* folder)
+ {
+ mPassed &= folder->getListener()->isItemRemovable();
+ }
+ virtual void doItem(LLFolderViewItem* item)
+ {
+ mPassed &= item->getListener()->isItemRemovable();
+ }
+ BOOL mPassed;
+};
+
// Can be destroyed (or moved to trash)
BOOL LLFolderBridge::isItemRemovable()
{
@@ -1328,47 +1377,25 @@ BOOL LLFolderBridge::isItemRemovable()
{
return FALSE;
}
-
+ // Allow protected types to be removed, but issue a warning.
+ /*
if(LLFolderType::lookupIsProtectedType(category->getPreferredType()))
{
return FALSE;
}
+ */
- LLInventoryModel::cat_array_t descendent_categories;
- LLInventoryModel::item_array_t descendent_items;
- gInventory.collectDescendents( mUUID, descendent_categories, descendent_items, FALSE );
-
- S32 i;
- for( i = 0; i < descendent_categories.count(); i++ )
+ LLInventoryPanel* panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get());
+ LLFolderViewFolder* folderp = dynamic_cast<LLFolderViewFolder*>(panel ? panel->getRootFolder()->getItemByID(mUUID) : NULL);
+ if (folderp)
{
- LLInventoryCategory* category = descendent_categories[i];
- if(LLFolderType::lookupIsProtectedType(category->getPreferredType()))
+ LLIsItemRemovable folder_test;
+ folderp->applyFunctorToChildren(folder_test);
+ if (!folder_test.mPassed)
{
return FALSE;
}
}
-
- for( i = 0; i < descendent_items.count(); i++ )
- {
- LLInventoryItem* item = descendent_items[i];
- if( (item->getType() == LLAssetType::AT_CLOTHING) ||
- (item->getType() == LLAssetType::AT_BODYPART) )
- {
- if(gAgentWearables.isWearingItem(item->getUUID()))
- {
- return FALSE;
- }
- }
- else
- if( item->getType() == LLAssetType::AT_OBJECT )
- {
- if(avatar->isWearingAttachment(item->getUUID()))
- {
- return FALSE;
- }
- }
- }
-
return TRUE;
}
@@ -1678,7 +1705,7 @@ void warn_move_inventory(LLViewerObject* object, LLMoveInv* move_inv)
{
dialog = "MoveInventoryFromObject";
}
- LLNotifications::instance().add(dialog, LLSD(), LLSD(), boost::bind(move_task_inventory_callback, _1, _2, move_inv));
+ LLNotificationsUtil::add(dialog, LLSD(), LLSD(), boost::bind(move_task_inventory_callback, _1, _2, move_inv));
}
// Move/copy all inventory items from the Contents folder of an in-world
@@ -2180,38 +2207,70 @@ BOOL LLFolderBridge::removeItem()
{
return FALSE;
}
- // move it to the trash
- LLPreview::hide(mUUID);
- LLInventoryModel* model = getInventoryModel();
- if(!model) return FALSE;
+ const LLViewerInventoryCategory *cat = getCategory();
+
+ LLSD payload;
+ LLSD args;
+ args["FOLDERNAME"] = cat->getName();
- const LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH);
+ LLNotification::Params params("ConfirmDeleteProtectedCategory");
+ params.payload(payload).substitutions(args).functor.function(boost::bind(&LLFolderBridge::removeItemResponse, this, _1, _2));
+ //params.functor.function(boost::bind(&LLFolderBridge::removeItemResponse, this, _1, _2));
+ /*
+ LLNotification::Params params("ChangeLindenEstate");
+ params.functor.function(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2));
+ */
+ if (LLFolderType::lookupIsProtectedType(cat->getPreferredType()))
+ {
+ LLNotifications::instance().add(params);
+ }
+ else
+ {
+ LLNotifications::instance().forceResponse(params, 0);
+ }
+ return TRUE;
+}
- // Look for any gestures and deactivate them
- LLInventoryModel::cat_array_t descendent_categories;
- LLInventoryModel::item_array_t descendent_items;
- gInventory.collectDescendents( mUUID, descendent_categories, descendent_items, FALSE );
+bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& response)
+{
+ S32 option = LLNotification::getSelectedOption(notification, response);
- S32 i;
- for (i = 0; i < descendent_items.count(); i++)
+ // if they choose delete, do it. Otherwise, don't do anything
+ if(option == 0)
{
- LLInventoryItem* item = descendent_items[i];
- if (item->getType() == LLAssetType::AT_GESTURE
- && LLGestureManager::instance().isGestureActive(item->getUUID()))
+ // move it to the trash
+ LLPreview::hide(mUUID);
+ LLInventoryModel* model = getInventoryModel();
+ if(!model) return FALSE;
+
+ const LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH);
+
+ // Look for any gestures and deactivate them
+ LLInventoryModel::cat_array_t descendent_categories;
+ LLInventoryModel::item_array_t descendent_items;
+ gInventory.collectDescendents( mUUID, descendent_categories, descendent_items, FALSE );
+
+ S32 i;
+ for (i = 0; i < descendent_items.count(); i++)
{
- LLGestureManager::instance().deactivateGesture(item->getUUID());
+ LLInventoryItem* item = descendent_items[i];
+ if (item->getType() == LLAssetType::AT_GESTURE
+ && LLGestureManager::instance().isGestureActive(item->getUUID()))
+ {
+ LLGestureManager::instance().deactivateGesture(item->getUUID());
+ }
}
+
+ // go ahead and do the normal remove if no 'last calling
+ // cards' are being removed.
+ LLViewerInventoryCategory* cat = getCategory();
+ if(cat)
+ {
+ LLInvFVBridge::changeCategoryParent(model, cat, trash_id, TRUE);
+ }
+ return TRUE;
}
-
- // go ahead and do the normal remove if no 'last calling
- // cards' are being removed.
- LLViewerInventoryCategory* cat = getCategory();
- if(cat)
- {
- LLInvFVBridge::changeCategoryParent(model, cat, trash_id, TRUE);
- }
-
- return TRUE;
+ return FALSE;
}
void LLFolderBridge::pasteFromClipboard()
@@ -2295,6 +2354,19 @@ void LLFolderBridge::staticFolderOptionsMenu()
sSelf->folderOptionsMenu();
}
+bool isInOutfitsSidePanel(LLPanel *panel)
+{
+ LLInventoryPanel *my_panel = dynamic_cast<LLInventoryPanel*>(panel);
+ LLPanelOutfitsInventory *outfit_panel =
+ dynamic_cast<LLPanelOutfitsInventory*>(LLSideTray::getInstance()->getPanel("panel_outfits_inventory"));
+ if (!outfit_panel)
+ return false;
+ return outfit_panel->isAccordionPanel(my_panel);
+
+ //LLInventoryPanel *outfit_inv_panel = outfit_panel ? outfit_panel->getActivePanel(): NULL;
+ //return (my_panel && (my_panel == outfit_inv_panel));
+}
+
void LLFolderBridge::folderOptionsMenu()
{
std::vector<std::string> disabled_items;
@@ -2308,11 +2380,17 @@ void LLFolderBridge::folderOptionsMenu()
// BAP change once we're no longer treating regular categories as ensembles.
const bool is_ensemble = category && (type == LLFolderType::FT_NONE ||
LLFolderType::lookupIsEnsembleType(type));
+ const bool is_sidepanel = isInOutfitsSidePanel(mInventoryPanel.get());
// calling card related functionality for folders.
+ if (is_sidepanel)
+ {
+ mItems.clear();
+ }
+
// Only enable calling-card related options for non-default folders.
- if (!is_default_folder)
+ if (!is_sidepanel && !is_default_folder)
{
LLIsType is_callingcard(LLAssetType::AT_CALLINGCARD);
if (mCallingCards || checkFolderForContentsOfType(model, is_callingcard))
@@ -2349,6 +2427,10 @@ void LLFolderBridge::folderOptionsMenu()
mItems.push_back(std::string("Remove From Outfit"));
}
hide_context_entries(*mMenu, mItems, disabled_items);
+
+ // Reposition the menu, in case we're adding items to an existing menu.
+ mMenu->needsArrange();
+ mMenu->arrangeAndClear();
}
BOOL LLFolderBridge::checkFolderForContentsOfType(LLInventoryModel* model, LLInventoryCollectFunctor& is_type)
@@ -2680,7 +2762,7 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response
{
LLFloaterOpenObject::LLCatAndWear* cat_and_wear = (LLFloaterOpenObject::LLCatAndWear* )move_inv->mUserData;
LLViewerObject* object = gObjectList.findObject(move_inv->mObjectID);
- S32 option = LLNotification::getSelectedOption(notification, response);
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if(option == 0 && object)
{
@@ -2769,7 +2851,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
BOOL drop)
{
LLInventoryModel* model = getInventoryModel();
- if(!model) return FALSE;
+ if(!model || !inv_item) return FALSE;
// cannot drag into library
if(!isAgentInventory())
@@ -3253,7 +3335,7 @@ void LLLandmarkBridge::performAction(LLFolderView* folder, LLInventoryModel* mod
static bool open_landmark_callback(const LLSD& notification, const LLSD& response)
{
- S32 option = LLNotification::getSelectedOption(notification, response);
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLUUID asset_id = notification["payload"]["asset_id"].asUUID();
if (option == 0)
@@ -3283,7 +3365,7 @@ void LLLandmarkBridge::openItem()
// open_landmark(item);
LLSD payload;
payload["asset_id"] = item->getAssetUUID();
- LLNotifications::instance().add("TeleportFromLandmark", LLSD(), payload);
+ LLNotificationsUtil::add("TeleportFromLandmark", LLSD(), payload);
}
*/
}
@@ -3658,11 +3740,6 @@ void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
}
else
{
- LLInventoryItem* item = getItem();
- if (item && item->getIsLinkType())
- {
- items.push_back(std::string("Find Original"));
- }
items.push_back(std::string("Open"));
items.push_back(std::string("Properties"));
@@ -3772,14 +3849,6 @@ LLItemBridge(inventory, uuid), mInvType(type)
mIsMultiObject = ( flags & LLInventoryItem::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS ) ? TRUE: FALSE;
}
-BOOL LLObjectBridge::isItemRemovable()
-{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if(!avatar) return FALSE;
- if(avatar->isWearingAttachment(mUUID)) return FALSE;
- return LLInvFVBridge::isItemRemovable();
-}
-
LLUIImagePtr LLObjectBridge::getIcon() const
{
return get_item_icon(LLAssetType::AT_OBJECT, mInvType, mAttachPt, mIsMultiObject );
@@ -3923,7 +3992,7 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach
#if !ENABLE_MULTIATTACHMENTS
if (attachment && attachment->getNumObjects() > 0)
{
- LLNotifications::instance().add("ReplaceAttachment", LLSD(), payload, confirm_replace_attachment_rez);
+ LLNotificationsUtil::add("ReplaceAttachment", LLSD(), payload, confirm_replace_attachment_rez);
}
else
#endif
@@ -3940,11 +4009,11 @@ bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& respon
{
LLSD args;
args["MAX_ATTACHMENTS"] = llformat("%d", MAX_AGENT_ATTACHMENTS);
- LLNotifications::instance().add("MaxAttachmentsOnOutfit", args);
+ LLNotificationsUtil::add("MaxAttachmentsOnOutfit", args);
return false;
}
- S32 option = LLNotification::getSelectedOption(notification, response);
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (option == 0/*YES*/)
{
LLViewerInventoryItem* itemp = gInventory.getItem(notification["payload"]["item_id"].asUUID());
@@ -3990,14 +4059,9 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
}
else
{
- LLInventoryItem* item = getItem();
- if (item && item->getIsLinkType())
- {
- items.push_back(std::string("Find Original"));
- }
-
items.push_back(std::string("Properties"));
+ LLInventoryItem *item = getItem();
getClipboardEntries(true, items, disabled_items, flags);
LLObjectBridge::sContextMenuItemID = mUUID;
@@ -4235,32 +4299,37 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, LLUUID category_
{
for(i = 0; i < wearable_count; ++i)
{
- if( gAgentWearables.isWearingItem (item_array.get(i)->getUUID()) )
+ LLViewerInventoryItem *item = item_array.get(i);
+ if (item->getType() == LLAssetType::AT_BODYPART)
+ continue;
+ if (gAgent.isTeen() && item->isWearableType() &&
+ (item->getWearableType() == WT_UNDERPANTS || item->getWearableType() == WT_UNDERSHIRT))
+ continue;
+ if( gAgentWearables.isWearingItem (item->getLinkedUUID()) )
{
- LLWearableList::instance().getAsset(item_array.get(i)->getAssetUUID(),
- item_array.get(i)->getName(),
- item_array.get(i)->getType(),
+ LLWearableList::instance().getAsset(item->getAssetUUID(),
+ item->getName(),
+ item->getType(),
LLWearableBridge::onRemoveFromAvatarArrived,
- new OnRemoveStruct(item_array.get(i)->getUUID()));
-
+ new OnRemoveStruct(item->getLinkedUUID()));
}
}
}
-
if (obj_count > 0)
{
for(i = 0; i < obj_count; ++i)
{
+ LLViewerInventoryItem *obj_item = obj_item_array.get(i);
gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
gMessageSystem->nextBlockFast(_PREHASH_ObjectData );
gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
- gMessageSystem->addUUIDFast(_PREHASH_ItemID, obj_item_array.get(i)->getUUID() );
+ gMessageSystem->addUUIDFast(_PREHASH_ItemID, obj_item->getLinkedUUID() );
gMessageSystem->sendReliable( gAgent.getRegion()->getHost() );
// this object might have been selected, so let the selection manager know it's gone now
- LLViewerObject *found_obj = gObjectList.findObject( obj_item_array.get(i)->getUUID());
+ LLViewerObject *found_obj = gObjectList.findObject( obj_item->getLinkedUUID());
if (found_obj)
{
LLSelectMgr::getInstance()->remove(found_obj);
@@ -4272,10 +4341,11 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, LLUUID category_
{
for(i = 0; i < gest_count; ++i)
{
- if ( LLGestureManager::instance().isGestureActive( gest_item_array.get(i)->getUUID()) )
+ LLViewerInventoryItem *gest_item = gest_item_array.get(i);
+ if ( LLGestureManager::instance().isGestureActive( gest_item->getLinkedUUID()) )
{
- LLGestureManager::instance().deactivateGesture( gest_item_array.get(i)->getUUID() );
- gInventory.updateItem( gest_item_array.get(i) );
+ LLGestureManager::instance().deactivateGesture( gest_item->getLinkedUUID() );
+ gInventory.updateItem( gest_item );
gInventory.notifyObservers();
}
@@ -4293,12 +4363,6 @@ BOOL LLWearableBridge::renameItem(const std::string& new_name)
return LLItemBridge::renameItem(new_name);
}
-BOOL LLWearableBridge::isItemRemovable()
-{
- if (gAgentWearables.isWearingItem(mUUID)) return FALSE;
- return LLInvFVBridge::isItemRemovable();
-}
-
std::string LLWearableBridge::getLabelSuffix() const
{
if( gAgentWearables.isWearingItem( mUUID ) )
@@ -4362,7 +4426,7 @@ void LLWearableBridge::openItem()
/*
if( isInTrash() )
{
- LLNotifications::instance().add("CannotWearTrash");
+ LLNotificationsUtil::add("CannotWearTrash");
}
else if(isAgentInventory())
{
@@ -4391,7 +4455,7 @@ void LLWearableBridge::openItem()
{
// *TODO: We should fetch the item details, and then do
// the operation above.
- LLNotifications::instance().add("CannotWearInfoNotComplete");
+ LLNotificationsUtil::add("CannotWearInfoNotComplete");
}
}
*/
@@ -4428,11 +4492,6 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
items.push_back(std::string("Open"));
}
- if (item && item->getIsLinkType())
- {
- items.push_back(std::string("Find Original"));
- }
-
items.push_back(std::string("Properties"));
getClipboardEntries(true, items, disabled_items, flags);
@@ -4510,7 +4569,7 @@ void LLWearableBridge::wearOnAvatar()
// destroy clothing items.
if (!gAgentWearables.areWearablesLoaded())
{
- LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded");
+ LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded");
return;
}
@@ -4541,7 +4600,7 @@ void LLWearableBridge::wearAddOnAvatar()
// destroy clothing items.
if (!gAgentWearables.areWearablesLoaded())
{
- LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded");
+ LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded");
return;
}
@@ -4842,7 +4901,7 @@ void LLLandmarkBridgeAction::doIt()
// but warns you the first time.
LLSD payload;
payload["asset_id"] = item->getAssetUUID();
- LLNotifications::instance().add("TeleportFromLandmark", LLSD(), payload);
+ LLNotificationsUtil::add("TeleportFromLandmark", LLSD(), payload);
}
LLInvFVBridgeAction::doIt();
@@ -4942,7 +5001,7 @@ void LLWearableBridgeAction::wearOnAvatar()
// destroy clothing items.
if (!gAgentWearables.areWearablesLoaded())
{
- LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded");
+ LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded");
return;
}
@@ -4972,7 +5031,7 @@ void LLWearableBridgeAction::doIt()
{
if(isInTrash())
{
- LLNotifications::instance().add("CannotWearTrash");
+ LLNotificationsUtil::add("CannotWearTrash");
}
else if(isAgentInventory())
{
@@ -5001,7 +5060,7 @@ void LLWearableBridgeAction::doIt()
{
// *TODO: We should fetch the item details, and then do
// the operation above.
- LLNotifications::instance().add("CannotWearInfoNotComplete");
+ LLNotificationsUtil::add("CannotWearInfoNotComplete");
}
}