summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2012-02-09 23:37:24 -0800
committerMerov Linden <merov@lindenlab.com>2012-02-09 23:37:24 -0800
commit2a4aa438f5798c34f1eef3ef75dc3289492138e1 (patch)
tree06ef82d5d556f0ae4c275588886fa99371154414 /indra/newview
parent10dadc6b0dd646faa251c0935e75d07c97b3052d (diff)
EXP-1863 : Implemented cut, copy, paste for folders. Issues with folder filtering though.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llinventorybridge.cpp82
-rw-r--r--indra/newview/llinventoryfilter.cpp45
-rw-r--r--indra/newview/llinventoryfunctions.cpp36
-rw-r--r--indra/newview/llinventoryfunctions.h2
4 files changed, 131 insertions, 34 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 9775e54d6a..1fa6820d2d 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -210,21 +210,21 @@ BOOL LLInvFVBridge::isLink() const
*/
BOOL LLInvFVBridge::cutToClipboard() const
{
- LLViewerInventoryItem* inv_item = gInventory.getItem(mUUID);
- if (inv_item && isItemMovable() && isItemRemovable())
+ const LLInventoryObject* obj = gInventory.getObject(mUUID);
+ if (obj && isItemMovable() && isItemRemovable())
{
LLClipboard::getInstance()->setCutMode(true);
- return LLClipboard::getInstance()->addToClipboard(mUUID,inv_item->getType());
+ return LLClipboard::getInstance()->addToClipboard(mUUID,obj->getType());
}
return FALSE;
}
BOOL LLInvFVBridge::copyToClipboard() const
{
- LLViewerInventoryItem* inv_item = gInventory.getItem(mUUID);
- if (inv_item && isItemCopyable())
+ const LLInventoryObject* obj = gInventory.getObject(mUUID);
+ if (obj && isItemCopyable())
{
- return LLClipboard::getInstance()->addToClipboard(mUUID,inv_item->getType());
+ return LLClipboard::getInstance()->addToClipboard(mUUID,obj->getType());
}
return FALSE;
}
@@ -423,9 +423,6 @@ BOOL LLInvFVBridge::isClipboardPasteable() const
const LLUUID &agent_id = gAgent.getID();
- // Merov : This should be suppressed for 2 reasons:
- // 1. folders should be pastable
- // 2. when pasting, we should paste what is authorized and let the rest not pasted
LLDynamicArray<LLUUID> objects;
LLClipboard::getInstance()->pasteFromClipboard(objects);
S32 count = objects.count();
@@ -433,12 +430,9 @@ BOOL LLInvFVBridge::isClipboardPasteable() const
{
const LLUUID &item_id = objects.get(i);
- // Can't paste folders
+ // Always paste folders
const LLInventoryCategory *cat = model->getCategory(item_id);
- if (cat)
- {
- return FALSE;
- }
+ if (cat) continue;
const LLInventoryItem *item = model->getItem(item_id);
if (item)
@@ -1313,7 +1307,6 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action)
}
else if ("paste" == action)
{
- // Single item only
LLInventoryItem* itemp = model->getItem(mUUID);
if (!itemp) return;
@@ -1785,8 +1778,9 @@ BOOL LLFolderBridge::isUpToDate() const
BOOL LLFolderBridge::isItemCopyable() const
{
+ return TRUE;
// Can copy folders to paste-as-link, but not for straight paste.
- return gSavedSettings.getBOOL("InventoryLinking");
+ //return gSavedSettings.getBOOL("InventoryLinking");
}
BOOL LLFolderBridge::isClipboardPasteable() const
@@ -2829,7 +2823,7 @@ bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& re
void LLFolderBridge::pasteFromClipboard()
{
LLInventoryModel* model = getInventoryModel();
- if(model && isClipboardPasteable())
+ if (model && isClipboardPasteable())
{
const LLUUID &current_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, false);
const BOOL move_is_into_current_outfit = (mUUID == current_outfit_id);
@@ -2845,7 +2839,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)
{
@@ -2856,24 +2851,49 @@ void LLFolderBridge::pasteFromClipboard()
}
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())
{
- 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));
+ }
}
}
}
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index 9d12478019..808b7619eb 100644
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -240,12 +240,26 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con
////////////////////////////////////////////////////////////////////////////////
// FILTERTYPE_CLIPBOARD
- // Pass if this item is not on the clipboard
+ // Pass if this item is not on the clipboard or is not a descendant of a folder
+ // which is on the clipboard
if (filterTypes & FILTERTYPE_CLIPBOARD)
{
- if (LLClipboard::getInstance()->isCutMode() && LLClipboard::getInstance()->isOnClipboard(object_id))
+ if (LLClipboard::getInstance()->isCutMode())
{
- return FALSE;
+ LLUUID current_id = object_id;
+ LLInventoryObject *current_object = gInventory.getObject(object_id);
+ while (current_id.notNull())
+ {
+ if (LLClipboard::getInstance()->isOnClipboard(current_id))
+ {
+ return FALSE;
+ }
+ current_id = current_object->getParentUUID();
+ if (current_id.notNull())
+ {
+ current_object = gInventory.getObject(current_id);
+ }
+ }
}
}
@@ -309,6 +323,31 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLInventoryItem* item) cons
return false;
}
+ ////////////////////////////////////////////////////////////////////////////////
+ // FILTERTYPE_CLIPBOARD
+ // Pass if this item is not on the clipboard or is not a descendant of a folder
+ // which is on the clipboard
+ if (filterTypes & FILTERTYPE_CLIPBOARD)
+ {
+ if (LLClipboard::getInstance()->isCutMode())
+ {
+ LLUUID current_id = object_id;
+ LLInventoryObject *current_object = gInventory.getObject(object_id);
+ while (current_id.notNull())
+ {
+ if (LLClipboard::getInstance()->isOnClipboard(current_id))
+ {
+ return false;
+ }
+ current_id = current_object->getParentUUID();
+ if (current_id.notNull())
+ {
+ current_object = gInventory.getObject(current_id);
+ }
+ }
+ }
+ }
+
return true;
}
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 8313b23f44..4fb06f82c1 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -238,6 +238,42 @@ void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::s
model->notifyObservers();
}
+void copy_inventory_category(LLInventoryModel* model,
+ LLViewerInventoryCategory* cat,
+ const LLUUID& parent_id)
+{
+ // Create the initial folder
+ LLUUID new_cat_uuid = gInventory.createNewCategory(parent_id, LLFolderType::FT_NONE, cat->getName());
+ model->notifyObservers();
+
+ // Get the content of the folder
+ LLInventoryModel::cat_array_t* cat_array;
+ LLInventoryModel::item_array_t* item_array;
+ gInventory.getDirectDescendentsOf(cat->getUUID(),cat_array,item_array);
+
+ // Copy all 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++)
+ {
+ LLInventoryItem* item = *iter;
+ copy_inventory_item(
+ gAgent.getID(),
+ item->getPermissions().getOwner(),
+ item->getUUID(),
+ new_cat_uuid,
+ std::string(),
+ LLPointer<LLInventoryCallback>(NULL));
+ }
+
+ // Copy all 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;
+ copy_inventory_category(model, category, new_cat_uuid);
+ }
+}
+
class LLInventoryCollectAllItems : public LLInventoryCollectFunctor
{
public:
diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h
index f8ecca22b6..72c48c64f2 100644
--- a/indra/newview/llinventoryfunctions.h
+++ b/indra/newview/llinventoryfunctions.h
@@ -73,6 +73,8 @@ void remove_category(LLInventoryModel* model, const LLUUID& cat_id);
void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name);
+void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& parent_id);
+
// Generates a string containing the path to the item specified by item_id.
void append_path(const LLUUID& id, std::string& path);