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.cpp723
1 files changed, 466 insertions, 257 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 5ed79a6493..25025038d2 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -104,7 +104,6 @@ static bool check_item(const LLUUID& item_id,
LLInventoryFilter* filter);
// Helper functions
-
bool isAddAction(const std::string& action)
{
return ("wear" == action || "attach" == action || "activate" == action);
@@ -1897,20 +1896,24 @@ void LLItemBridge::selectItem()
}
}
+// virtual
void LLItemBridge::restoreItem()
{
- LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem());
- if(item)
+ if (LLViewerInventoryItem* item = getItem())
{
- LLInventoryModel* model = getInventoryModel();
- bool is_snapshot = (item->getInventoryType() == LLInventoryType::IT_SNAPSHOT);
+ bool is_snapshot = item->getInventoryType() == LLInventoryType::IT_SNAPSHOT;
+ LLFolderType::EType preferred_type = is_snapshot ?
+ LLFolderType::FT_SNAPSHOT_CATEGORY :
+ LLFolderType::assetTypeToFolderType(item->getType());
- const LLUUID new_parent = model->findCategoryUUIDForType(is_snapshot? LLFolderType::FT_SNAPSHOT_CATEGORY : LLFolderType::assetTypeToFolderType(item->getType()));
- // do not restamp on restore.
+ LLInventoryModel* model = getInventoryModel();
+ LLUUID new_parent = model->findCategoryUUIDForType(preferred_type);
+ // Do not restamp on restore.
LLInvFVBridge::changeItemParent(model, item, new_parent, false);
}
}
+// virtual
void LLItemBridge::restoreToWorld()
{
//Similar functionality to the drag and drop rez logic
@@ -1931,26 +1934,27 @@ void LLItemBridge::restoreToWorld()
//remove local inventory copy, sim will deal with permissions and removing the item
//from the actual inventory if its a no-copy etc
- if(!itemp->getPermissions().allowCopyBy(gAgent.getID()))
+ if (!itemp->getPermissions().allowCopyBy(gAgent.getID()))
{
remove_from_inventory = true;
}
// Check if it's in the trash. (again similar to the normal rez logic)
const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
- if(gInventory.isObjectDescendentOf(itemp->getUUID(), trash_id))
+ if (gInventory.isObjectDescendentOf(itemp->getUUID(), trash_id))
{
remove_from_inventory = true;
}
}
- if(remove_from_inventory)
+ if (remove_from_inventory)
{
gInventory.deleteObject(itemp->getUUID());
gInventory.notifyObservers();
}
}
+// virtual
void LLItemBridge::gotoItem()
{
LLInventoryObject *obj = getInventoryObject();
@@ -1960,39 +1964,43 @@ void LLItemBridge::gotoItem()
}
}
+// virtual
LLUIImagePtr LLItemBridge::getIcon() const
{
- LLInventoryObject *obj = getInventoryObject();
- if (obj)
+ if (LLInventoryObject* obj = getInventoryObject())
{
- return LLInventoryIcon::getIcon(obj->getType(),
- LLInventoryType::IT_NONE,
- mIsLink);
+ return LLInventoryIcon::getIcon(obj->getType(), LLInventoryType::IT_NONE, mIsLink);
}
return LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT);
}
+// virtual
LLUIImagePtr LLItemBridge::getIconOverlay() const
{
if (getItem() && getItem()->getIsLinkType())
{
return LLUI::getUIImage("Inv_Link");
}
+
return NULL;
}
+// virtual
PermissionMask LLItemBridge::getPermissionMask() const
{
- LLViewerInventoryItem* item = getItem();
- PermissionMask perm_mask = 0;
- if (item) perm_mask = item->getPermissionMask();
- return perm_mask;
+ if (LLViewerInventoryItem* item = getItem())
+ {
+ return item->getPermissionMask();
+ }
+
+ return 0;
}
+// virtual
void LLItemBridge::buildDisplayName() const
{
- if(getItem())
+ if (getItem())
{
mDisplayName.assign(getItem()->getName());
}
@@ -2005,14 +2013,15 @@ void LLItemBridge::buildDisplayName() const
mSearchableName.append(getLabelSuffix());
LLStringUtil::toUpper(mSearchableName);
- //Name set, so trigger a sort
+ // Name set, so trigger a sort
LLInventorySort sorter = static_cast<LLFolderViewModelInventory&>(mRootViewModel).getSorter();
- if(mParent && !sorter.isByDate())
+ if (mParent && !sorter.isByDate())
{
mParent->requestSort();
}
}
+// virtual
LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const
{
U8 font = LLFontGL::NORMAL;
@@ -2023,7 +2032,7 @@ LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const
// LL_INFOS() << "BOLD" << LL_ENDL;
font |= LLFontGL::BOLD;
}
- else if(item && item->getIsLinkType())
+ else if (item && item->getIsLinkType())
{
font |= LLFontGL::ITALIC;
}
@@ -2031,6 +2040,7 @@ LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const
return (LLFontGL::StyleFlags)font;
}
+// virtual
std::string LLItemBridge::getLabelSuffix() const
{
// String table is loaded before login screen and inventory items are
@@ -2040,19 +2050,19 @@ std::string LLItemBridge::getLabelSuffix() const
static std::string NO_XFER = LLTrans::getString("no_transfer_lbl");
static std::string LINK = LLTrans::getString("link");
static std::string BROKEN_LINK = LLTrans::getString("broken_link");
+
std::string suffix;
- LLInventoryItem* item = getItem();
- if(item)
+ if (LLInventoryItem* item = getItem())
{
// Any type can have the link suffix...
- bool broken_link = LLAssetType::lookupIsLinkType(item->getType());
- if (broken_link) return BROKEN_LINK;
+ if (LLAssetType::lookupIsLinkType(item->getType()))
+ return BROKEN_LINK;
- bool link = item->getIsLinkType();
- if (link) return LINK;
+ if (item->getIsLinkType())
+ return LINK;
// ...but it's a bit confusing to put nocopy/nomod/etc suffixes on calling cards.
- if(LLAssetType::AT_CALLINGCARD != item->getType()
+ if (LLAssetType::AT_CALLINGCARD != item->getType()
&& item->getPermissions().getOwner() == gAgent.getID())
{
bool copy = item->getPermissions().allowCopyBy(gAgent.getID());
@@ -2067,8 +2077,7 @@ std::string LLItemBridge::getLabelSuffix() const
suffix += suffix.empty() ? " " : ",";
suffix += NO_MOD;
}
- bool xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER,
- gAgent.getID());
+ bool xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID());
if (!xfer)
{
suffix += suffix.empty() ? " " : ",";
@@ -2076,24 +2085,25 @@ std::string LLItemBridge::getLabelSuffix() const
}
}
}
+
return suffix;
}
+// virtual
time_t LLItemBridge::getCreationDate() const
{
- LLViewerInventoryItem* item = getItem();
- if (item)
+ if (LLViewerInventoryItem* item = getItem())
{
return item->getCreationDate();
}
+
return 0;
}
-
+// virtual
bool LLItemBridge::isItemRenameable() const
{
- LLViewerInventoryItem* item = getItem();
- if(item)
+ if (LLViewerInventoryItem* item = getItem())
{
// (For now) Don't allow calling card rename since that may confuse users as to
// what the calling card points to.
@@ -2112,50 +2122,62 @@ bool LLItemBridge::isItemRenameable() const
return false;
}
- return (item->getPermissions().allowModifyBy(gAgent.getID()));
+ return item->getPermissions().allowModifyBy(gAgent.getID());
}
+
return false;
}
+// virtual
bool LLItemBridge::renameItem(const std::string& new_name)
{
- if(!isItemRenameable())
+ if (!isItemRenameable())
return false;
+
LLPreview::dirty(mUUID);
LLInventoryModel* model = getInventoryModel();
- if(!model)
+ if (!model)
return false;
+
LLViewerInventoryItem* item = getItem();
- if(item && (item->getName() != new_name))
+ if (item && (item->getName() != new_name))
{
LLSD updates;
updates["name"] = new_name;
update_inventory_item(item->getUUID(),updates, NULL);
}
- // return false because we either notified observers (& therefore
- // rebuilt) or we didn't update.
+
+ // return false because we either notified observers
+ // (& therefore rebuilt) or we didn't update.
return false;
}
+// virtual
bool LLItemBridge::removeItem()
{
- if(!isItemRemovable())
+ if (!isItemRemovable())
{
return false;
}
// move it to the trash
LLInventoryModel* model = getInventoryModel();
- if(!model) return false;
+ if (!model)
+ return false;
+
const LLUUID& trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH);
LLViewerInventoryItem* item = getItem();
- if (!item) return false;
+ if (!item)
+ return false;
+
if (item->getType() != LLAssetType::AT_LSL_TEXT)
{
LLPreview::hide(mUUID, true);
}
+
// Already in trash
- if (model->isObjectDescendentOf(mUUID, trash_id)) return false;
+ if (model->isObjectDescendentOf(mUUID, trash_id))
+ return false;
LLNotification::Params params("ConfirmItemDeleteHasLinks");
params.functor.function(boost::bind(&LLItemBridge::confirmRemoveItem, this, _1, _2));
@@ -2187,26 +2209,31 @@ bool LLItemBridge::removeItem()
bool LLItemBridge::confirmRemoveItem(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
- if (option != 0) return false;
+ if (option != 0)
+ return false;
LLInventoryModel* model = getInventoryModel();
- if (!model) return false;
+ if (!model)
+ return false;
LLViewerInventoryItem* item = getItem();
- if (!item) return false;
+ 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))
+ if (item && !model->isObjectDescendentOf(mUUID, trash_id))
{
// move to trash, and restamp
LLInvFVBridge::changeItemParent(model, item, trash_id, true);
// delete was successful
return true;
}
+
return false;
}
+// virtual
bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const
{
LLViewerInventoryItem* item = getItem();
@@ -2214,6 +2241,7 @@ bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const
{
return false;
}
+
// Can't copy worn objects.
// Worn objects are tied to their inworld conterparts
// Copy of modified worn object will return object with obsolete asset and inventory
@@ -2230,37 +2258,36 @@ bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const
LLViewerInventoryItem* LLItemBridge::getItem() const
{
- LLViewerInventoryItem* item = NULL;
- LLInventoryModel* model = getInventoryModel();
- if(model)
+ if (LLInventoryModel* model = getInventoryModel())
{
- item = (LLViewerInventoryItem*)model->getItem(mUUID);
+ return model->getItem(mUUID);
}
- return item;
+
+ return NULL;
}
+// virtual
const LLUUID& LLItemBridge::getThumbnailUUID() const
{
- LLViewerInventoryItem* item = NULL;
- LLInventoryModel* model = getInventoryModel();
- if(model)
- {
- item = (LLViewerInventoryItem*)model->getItem(mUUID);
- }
- if (item)
+ if (LLInventoryModel* model = getInventoryModel())
{
- return item->getThumbnailUUID();
+ if (LLViewerInventoryItem* item = model->getItem(mUUID))
+ {
+ return item->getThumbnailUUID();
+ }
}
+
return LLUUID::null;
}
+// virtual
bool LLItemBridge::isItemPermissive() const
{
- LLViewerInventoryItem* item = getItem();
- if(item)
+ if (LLViewerInventoryItem* item = getItem())
{
return item->getIsFullPerm();
}
+
return false;
}
@@ -2583,16 +2610,22 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
LLInventoryModel* model = getInventoryModel();
- if (!inv_cat) return false; // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL
- if (!model) return false;
- if (!isAgentAvatarValid()) return false;
- if (!isAgentInventory()) return false; // cannot drag categories into library
+ if (!inv_cat) // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL
+ return false;
+ if (!model)
+ return false;
+ if (!isAgentAvatarValid())
+ return false;
+ if (!isAgentInventory())
+ return false; // cannot drag categories into library
LLInventoryPanel* destination_panel = mInventoryPanel.get();
- if (!destination_panel) return false;
+ if (!destination_panel)
+ return false;
LLInventoryFilter* filter = getInventoryFilter();
- if (!filter) return false;
+ if (!filter)
+ return false;
const LLUUID &cat_id = inv_cat->getUUID();
const LLUUID &current_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT);
@@ -2631,6 +2664,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
//
bool is_movable = true;
+ bool create_outfit = false;
if (is_movable && (marketplacelistings_id == cat_id))
{
@@ -2663,14 +2697,24 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
U32 max_items_to_wear = gSavedSettings.getU32("WearFolderLimit");
if (is_movable && move_is_into_outfit)
{
- if (mUUID == my_outifts_id)
+ if ((inv_cat->getPreferredType() != LLFolderType::FT_NONE) && (inv_cat->getPreferredType() != LLFolderType::FT_OUTFIT))
+ {
+ tooltip_msg = LLTrans::getString("TooltipCantCreateOutfit");
+ is_movable = false;
+ }
+ else if (mUUID == my_outifts_id)
{
if (source != LLToolDragAndDrop::SOURCE_AGENT || move_is_from_marketplacelistings)
{
tooltip_msg = LLTrans::getString("TooltipOutfitNotInInventory");
is_movable = false;
}
- else if (can_move_to_my_outfits(model, inv_cat, max_items_to_wear))
+ else if (can_move_to_my_outfits_as_outfit(model, inv_cat, max_items_to_wear))
+ {
+ is_movable = true;
+ create_outfit = true;
+ }
+ else if (can_move_to_my_outfits_as_subfolder(model, inv_cat))
{
is_movable = true;
}
@@ -2680,16 +2724,47 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
is_movable = false;
}
}
- else if(getCategory() && getCategory()->getPreferredType() == LLFolderType::FT_NONE)
+ else if (!getCategory())
{
- is_movable = ((inv_cat->getPreferredType() == LLFolderType::FT_NONE) || (inv_cat->getPreferredType() == LLFolderType::FT_OUTFIT));
+ is_movable = false;
+ tooltip_msg = LLTrans::getString("TooltipCantCreateOutfit");
}
else
{
- is_movable = false;
+ EMyOutfitsSubfolderType dest_res = myoutfit_object_subfolder_type(model, mUUID, my_outifts_id);
+ EMyOutfitsSubfolderType inv_res = myoutfit_object_subfolder_type(model, cat_id, my_outifts_id);
+ if ((dest_res == MY_OUTFITS_OUTFIT || dest_res == MY_OUTFITS_SUBOUTFIT) && inv_res == MY_OUTFITS_OUTFIT)
+ {
+ is_movable = false;
+ tooltip_msg = LLTrans::getString("TooltipCantMoveOutfitIntoOutfit");
+ }
+ else if (dest_res == MY_OUTFITS_OUTFIT || dest_res == MY_OUTFITS_SUBOUTFIT)
+ {
+ is_movable = false;
+ tooltip_msg = LLTrans::getString("TooltipCantCreateOutfit");
+ }
+ else if (dest_res == MY_OUTFITS_SUBFOLDER && inv_res == MY_OUTFITS_SUBOUTFIT)
+ {
+ is_movable = false;
+ tooltip_msg = LLTrans::getString("TooltipCantCreateOutfit");
+ }
+ else if (can_move_to_my_outfits_as_outfit(model, inv_cat, max_items_to_wear))
+ {
+ is_movable = true;
+ create_outfit = true;
+ }
+ else if (can_move_to_my_outfits_as_subfolder(model, inv_cat))
+ {
+ is_movable = true;
+ }
+ else
+ {
+ is_movable = false;
+ tooltip_msg = LLTrans::getString("TooltipCantCreateOutfit");
+ }
}
}
- if(is_movable && move_is_into_current_outfit && is_link)
+ if (is_movable && move_is_into_current_outfit && is_link)
{
is_movable = false;
}
@@ -2717,7 +2792,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
for (S32 i=0; i < descendent_categories.size(); ++i)
{
LLInventoryCategory* category = descendent_categories[i];
- if(LLFolderType::lookupIsProtectedType(category->getPreferredType()))
+ if (LLFolderType::lookupIsProtectedType(category->getPreferredType()))
{
// Can't move "special folders" (e.g. Textures Folder).
is_movable = false;
@@ -2749,9 +2824,8 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
}
if (is_movable && move_is_into_trash)
{
- for (S32 i=0; i < descendent_items.size(); ++i)
+ for (LLViewerInventoryItem* item : descendent_items)
{
- LLInventoryItem* item = descendent_items[i];
if (get_is_item_worn(item->getUUID()))
{
is_movable = false;
@@ -2761,10 +2835,8 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
}
if (is_movable && move_is_into_landmarks)
{
- for (S32 i=0; i < descendent_items.size(); ++i)
+ for (LLViewerInventoryItem* item : descendent_items)
{
- LLViewerInventoryItem* item = descendent_items[i];
-
// Don't move anything except landmarks and categories into Landmarks folder.
// We use getType() instead of getActua;Type() to allow links to landmarks and folders.
if (LLAssetType::AT_LANDMARK != item->getType() && LLAssetType::AT_CATEGORY != item->getType())
@@ -2881,9 +2953,81 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
if (mUUID == my_outifts_id)
{
- // Category can contains objects,
- // create a new folder and populate it with links to original objects
- dropToMyOutfits(inv_cat, cb);
+ EMyOutfitsSubfolderType inv_res = myoutfit_object_subfolder_type(model, cat_id, my_outifts_id);
+ if (inv_res == MY_OUTFITS_SUBFOLDER || inv_res == MY_OUTFITS_OUTFIT || !create_outfit)
+ {
+ LLInvFVBridge::changeCategoryParent(
+ model,
+ (LLViewerInventoryCategory*)inv_cat,
+ mUUID,
+ false);
+ if (cb) cb->fire(inv_cat->getUUID());
+ }
+ else
+ {
+ // Moving from inventory
+ // create a new folder and populate it with links to original objects
+ dropToMyOutfits(inv_cat, cb);
+ }
+ }
+ else if (move_is_into_my_outfits)
+ {
+ EMyOutfitsSubfolderType dest_res = myoutfit_object_subfolder_type(model, mUUID, my_outifts_id);
+ EMyOutfitsSubfolderType inv_res = myoutfit_object_subfolder_type(model, cat_id, my_outifts_id);
+ switch (inv_res)
+ {
+ case MY_OUTFITS_NO:
+ // Moning from outside outfits into outfits
+ if (dest_res == MY_OUTFITS_SUBFOLDER && create_outfit)
+ {
+ // turn it into outfit
+ dropToMyOutfitsSubfolder(inv_cat, mUUID, cb);
+ }
+ else
+ {
+ LLInvFVBridge::changeCategoryParent(
+ model,
+ (LLViewerInventoryCategory*)inv_cat,
+ mUUID,
+ move_is_into_trash);
+ if (cb) cb->fire(inv_cat->getUUID());
+ }
+ break;
+ case MY_OUTFITS_SUBFOLDER:
+ case MY_OUTFITS_OUTFIT:
+ // only permit moving subfodlers and outfits into other subfolders
+ if (dest_res == MY_OUTFITS_SUBFOLDER)
+ {
+ LLInvFVBridge::changeCategoryParent(
+ model,
+ (LLViewerInventoryCategory*)inv_cat,
+ mUUID,
+ false);
+ if (cb) cb->fire(inv_cat->getUUID());
+ }
+ else
+ {
+ assert(false); // mot permitted, shouldn't have accepted
+ }
+ break;
+ case MY_OUTFITS_SUBOUTFIT:
+ if (dest_res == MY_OUTFITS_SUBOUTFIT || dest_res == MY_OUTFITS_OUTFIT)
+ {
+ LLInvFVBridge::changeCategoryParent(
+ model,
+ (LLViewerInventoryCategory*)inv_cat,
+ mUUID,
+ false);
+ if (cb) cb->fire(inv_cat->getUUID());
+ }
+ else
+ {
+ assert(false); // mot permitted, shouldn't have accepted
+ }
+ break;
+ default:
+ break;
+ }
}
// if target is current outfit folder we use link
else if (move_is_into_current_outfit &&
@@ -3055,7 +3199,7 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id,
// permissions.
// content category has same ID as object itself
LLViewerObject* object = gObjectList.findObject(object_id);
- if(!object)
+ if (!object)
{
LL_INFOS() << "Object not found for drop." << LL_ENDL;
return false;
@@ -3083,11 +3227,9 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id,
// coming from a task. Need to figure out if the person can
// move/copy this item.
- LLInventoryObject::object_list_t::iterator it = inventory_objects.begin();
- LLInventoryObject::object_list_t::iterator end = inventory_objects.end();
- for ( ; it != end; ++it)
+ for (LLPointer<LLInventoryObject> obj : inventory_objects)
{
- LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(it->get());
+ LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(obj.get());
if (!item)
{
LL_WARNS() << "Invalid inventory item for drop" << LL_ENDL;
@@ -3097,13 +3239,13 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id,
// coming from a task. Need to figure out if the person can
// move/copy this item.
LLPermissions perm(item->getPermissions());
- if((perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID())
+ if ((perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID())
&& perm.allowTransferTo(gAgent.getID())))
// || gAgent.isGodlike())
{
accept = true;
}
- else if(object->permYouOwner())
+ else if (object->permYouOwner())
{
// If the object cannot be copied, but the object the
// inventory is owned by the agent, then the item can be
@@ -3123,22 +3265,21 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id,
}
}
- if(drop && accept)
+ if (drop && accept)
{
- it = inventory_objects.begin();
std::shared_ptr<LLMoveInv> move_inv(new LLMoveInv);
move_inv->mObjectID = object_id;
move_inv->mCategoryID = category_id;
move_inv->mCallback = callback;
move_inv->mUserData = user_data;
- for ( ; it != end; ++it)
+ for (LLPointer<LLInventoryObject> obj : inventory_objects)
{
- two_uuids_t two(category_id, (*it)->getUUID());
+ two_uuids_t two(category_id, obj->getUUID());
move_inv->mMoveList.push_back(two);
}
- if(is_move)
+ if (is_move)
{
// Callback called from within here.
warn_move_inventory(object, move_inv);
@@ -3156,13 +3297,13 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id,
void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer)
{
// Bail out immediately if no descendents
- if( mComplete.empty() )
+ if (mComplete.empty())
{
LL_WARNS() << "LLRightClickInventoryFetchDescendentsObserver::done with empty mCompleteFolders" << LL_ENDL;
if (clear_observer)
{
- gInventory.removeObserver(this);
- delete this;
+ gInventory.removeObserver(this);
+ delete this;
}
return;
}
@@ -3186,13 +3327,13 @@ void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer)
gInventory.getDirectDescendentsOf(*current_folder, cat_array, item_array);
size_t item_count(0);
- if( item_array )
+ if (item_array)
{
item_count = item_array->size();
}
size_t cat_count(0);
- if( cat_array )
+ if (cat_array)
{
cat_count = cat_array->size();
}
@@ -3291,20 +3432,16 @@ protected:
};
-
void LLInventoryCopyAndWearObserver::changed(U32 mask)
{
- if((mask & (LLInventoryObserver::ADD)) != 0)
+ if ((mask & (LLInventoryObserver::ADD)) != 0)
{
if (!mFolderAdded)
{
const std::set<LLUUID>& changed_items = gInventory.getChangedIDs();
-
- std::set<LLUUID>::const_iterator id_it = changed_items.begin();
- std::set<LLUUID>::const_iterator id_end = changed_items.end();
- for (;id_it != id_end; ++id_it)
+ for (const LLUUID& item_id : changed_items)
{
- if ((*id_it) == mCatID)
+ if (item_id == mCatID)
{
mFolderAdded = true;
break;
@@ -3322,8 +3459,7 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask)
}
else
{
- if (category->getDescendentCount() ==
- mContentsCount)
+ if (category->getDescendentCount() == mContentsCount)
{
gInventory.removeObserver(this);
LLAppearanceMgr::instance().wearInventoryCategory(category, false, !mReplace);
@@ -3335,8 +3471,6 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask)
}
}
-
-
void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
{
if ("open" == action)
@@ -3429,19 +3563,19 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
LLMarketplaceValidator::getInstance()->validateMarketplaceListings(
version_folder_id,
[this](bool result)
- {
- // todo: might need to ensure bridge/mUUID exists or this will cause crashes
- if (!result)
{
- LLSD subs;
- subs["[ERROR_CODE]"] = mMessage;
- LLNotificationsUtil::add("MerchantListingFailed", subs);
- }
- else
- {
- LLMarketplaceData::instance().activateListing(mUUID, true);
- }
- },
+ // todo: might need to ensure bridge/mUUID exists or this will cause crashes
+ if (!result)
+ {
+ LLSD subs;
+ subs["[ERROR_CODE]"] = mMessage;
+ LLNotificationsUtil::add("MerchantListingFailed", subs);
+ }
+ else
+ {
+ LLMarketplaceData::instance().activateListing(mUUID, true);
+ }
+ },
boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3)
);
}
@@ -3456,19 +3590,19 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
LLMarketplaceValidator::getInstance()->validateMarketplaceListings(
mUUID,
[this](bool result)
- {
- if (!result)
{
- LLSD subs;
- subs["[ERROR_CODE]"] = mMessage;
- LLNotificationsUtil::add("MerchantFolderActivationFailed", subs);
- }
- else
- {
- LLInventoryCategory* category = gInventory.getCategory(mUUID);
- LLMarketplaceData::instance().setVersionFolder(category->getParentUUID(), mUUID);
- }
- },
+ if (!result)
+ {
+ LLSD subs;
+ subs["[ERROR_CODE]"] = mMessage;
+ LLNotificationsUtil::add("MerchantFolderActivationFailed", subs);
+ }
+ else
+ {
+ LLInventoryCategory* category = gInventory.getCategory(mUUID);
+ LLMarketplaceData::instance().setVersionFolder(category->getParentUUID(), mUUID);
+ }
+ },
boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3),
false,
2);
@@ -3500,35 +3634,35 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
LLMarketplaceValidator::getInstance()->validateMarketplaceListings(
mUUID,
[this](bool result)
- {
- if (!result)
{
- mMessage = "";
-
- LLMarketplaceValidator::getInstance()->validateMarketplaceListings(
- mUUID,
- [this](bool result)
+ if (!result)
{
- if (result)
- {
- LLNotificationsUtil::add("MerchantForceValidateListing");
- LLMarketplaceData::instance().createListing(mUUID);
- }
- else
+ mMessage = "";
+
+ LLMarketplaceValidator::getInstance()->validateMarketplaceListings(
+ mUUID,
+ [this](bool result)
{
- LLSD subs;
- subs["[ERROR_CODE]"] = mMessage;
- LLNotificationsUtil::add("MerchantListingFailed", subs);
- }
- },
- boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3),
- true);
- }
- else
- {
- LLMarketplaceData::instance().createListing(mUUID);
- }
- },
+ if (result)
+ {
+ LLNotificationsUtil::add("MerchantForceValidateListing");
+ LLMarketplaceData::instance().createListing(mUUID);
+ }
+ else
+ {
+ LLSD subs;
+ subs["[ERROR_CODE]"] = mMessage;
+ LLNotificationsUtil::add("MerchantListingFailed", subs);
+ }
+ },
+ boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3),
+ true);
+ }
+ else
+ {
+ LLMarketplaceData::instance().createListing(mUUID);
+ }
+ },
boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3),
false);
@@ -3578,6 +3712,13 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
const LLUUID &marketplacelistings_id = model->findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS);
move_folder_to_marketplacelistings(cat, marketplacelistings_id, ("move_to_marketplace_listings" != action), (("copy_or_move_to_marketplace_listings" == action)));
}
+ else if ("copy_folder_uuid" == action)
+ {
+ LLInventoryCategory* cat = gInventory.getCategory(mUUID);
+ if (!cat) return;
+ gViewerWindow->getWindow()->copyTextToClipboard(utf8str_to_wstring(mUUID.asString()));
+ return;
+ }
}
void LLFolderBridge::gatherMessage(std::string& message, S32 depth, LLError::ELevel log_level)
@@ -3607,7 +3748,7 @@ void LLFolderBridge::copyOutfitToClipboard()
gInventory.getDirectDescendentsOf(mUUID, cat_array, item_array);
size_t item_count(0);
- if( item_array )
+ if (item_array)
{
item_count = item_array->size();
}
@@ -3699,8 +3840,7 @@ void LLFolderBridge::restoreItem()
LLFolderType::EType LLFolderBridge::getPreferredType() const
{
LLFolderType::EType preferred_type = LLFolderType::FT_NONE;
- LLViewerInventoryCategory* cat = getCategory();
- if(cat)
+ if (LLViewerInventoryCategory* cat = getCategory())
{
preferred_type = cat->getPreferredType();
}
@@ -3742,7 +3882,6 @@ LLUIImagePtr LLFolderBridge::getIconOverlay() const
bool LLFolderBridge::renameItem(const std::string& new_name)
{
-
LLScrollOnRenameObserver *observer = new LLScrollOnRenameObserver(mUUID, mRoot);
gInventory.addObserver(observer);
@@ -3755,7 +3894,7 @@ bool LLFolderBridge::renameItem(const std::string& new_name)
bool LLFolderBridge::removeItem()
{
- if(!isItemRemovable())
+ if (!isItemRemovable())
{
return false;
}
@@ -3771,7 +3910,6 @@ bool LLFolderBridge::removeItem()
return true;
}
-
bool LLFolderBridge::removeSystemFolder()
{
const LLViewerInventoryCategory *cat = getCategory();
@@ -3971,7 +4109,6 @@ void LLFolderBridge::perform_pasteFromClipboard()
LLInventoryObject *obj = model->getObject(item_id);
if (obj)
{
-
if (move_is_into_lost_and_found)
{
if (LLAssetType::AT_CATEGORY == obj->getType())
@@ -3981,24 +4118,57 @@ void LLFolderBridge::perform_pasteFromClipboard()
}
if (move_is_into_outfit)
{
- if (!move_is_into_my_outfits && item && can_move_to_outfit(item, move_is_into_current_outfit))
+ bool handled = false;
+ if (mUUID != my_outifts_id
+ && dest_folder->getPreferredType() == LLFolderType::FT_OUTFIT
+ && item
+ && can_move_to_outfit(item, move_is_into_current_outfit))
{
dropToOutfit(item, move_is_into_current_outfit, cb);
+ handled = true;
}
else if (move_is_into_my_outfits && LLAssetType::AT_CATEGORY == obj->getType())
{
- LLInventoryCategory* cat = model->getCategory(item_id);
+ LLViewerInventoryCategory* cat = model->getCategory(item_id);
U32 max_items_to_wear = gSavedSettings.getU32("WearFolderLimit");
- if (cat && can_move_to_my_outfits(model, cat, max_items_to_wear))
+ if (cat && can_move_to_my_outfits_as_outfit(model, cat, max_items_to_wear))
{
- dropToMyOutfits(cat, cb);
+ if (mUUID == my_outifts_id)
+ {
+ dropToMyOutfits(cat, cb);
+ handled = true;
+ }
+ else
+ {
+ EMyOutfitsSubfolderType dest_res = myoutfit_object_subfolder_type(model, mUUID, my_outifts_id);
+ if (dest_res == MY_OUTFITS_SUBFOLDER)
+ {
+ // turn it into outfit
+ dropToMyOutfitsSubfolder(cat, mUUID, cb);
+ handled = true;
+ }
+ }
}
- else
+ if (!handled && cat && can_move_to_my_outfits_as_subfolder(model, cat))
{
- LLNotificationsUtil::add("MyOutfitsPasteFailed");
+ EMyOutfitsSubfolderType dest_res = myoutfit_object_subfolder_type(model, mUUID, my_outifts_id);
+ if (dest_res == MY_OUTFITS_SUBFOLDER || mUUID == my_outifts_id)
+ {
+ if (LLClipboard::instance().isCutMode())
+ {
+ changeCategoryParent(model, cat, parent_id, false);
+ }
+ else
+ {
+ copy_inventory_category(model, cat, parent_id);
+ }
+ if (cb) cb->fire(item_id);
+ handled = true;
+ }
}
}
- else
+
+ if (!handled)
{
LLNotificationsUtil::add("MyOutfitsPasteFailed");
}
@@ -4041,7 +4211,7 @@ void LLFolderBridge::perform_pasteFromClipboard()
// move_inventory_item() is not enough, as we have to update inventory locally too
if (LLAssetType::AT_CATEGORY == obj->getType())
{
- LLViewerInventoryCategory* vicat = (LLViewerInventoryCategory *) model->getCategory(item_id);
+ LLViewerInventoryCategory* vicat = model->getCategory(item_id);
llassert(vicat);
if (vicat)
{
@@ -4213,14 +4383,9 @@ void LLFolderBridge::staticFolderOptionsMenu()
bool LLFolderBridge::checkFolderForContentsOfType(LLInventoryModel* model, LLInventoryCollectFunctor& is_type)
{
- LLInventoryModel::cat_array_t cat_array;
- LLInventoryModel::item_array_t item_array;
- model->collectDescendentsIf(mUUID,
- cat_array,
- item_array,
+ return model->hasMatchingDescendents(mUUID,
LLInventoryModel::EXCLUDE_TRASH,
is_type);
- return !item_array.empty();
}
void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items, menuentry_vec_t& disabled_items)
@@ -4236,6 +4401,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items
if (outfits_id == mUUID)
{
+ items.push_back(std::string("New Outfit Folder"));
items.push_back(std::string("New Outfit"));
}
@@ -4329,63 +4495,83 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items
else if(isAgentInventory()) // do not allow creating in library
{
LLViewerInventoryCategory *cat = getCategory();
- // BAP removed protected check to re-enable standard ops in untyped folders.
- // Not sure what the right thing is to do here.
- if (!isCOFFolder() && cat && (cat->getPreferredType() != LLFolderType::FT_OUTFIT))
- {
- if (!isInboxFolder() // don't allow creation in inbox
- && outfits_id != mUUID)
- {
- bool menu_items_added = false;
- // Do not allow to create 2-level subfolder in the Calling Card/Friends folder. EXT-694.
- if (!LLFriendCardsManager::instance().isCategoryInFriendFolder(cat))
- {
- items.push_back(std::string("New Folder"));
- menu_items_added = true;
- }
- if (!isMarketplaceListingsFolder())
- {
- items.push_back(std::string("upload_def"));
- items.push_back(std::string("create_new"));
- items.push_back(std::string("New Script"));
- items.push_back(std::string("New Note"));
- items.push_back(std::string("New Gesture"));
- items.push_back(std::string("New Material"));
- items.push_back(std::string("New Clothes"));
- items.push_back(std::string("New Body Parts"));
- items.push_back(std::string("New Settings"));
- if (!LLEnvironment::instance().isInventoryEnabled())
- {
- disabled_items.push_back("New Settings");
- }
- }
- else
- {
- items.push_back(std::string("New Listing Folder"));
- }
- if (menu_items_added)
- {
- items.push_back(std::string("Create Separator"));
- }
- }
- getClipboardEntries(false, items, disabled_items, flags);
- }
- else
+
+ if (cat)
{
- // Want some but not all of the items from getClipboardEntries for outfits.
- if (cat && (cat->getPreferredType() == LLFolderType::FT_OUTFIT))
+ if (cat->getPreferredType() == LLFolderType::FT_OUTFIT)
{
+ // Want some but not all of the items from getClipboardEntries for outfits.
items.push_back(std::string("Rename"));
items.push_back(std::string("thumbnail"));
addDeleteContextMenuOptions(items, disabled_items);
// EXT-4030: disallow deletion of currently worn outfit
- const LLViewerInventoryItem *base_outfit_link = LLAppearanceMgr::instance().getBaseOutfitLink();
+ const LLViewerInventoryItem* base_outfit_link = LLAppearanceMgr::instance().getBaseOutfitLink();
if (base_outfit_link && (cat == base_outfit_link->getLinkedCategory()))
{
disabled_items.push_back(std::string("Delete"));
}
}
+ else if (outfits_id == mUUID)
+ {
+ getClipboardEntries(false, items, disabled_items, flags);
+ }
+ else if (!isCOFFolder())
+ {
+ EMyOutfitsSubfolderType in_my_outfits = myoutfit_object_subfolder_type(model, mUUID, outfits_id);
+ if (in_my_outfits != MY_OUTFITS_NO)
+ {
+ if (in_my_outfits == MY_OUTFITS_SUBFOLDER)
+ {
+ // Not inside an outfit, but inside 'my outfits'
+ items.push_back(std::string("New Outfit"));
+ items.push_back(std::string("New Outfit Folder"));
+ }
+ items.push_back(std::string("Rename"));
+ items.push_back(std::string("thumbnail"));
+
+ addDeleteContextMenuOptions(items, disabled_items);
+ }
+ else
+ {
+ if (!isInboxFolder() // don't allow creation in inbox
+ && outfits_id != mUUID)
+ {
+ bool menu_items_added = false;
+ // Do not allow to create 2-level subfolder in the Calling Card/Friends folder. EXT-694.
+ if (!LLFriendCardsManager::instance().isCategoryInFriendFolder(cat))
+ {
+ items.push_back(std::string("New Folder"));
+ menu_items_added = true;
+ }
+ if (!isMarketplaceListingsFolder())
+ {
+ items.push_back(std::string("upload_def"));
+ items.push_back(std::string("create_new"));
+ items.push_back(std::string("New Script"));
+ items.push_back(std::string("New Note"));
+ items.push_back(std::string("New Gesture"));
+ items.push_back(std::string("New Material"));
+ items.push_back(std::string("New Clothes"));
+ items.push_back(std::string("New Body Parts"));
+ items.push_back(std::string("New Settings"));
+ if (!LLEnvironment::instance().isInventoryEnabled())
+ {
+ disabled_items.push_back("New Settings");
+ }
+ }
+ else
+ {
+ items.push_back(std::string("New Listing Folder"));
+ }
+ if (menu_items_added)
+ {
+ items.push_back(std::string("Create Separator"));
+ }
+ }
+ getClipboardEntries(false, items, disabled_items, flags);
+ }
+ }
}
if (model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT) == mUUID)
@@ -4397,21 +4583,26 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items
//Added by aura to force inventory pull on right-click to display folder options correctly. 07-17-06
mCallingCards = mWearables = false;
- LLIsType is_callingcard(LLAssetType::AT_CALLINGCARD);
- if (checkFolderForContentsOfType(model, is_callingcard))
+ if (gInventory.getRootFolderID() != mUUID)
{
- mCallingCards=true;
- }
+ LLIsType is_callingcard(LLAssetType::AT_CALLINGCARD);
+ if (checkFolderForContentsOfType(model, is_callingcard))
+ {
+ mCallingCards = true;
+ }
- LLFindWearables is_wearable;
- LLIsType is_object( LLAssetType::AT_OBJECT );
- LLIsType is_gesture( LLAssetType::AT_GESTURE );
+ const std::vector<LLAssetType::EType> types = { LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART, LLAssetType::AT_OBJECT, LLAssetType::AT_GESTURE };
+ LLIsOneOfTypes is_wearable(types);
- if (checkFolderForContentsOfType(model, is_wearable) ||
- checkFolderForContentsOfType(model, is_object) ||
- checkFolderForContentsOfType(model, is_gesture) )
+ if (checkFolderForContentsOfType(model, is_wearable))
+ {
+ mWearables = true;
+ }
+ }
+ else
{
- mWearables=true;
+ // Assume that there are wearables in the root folder
+ mWearables = true;
}
items.push_back(std::string("Set favorite folder"));
@@ -4426,13 +4617,10 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items
LLFolderType::EType type = category->getPreferredType();
const bool is_system_folder = LLFolderType::lookupIsProtectedType(type);
- LLFindWearables is_wearable;
- LLIsType is_object(LLAssetType::AT_OBJECT);
- LLIsType is_gesture(LLAssetType::AT_GESTURE);
+ const std::vector<LLAssetType::EType> types = { LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART, LLAssetType::AT_OBJECT, LLAssetType::AT_GESTURE };
+ LLIsOneOfTypes is_wearable(types);
- if (checkFolderForContentsOfType(model, is_wearable) ||
- checkFolderForContentsOfType(model, is_object) ||
- checkFolderForContentsOfType(model, is_gesture))
+ if (checkFolderForContentsOfType(model, is_wearable))
{
mWearables = true;
}
@@ -4453,6 +4641,14 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items
{
disabled_items.push_back(std::string("Delete System Folder"));
}
+ else
+ {
+ static LLCachedControl<bool> show_copy_id(gSavedSettings, "InventoryExposeFolderID", false);
+ if (show_copy_id())
+ {
+ items.push_back(std::string("Copy UUID"));
+ }
+ }
if (isAgentInventory() && !isMarketplaceListingsFolder())
{
@@ -4530,7 +4726,11 @@ void LLFolderBridge::buildContextMenuFolderOptions(U32 flags, menuentry_vec_t&
if (((flags & ITEM_IN_MULTI_SELECTION) == 0) && hasChildren() && (type != LLFolderType::FT_OUTFIT))
{
- items.push_back(std::string("Ungroup folder items"));
+ const LLUUID my_outfits = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS);
+ if (!gInventory.isObjectDescendentOf(mUUID, my_outfits))
+ {
+ items.push_back(std::string("Ungroup folder items"));
+ }
}
}
else
@@ -4555,14 +4755,11 @@ void LLFolderBridge::buildContextMenuFolderOptions(U32 flags, menuentry_vec_t&
// wearables related functionality for folders.
//is_wearable
- LLFindWearables is_wearable;
- LLIsType is_object( LLAssetType::AT_OBJECT );
- LLIsType is_gesture( LLAssetType::AT_GESTURE );
+ const std::vector<LLAssetType::EType> types = { LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART, LLAssetType::AT_OBJECT, LLAssetType::AT_GESTURE };
+ LLIsOneOfTypes is_wearable(types);
if (mWearables ||
- checkFolderForContentsOfType(model, is_wearable) ||
- checkFolderForContentsOfType(model, is_object) ||
- checkFolderForContentsOfType(model, is_gesture) )
+ checkFolderForContentsOfType(model, is_wearable))
{
// Only enable add/replace outfit for non-system folders.
if (!is_system_folder)
@@ -5306,13 +5503,23 @@ void LLFolderBridge::dropToMyOutfits(LLInventoryCategory* inv_cat, LLPointer<LLI
// Note: creation will take time, so passing folder id to callback is slightly unreliable,
// but so is collecting and passing descendants' ids
inventory_func_type func = boost::bind(outfitFolderCreatedCallback, inv_cat->getUUID(), _1, cb, mInventoryPanel);
- gInventory.createNewCategory(dest_id,
+ getInventoryModel()->createNewCategory(dest_id,
LLFolderType::FT_OUTFIT,
inv_cat->getName(),
func,
inv_cat->getThumbnailUUID());
}
+void LLFolderBridge::dropToMyOutfitsSubfolder(LLInventoryCategory* inv_cat, const LLUUID& dest_id, LLPointer<LLInventoryCallback> cb)
+{
+ inventory_func_type func = boost::bind(outfitFolderCreatedCallback, inv_cat->getUUID(), _1, cb, mInventoryPanel);
+ getInventoryModel()->createNewCategory(dest_id,
+ LLFolderType::FT_OUTFIT,
+ inv_cat->getName(),
+ func,
+ inv_cat->getThumbnailUUID());
+}
+
void LLFolderBridge::outfitFolderCreatedCallback(LLUUID cat_source_id,
LLUUID cat_dest_id,
LLPointer<LLInventoryCallback> cb,
@@ -5486,7 +5693,9 @@ bool LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
}
else if (user_confirm && (move_is_into_current_outfit || move_is_into_outfit))
{
- accept = can_move_to_outfit(inv_item, move_is_into_current_outfit);
+ EMyOutfitsSubfolderType res = myoutfit_object_subfolder_type(model, mUUID, my_outifts_id);
+ // don't allow items in my outfits' subfodlers, only in outfits and outfit's subfolders
+ accept = res != MY_OUTFITS_SUBFOLDER && can_move_to_outfit(inv_item, move_is_into_current_outfit);
}
else if (user_confirm && (move_is_into_favorites || move_is_into_landmarks))
{