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.cpp187
1 files changed, 125 insertions, 62 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index ef58e4fa21..d55fb6a089 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -47,7 +47,7 @@
#include "llgiveinventory.h"
#include "llimfloater.h"
#include "llimview.h"
-#include "llinventoryclipboard.h"
+#include "llclipboard.h"
#include "llinventorydefines.h"
#include "llinventoryfunctions.h"
#include "llinventorymodel.h"
@@ -215,13 +215,27 @@ BOOL LLInvFVBridge::isLink() const
/**
* @brief Adds this item into clipboard storage
*/
-void LLInvFVBridge::cutToClipboard()
+BOOL LLInvFVBridge::cutToClipboard() const
{
- if(isItemMovable())
+ const LLInventoryObject* obj = gInventory.getObject(mUUID);
+ if (obj && isItemMovable() && isItemRemovable())
{
- LLInventoryClipboard::instance().cut(mUUID);
+ LLClipboard::getInstance()->setCutMode(true, boost::bind(LLFolderView::removeCutItems));
+ return LLClipboard::getInstance()->addToClipboard(mUUID);
}
+ return FALSE;
}
+
+BOOL LLInvFVBridge::copyToClipboard() const
+{
+ const LLInventoryObject* obj = gInventory.getObject(mUUID);
+ if (obj && isItemCopyable())
+ {
+ return LLClipboard::getInstance()->addToClipboard(mUUID);
+ }
+ return FALSE;
+}
+
// *TODO: make sure this does the right thing
void LLInvFVBridge::showProperties()
{
@@ -405,7 +419,7 @@ void LLInvFVBridge::removeBatchNoCheck(LLDynamicArray<LLFolderViewEventListener*
BOOL LLInvFVBridge::isClipboardPasteable() const
{
- if (!LLInventoryClipboard::instance().hasContents() || !isAgentInventory())
+ if (!LLClipboard::getInstance()->hasContents() || !isAgentInventory())
{
return FALSE;
}
@@ -415,37 +429,35 @@ BOOL LLInvFVBridge::isClipboardPasteable() const
return FALSE;
}
- const LLUUID &agent_id = gAgent.getID();
-
LLDynamicArray<LLUUID> objects;
- LLInventoryClipboard::instance().retrieve(objects);
+ LLClipboard::getInstance()->pasteFromClipboard(objects);
S32 count = objects.count();
for(S32 i = 0; i < count; i++)
{
const LLUUID &item_id = objects.get(i);
- // Can't paste folders
+ // Folders are pastable if all items in there are copyable
const LLInventoryCategory *cat = model->getCategory(item_id);
- if (cat)
- {
- return FALSE;
- }
-
- const LLInventoryItem *item = model->getItem(item_id);
- if (item)
+ if (cat)
{
- if (!item->getPermissions().allowCopyBy(agent_id))
- {
+ LLFolderBridge cat_br(mInventoryPanel.get(), mRoot, item_id);
+ if (!cat_br.isItemCopyable())
return FALSE;
- }
+ // Skip to the next item in the clipboard
+ continue;
}
+
+ // Each item must be copyable to be pastable
+ LLItemBridge item_br(mInventoryPanel.get(), mRoot, item_id);
+ if (!item_br.isItemCopyable())
+ return FALSE;
}
return TRUE;
}
BOOL LLInvFVBridge::isClipboardPasteableAsLink() const
{
- if (!LLInventoryClipboard::instance().hasContents() || !isAgentInventory())
+ if (!LLClipboard::getInstance()->hasContents() || !isAgentInventory())
{
return FALSE;
}
@@ -456,7 +468,7 @@ BOOL LLInvFVBridge::isClipboardPasteableAsLink() const
}
LLDynamicArray<LLUUID> objects;
- LLInventoryClipboard::instance().retrieve(objects);
+ LLClipboard::getInstance()->pasteFromClipboard(objects);
S32 count = objects.count();
for(S32 i = 0; i < count; i++)
{
@@ -607,6 +619,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"));
@@ -625,7 +643,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
{
items.push_back(std::string("Paste"));
}
- if (!isClipboardPasteable() || ((flags & FIRST_SELECTED_ITEM) == 0))
+ if ((!LLClipboard::getInstance()->isCutMode() && !isClipboardPasteable()) || ((flags & FIRST_SELECTED_ITEM) == 0))
{
disabled_items.push_back(std::string("Paste"));
}
@@ -1286,6 +1304,11 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action)
gViewerWindow->getWindow()->copyTextToClipboard(utf8str_to_wstring(buffer));
return;
}
+ else if ("cut" == action)
+ {
+ cutToClipboard();
+ return;
+ }
else if ("copy" == action)
{
copyToClipboard();
@@ -1293,7 +1316,6 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action)
}
else if ("paste" == action)
{
- // Single item only
LLInventoryItem* itemp = model->getItem(mUUID);
if (!itemp) return;
@@ -1668,16 +1690,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;
@@ -1776,18 +1788,34 @@ BOOL LLFolderBridge::isUpToDate() const
BOOL LLFolderBridge::isItemCopyable() const
{
- // Can copy folders to paste-as-link, but not for straight paste.
- return gSavedSettings.getBOOL("InventoryLinking");
-}
+ // 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);
+
+ // 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(mInventoryPanel.get(), 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(mInventoryPanel.get(), mRoot, category->getUUID());
+ if (!cat_br.isItemCopyable())
+ return FALSE;
+ }
+
+ return TRUE;
}
BOOL LLFolderBridge::isClipboardPasteable() const
@@ -1805,7 +1833,7 @@ BOOL LLFolderBridge::isClipboardPasteable() const
}
LLDynamicArray<LLUUID> objects;
- LLInventoryClipboard::instance().retrieve(objects);
+ LLClipboard::getInstance()->pasteFromClipboard(objects);
const LLViewerInventoryCategory *current_cat = getCategory();
// Search for the direct descendent of current Friends subfolder among all pasted items,
@@ -1843,7 +1871,7 @@ BOOL LLFolderBridge::isClipboardPasteableAsLink() const
const BOOL is_in_friend_folder = LLFriendCardsManager::instance().isCategoryInFriendFolder( current_cat );
const LLUUID &current_cat_id = current_cat->getUUID();
LLDynamicArray<LLUUID> objects;
- LLInventoryClipboard::instance().retrieve(objects);
+ LLClipboard::getInstance()->pasteFromClipboard(objects);
S32 count = objects.count();
for(S32 i = 0; i < count; i++)
{
@@ -2666,6 +2694,11 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
modifyOutfit(TRUE);
return;
}
+ else if ("cut" == action)
+ {
+ cutToClipboard();
+ return;
+ }
else if ("copy" == action)
{
copyToClipboard();
@@ -2877,7 +2910,7 @@ bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& re
void LLFolderBridge::pasteFromClipboard()
{
LLInventoryModel* model = getInventoryModel();
- if(model && isClipboardPasteable())
+ if (model && (isClipboardPasteable() || LLClipboard::getInstance()->isCutMode()))
{
const LLUUID &current_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, false);
const LLUUID &outbox_id = model->findCategoryUUIDForType(LLFolderType::FT_OUTBOX, false);
@@ -2887,7 +2920,7 @@ void LLFolderBridge::pasteFromClipboard()
const BOOL move_is_into_outbox = model->isObjectDescendentOf(mUUID, outbox_id);
LLDynamicArray<LLUUID> objects;
- LLInventoryClipboard::instance().retrieve(objects);
+ LLClipboard::getInstance()->pasteFromClipboard(objects);
if (move_is_into_outbox)
{
@@ -2937,7 +2970,8 @@ void LLFolderBridge::pasteFromClipboard()
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)
{
@@ -2946,29 +2980,56 @@ void LLFolderBridge::pasteFromClipboard()
dropToOutfit(item, move_is_into_current_outfit);
}
}
- else if(LLInventoryClipboard::instance().isCutMode())
+ else if (LLClipboard::getInstance()->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())
+ {
+ LLViewerInventoryCategory* vicat = (LLViewerInventoryCategory *) model->getCategory(item_id);
+ llassert(vicat);
+ if (vicat)
+ {
+ changeCategoryParent(model, vicat, parent_id, FALSE);
+ }
+ }
+ else
{
- changeItemParent(model, viitem, parent_id, FALSE);
+ 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 paste for next paste
+ LLClipboard::getInstance()->setCutMode(false);
}
}
@@ -2993,7 +3054,7 @@ void LLFolderBridge::pasteLinkFromClipboard()
const LLUUID parent_id(mUUID);
LLDynamicArray<LLUUID> objects;
- LLInventoryClipboard::instance().retrieve(objects);
+ LLClipboard::getInstance()->pasteFromClipboard(objects);
for (LLDynamicArray<LLUUID>::const_iterator iter = objects.begin();
iter != objects.end();
++iter)
@@ -3031,6 +3092,8 @@ void LLFolderBridge::pasteLinkFromClipboard()
LLPointer<LLInventoryCallback>(NULL));
}
}
+ // Change mode to paste for next paste
+ LLClipboard::getInstance()->setCutMode(false);
}
}