This commit is contained in:
Shyotl
2012-12-08 17:13:07 -06:00
18 changed files with 417 additions and 137 deletions

View File

@@ -319,7 +319,6 @@ BOOL LLInvFVBridge::isLink() const
/**
* @brief Adds this item into clipboard storage
*/
//Unused.
void LLInvFVBridge::cutToClipboard()
{
if(isItemMovable())
@@ -327,6 +326,18 @@ void LLInvFVBridge::cutToClipboard()
LLInventoryClipboard::instance().cut(mUUID);
}
}
BOOL LLInvFVBridge::copyToClipboard() const
{
const LLInventoryObject* obj = gInventory.getObject(mUUID);
if (obj && isItemCopyable())
{
LLInventoryClipboard::instance().add(mUUID);
return true;
}
return FALSE;
}
// *TODO: make sure this does the right thing
void LLInvFVBridge::showProperties()
{
@@ -556,6 +567,7 @@ void LLInvFVBridge::removeBatchNoCheck(LLDynamicArray<LLFolderViewEventListener*
BOOL LLInvFVBridge::isClipboardPasteable() const
{
// Return FALSE on degenerated cases: empty clipboard, no inventory, no agent
if (!LLInventoryClipboard::instance().hasContents() || !isAgentInventory())
{
return FALSE;
@@ -566,8 +578,14 @@ BOOL LLInvFVBridge::isClipboardPasteable() const
return FALSE;
}
const LLUUID &agent_id = gAgent.getID();
// In cut mode, whatever is on the clipboard is always pastable
if (LLInventoryClipboard::instance().isCutMode())
{
return TRUE;
}
// In normal mode, we need to check each element of the clipboard to know if we can paste or not
LLInventoryPanel* panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get());
LLDynamicArray<LLUUID> objects;
LLInventoryClipboard::instance().retrieve(objects);
S32 count = objects.count();
@@ -575,21 +593,21 @@ BOOL LLInvFVBridge::isClipboardPasteable() const
{
const LLUUID &item_id = objects.get(i);
// Can't paste folders
// Folders are pasteable if all items in there are copyable
const LLInventoryCategory *cat = model->getCategory(item_id);
if (cat)
{
return FALSE;
LLFolderBridge cat_br(panel, mRoot, item_id);
if (!cat_br.isItemCopyable())
return FALSE;
// Skip to the next item in the clipboard
continue;
}
const LLInventoryItem *item = model->getItem(item_id);
if (item)
{
if (!item->getPermissions().allowCopyBy(agent_id))
{
return FALSE;
}
}
// Each item must be copyable to be pasteable
LLItemBridge item_br(panel, mRoot, item_id);
if (!item_br.isItemCopyable())
return FALSE;
}
return TRUE;
}
@@ -761,6 +779,12 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
disabled_items.push_back(std::string("Copy"));
}
items.push_back(std::string("Cut"));
if (!isItemMovable() || !isItemRemovable())
{
disabled_items.push_back(std::string("Cut"));
}
if (canListOnMarketplace())
{
items.push_back(std::string("Marketplace Separator"));
@@ -919,7 +943,7 @@ void LLInvFVBridge::addOutboxContextMenuOptions(U32 flags,
items.push_back(std::string("Marketplace Separator"));
items.push_back(std::string("Marketplace Send"));
if ((flags & FIRST_SELECTED_ITEM) == 0)
if (!canListOnMarketplaceNow() || (flags & FIRST_SELECTED_ITEM) == 0)
{
disabled_items.push_back(std::string("Marketplace Send"));
}
@@ -1423,6 +1447,12 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action)
gViewerWindow->getWindow()->copyTextToClipboard(utf8str_to_wstring(buffer));
return;
}
else if ("cut" == action)
{
cutToClipboard();
LLFolderView::removeCutItems();
return;
}
else if ("copy" == action)
{
copyToClipboard();
@@ -1430,7 +1460,6 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action)
}
else if ("paste" == action)
{
// Single item only
LLInventoryItem* itemp = model->getItem(mUUID);
if (!itemp) return;
@@ -1855,16 +1884,6 @@ BOOL LLItemBridge::isItemCopyable() const
return FALSE;
}
BOOL LLItemBridge::copyToClipboard() const
{
if(isItemCopyable())
{
LLInventoryClipboard::instance().add(mUUID);
return TRUE;
}
return FALSE;
}
LLViewerInventoryItem* LLItemBridge::getItem() const
{
LLViewerInventoryItem* item = NULL;
@@ -1963,18 +1982,36 @@ BOOL LLFolderBridge::isUpToDate() const
BOOL LLFolderBridge::isItemCopyable() const
{
// Can copy folders to paste-as-link, but not for straight paste.
return InventoryLinksEnabled();
}
// Folders are copyable if items in them are, recursively, copyable.
BOOL LLFolderBridge::copyToClipboard() const
{
if(isItemCopyable())
// Get the content of the folder
LLInventoryModel::cat_array_t* cat_array;
LLInventoryModel::item_array_t* item_array;
gInventory.getDirectDescendentsOf(mUUID,cat_array,item_array);
LLInventoryPanel* panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get());
// Check the items
LLInventoryModel::item_array_t item_array_copy = *item_array;
for (LLInventoryModel::item_array_t::iterator iter = item_array_copy.begin(); iter != item_array_copy.end(); iter++)
{
LLInventoryClipboard::instance().add(mUUID);
return TRUE;
LLInventoryItem* item = *iter;
LLItemBridge item_br(panel, mRoot, item->getUUID());
if (!item_br.isItemCopyable())
return FALSE;
}
return FALSE;
// Check the folders
LLInventoryModel::cat_array_t cat_array_copy = *cat_array;
for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++)
{
LLViewerInventoryCategory* category = *iter;
LLFolderBridge cat_br(panel, mRoot, category->getUUID());
if (!cat_br.isItemCopyable())
return FALSE;
}
return TRUE;
}
BOOL LLFolderBridge::isClipboardPasteable() const
@@ -2807,6 +2844,12 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
modifyOutfit(TRUE);
return;
}
else if ("cut" == action)
{
cutToClipboard();
LLFolderView::removeCutItems();
return;
}
else if ("copy" == action)
{
copyToClipboard();
@@ -3026,6 +3069,7 @@ 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 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);
@@ -3079,8 +3123,10 @@ void LLFolderBridge::pasteFromClipboard()
++iter)
{
const LLUUID& item_id = (*iter);
LLInventoryItem *item = model->getItem(item_id);
if (item)
LLInventoryObject *obj = model->getObject(item_id);
if (obj)
{
if (move_is_into_current_outfit || move_is_into_outfit)
{
@@ -3091,29 +3137,56 @@ void LLFolderBridge::pasteFromClipboard()
}
else if(LLInventoryClipboard::instance().isCutMode())
{
// move_inventory_item() is not enough,
//we have to update inventory locally too
LLViewerInventoryItem* viitem = dynamic_cast<LLViewerInventoryItem*>(item);
llassert(viitem);
if (viitem)
// Do a move to "paste" a "cut"
// move_inventory_item() is not enough, as we have to update inventory locally too
if (LLAssetType::AT_CATEGORY == obj->getType())
{
changeItemParent(model, viitem, parent_id, FALSE);
LLViewerInventoryCategory* vicat = (LLViewerInventoryCategory *) model->getCategory(item_id);
llassert(vicat);
if (vicat)
{
changeCategoryParent(model, vicat, parent_id, FALSE);
}
}
else
{
LLViewerInventoryItem* viitem = dynamic_cast<LLViewerInventoryItem*>(item);
llassert(viitem);
if (viitem)
{
changeItemParent(model, viitem, parent_id, FALSE);
}
}
}
else
{
copy_inventory_item(
gAgent.getID(),
item->getPermissions().getOwner(),
item->getUUID(),
parent_id,
std::string(),
LLPointer<LLInventoryCallback>(NULL));
// Do a "copy" to "paste" a regular copy clipboard
if (LLAssetType::AT_CATEGORY == obj->getType())
{
LLViewerInventoryCategory* vicat = (LLViewerInventoryCategory *) model->getCategory(item_id);
llassert(vicat);
if (vicat)
{
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));
}
}
}
}
// Change mode to copy for next paste
LLInventoryClipboard::instance().setCutMode(false);
}
}
}
void LLFolderBridge::pasteLinkFromClipboard()
{
@@ -3121,8 +3194,17 @@ void LLFolderBridge::pasteLinkFromClipboard()
if(model)
{
const LLUUID &current_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, false);
const LLUUID &outbox_id = model->findCategoryUUIDForType(LLFolderType::FT_OUTBOX, 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);
if (move_is_into_outbox)
{
// Notify user of failure somehow -- play error sound? modal dialog?
return;
}
const LLUUID parent_id(mUUID);
@@ -3165,6 +3247,7 @@ void LLFolderBridge::pasteLinkFromClipboard()
LLPointer<LLInventoryCallback>(NULL));
}
}
//Singu Note: Don't setCutMode(false) here, we can link now but real paste later.
}
}