DD-20 : WIP : Implemented the cut and paste code for marketplace. Stock update still not working as expected.

meow-7.2.2
Merov Linden 2014-04-01 21:41:18 -07:00
parent 69fb50322e
commit f66de28a7c
4 changed files with 105 additions and 39 deletions

View File

@ -3264,13 +3264,12 @@ void LLFolderBridge::pasteFromClipboard()
{
const LLUUID &current_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, false);
const LLUUID &outbox_id = model->findCategoryUUIDForType(LLFolderType::FT_OUTBOX, false);
const LLUUID &marketplacelistings_id = model->findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
const BOOL move_is_into_current_outfit = (mUUID == current_outfit_id);
const BOOL move_is_into_outfit = (getCategory() && getCategory()->getPreferredType()==LLFolderType::FT_OUTFIT);
const BOOL move_is_into_outbox = model->isObjectDescendentOf(mUUID, outbox_id);
// *TODO : Add marketplace listings case
//const LLUUID &marketplacelistings_id = model->findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
//const BOOL move_is_into_marketplacelistings = model->isObjectDescendentOf(mUUID, marketplacelistings_id);
const BOOL move_is_into_marketplacelistings = model->isObjectDescendentOf(mUUID, marketplacelistings_id);
LLDynamicArray<LLUUID> objects;
LLClipboard::instance().pasteFromClipboard(objects);
@ -3342,21 +3341,35 @@ void LLFolderBridge::pasteFromClipboard()
LLViewerInventoryCategory* vicat = (LLViewerInventoryCategory *) model->getCategory(item_id);
llassert(vicat);
if (vicat)
{
//changeCategoryParent() implicity calls dirtyFilter
changeCategoryParent(model, vicat, parent_id, FALSE);
{
if (move_is_into_marketplacelistings)
{
move_folder_to_marketplacelistings(vicat, parent_id);
}
else
{
//changeCategoryParent() implicity calls dirtyFilter
changeCategoryParent(model, vicat, parent_id, FALSE);
}
}
}
else
{
LLViewerInventoryItem* viitem = dynamic_cast<LLViewerInventoryItem*>(item);
llassert(viitem);
if (viitem)
{
//changeItemParent() implicity calls dirtyFilter
changeItemParent(model, viitem, parent_id, FALSE);
}
}
{
LLViewerInventoryItem* viitem = dynamic_cast<LLViewerInventoryItem*>(item);
llassert(viitem);
if (viitem)
{
if (move_is_into_marketplacelistings)
{
move_item_to_marketplacelistings(viitem, parent_id);
}
else
{
//changeItemParent() implicity calls dirtyFilter
changeItemParent(model, viitem, parent_id, FALSE);
}
}
}
}
else
{
@ -3367,22 +3380,41 @@ void LLFolderBridge::pasteFromClipboard()
llassert(vicat);
if (vicat)
{
copy_inventory_category(model, vicat, parent_id);
if (move_is_into_marketplacelistings)
{
move_folder_to_marketplacelistings(vicat, parent_id, true);
}
else
{
copy_inventory_category(model, vicat, parent_id);
}
}
}
else
{
copy_inventory_item(
gAgent.getID(),
item->getPermissions().getOwner(),
item->getUUID(),
parent_id,
std::string(),
LLPointer<LLInventoryCallback>(NULL));
}
}
}
}
else
{
LLViewerInventoryItem* viitem = dynamic_cast<LLViewerInventoryItem*>(item);
llassert(viitem);
if (viitem)
{
if (move_is_into_marketplacelistings)
{
move_item_to_marketplacelistings(viitem, parent_id, true);
}
else
{
copy_inventory_item(
gAgent.getID(),
item->getPermissions().getOwner(),
item->getUUID(),
parent_id,
std::string(),
LLPointer<LLInventoryCallback>(NULL));
}
}
}
}
}
}
// Change mode to paste for next paste
LLClipboard::instance().setCutMode(false);
}

View File

@ -688,7 +688,15 @@ void copy_folder_to_outbox(LLInventoryCategory* inv_cat, const LLUUID& dest_fold
open_outbox();
}
void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_folder)
///----------------------------------------------------------------------------
// Marketplace functions
//
// Handles Copy and Move to or within the Marketplace listings folder.
// Handles creation of stock folders, nesting of listings and version folders,
// permission checking and listings validation.
///----------------------------------------------------------------------------
void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_folder, bool copy)
{
// Get the marketplace listings, exit with error if none
const LLUUID marketplace_listings_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
@ -705,7 +713,7 @@ void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol
if (linked_category != NULL)
{
// Move the linked folder directly
move_folder_to_marketplacelistings(linked_category, dest_folder);
move_folder_to_marketplacelistings(linked_category, dest_folder, copy);
}
else
{
@ -733,10 +741,25 @@ void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol
// Get the parent folder of the moved item : we may have to update it
LLUUID src_folder = viewer_inv_item->getParentUUID();
LLViewerInventoryCategory* src_cat = gInventory.getCategory(src_folder);
LLViewerInventoryCategory* src_cat = gInventory.getCategory(src_folder);
// Reparent the item
gInventory.changeItemParent(viewer_inv_item, dest_folder, false);
if (copy)
{
// Copy the item
copy_inventory_item(
gAgent.getID(),
viewer_inv_item->getPermissions().getOwner(),
viewer_inv_item->getUUID(),
dest_folder,
std::string(),
LLPointer<LLInventoryCallback>(NULL));
}
else
{
// Reparent the item
gInventory.changeItemParent(viewer_inv_item, dest_folder, false);
}
// Update the modified folders
gInventory.updateCategory(src_cat);
@ -754,7 +777,7 @@ void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol
}
}
void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUUID& dest_folder)
void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUUID& dest_folder, bool copy)
{
// Check that we have adequate permission on all items being moved. Proceed if we do.
if (has_correct_permissions_for_sale(inv_cat))
@ -767,9 +790,17 @@ void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUU
LLUUID src_folder = inv_cat->getParentUUID();
LLViewerInventoryCategory* src_cat = gInventory.getCategory(src_folder);
// Reparent the folder
LLViewerInventoryCategory * viewer_inv_cat = (LLViewerInventoryCategory *) inv_cat;
gInventory.changeCategoryParent(viewer_inv_cat, dest_folder, false);
if (copy)
{
// Copy the folder
copy_inventory_category(&gInventory, viewer_inv_cat, dest_folder);
}
else
{
// Reparent the folder
gInventory.changeCategoryParent(viewer_inv_cat, dest_folder, false);
}
// Update the modified folders
gInventory.updateCategory(src_cat);

View File

@ -72,8 +72,8 @@ void copy_item_to_outbox(LLInventoryItem* inv_item, LLUUID dest_folder, const LL
void move_item_within_outbox(LLInventoryItem* inv_item, LLUUID dest_folder, S32 operation_id);
void copy_folder_to_outbox(LLInventoryCategory* inv_cat, const LLUUID& dest_folder, const LLUUID& top_level_folder, S32 operation_id);
void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_folder);
void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUUID& dest_folder);
void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_folder, bool copy = false);
void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUUID& dest_folder, bool copy = false);
bool has_correct_permissions_for_sale(LLInventoryCategory* cat);
void validate_marketplacelistings(LLInventoryCategory* inv_cat);

View File

@ -1056,7 +1056,10 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat)
const LLUUID marketplace_id = findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
if (marketplace_id.notNull() && isObjectDescendentOf(cat->getUUID(), marketplace_id))
{
// *TODO : Need some internal analysis to be less brutal with updates
mask |= LLInventoryObserver::LABEL;
mask |= LLInventoryObserver::STRUCTURE;
mask |= LLInventoryObserver::INTERNAL;
}
old_cat->copyViewerCategory(cat);
addChangedMask(mask, cat->getUUID());