summaryrefslogtreecommitdiff
path: root/indra/newview/llinventoryfunctions.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2012-03-30 15:56:38 -0400
committerOz Linden <oz@lindenlab.com>2012-03-30 15:56:38 -0400
commit74d199c1dd10660f72293c84888af412764f1da8 (patch)
tree0b4c4137abde8283c5a85da08f19de1aea335c2a /indra/newview/llinventoryfunctions.cpp
parent3c3ee709677a0c60420eae84a55a7b61113b4949 (diff)
parent6e4e971fd27826f90c1728c7fd17242083e230fc (diff)
merge changes for vmrg-233
Diffstat (limited to 'indra/newview/llinventoryfunctions.cpp')
-rw-r--r--indra/newview/llinventoryfunctions.cpp85
1 files changed, 76 insertions, 9 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index dd92188e9d..f74a239fd3 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -54,7 +54,6 @@
#include "lliconctrl.h"
#include "llimview.h"
#include "llinventorybridge.h"
-#include "llinventoryclipboard.h"
#include "llinventorymodel.h"
#include "llinventorypanel.h"
#include "lllineeditor.h"
@@ -161,6 +160,31 @@ void change_category_parent(LLInventoryModel* model,
model->notifyObservers();
}
+// Move the item to the trash. Works for folders and objects.
+// Caution: This method assumes that the item is removable!
+void remove_item(LLInventoryModel* model, const LLUUID& id)
+{
+ LLViewerInventoryItem* item = model->getItem(id);
+ if (!item)
+ return;
+
+ if (item->getType() == LLAssetType::AT_CATEGORY)
+ {
+ // Call the general helper function to delete a folder
+ remove_category(model, id);
+ }
+ else
+ {
+ // Get the trash UUID
+ LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH, false);
+ if (trash_id.notNull())
+ {
+ // Finally, move the item to the trash
+ change_item_parent(model, item, trash_id, true);
+ }
+ }
+}
+
void remove_category(LLInventoryModel* model, const LLUUID& cat_id)
{
if (!model || !get_is_category_removable(model, cat_id))
@@ -214,6 +238,49 @@ 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,
+ const LLUUID& root_copy_id)
+{
+ // Create the initial folder
+ LLUUID new_cat_uuid = gInventory.createNewCategory(parent_id, LLFolderType::FT_NONE, cat->getName());
+ model->notifyObservers();
+
+ // We need to exclude the initial root of the copy to avoid recursively copying the copy, etc...
+ LLUUID root_id = (root_copy_id.isNull() ? new_cat_uuid : root_copy_id);
+
+ // 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;
+ if (category->getUUID() != root_id)
+ {
+ copy_inventory_category(model, category, new_cat_uuid, root_id);
+ }
+ }
+}
+
class LLInventoryCollectAllItems : public LLInventoryCollectFunctor
{
public:
@@ -992,20 +1059,24 @@ void LLSaveFolderState::setApply(BOOL apply)
void LLSaveFolderState::doFolder(LLFolderViewFolder* folder)
{
LLMemType mt(LLMemType::MTYPE_INVENTORY_DO_FOLDER);
+ LLInvFVBridge* bridge = (LLInvFVBridge*)folder->getListener();
+ if(!bridge) return;
+
if(mApply)
{
// we're applying the open state
- LLInvFVBridge* bridge = (LLInvFVBridge*)folder->getListener();
- if(!bridge) return;
LLUUID id(bridge->getUUID());
if(mOpenFolders.find(id) != mOpenFolders.end())
{
- folder->setOpen(TRUE);
+ if (!folder->isOpen())
+ {
+ folder->setOpen(TRUE);
+ }
}
else
{
// keep selected filter in its current state, this is less jarring to user
- if (!folder->isSelected())
+ if (!folder->isSelected() && folder->isOpen())
{
folder->setOpen(FALSE);
}
@@ -1016,8 +1087,6 @@ void LLSaveFolderState::doFolder(LLFolderViewFolder* folder)
// we're recording state at this point
if(folder->isOpen())
{
- LLInvFVBridge* bridge = (LLInvFVBridge*)folder->getListener();
- if(!bridge) return;
mOpenFolders.insert(bridge->getUUID());
}
}
@@ -1053,7 +1122,6 @@ void LLSelectFirstFilteredItem::doItem(LLFolderViewItem *item)
{
item->getParentFolder()->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP);
}
- item->getRoot()->scrollToShowSelection();
mItemSelected = TRUE;
}
}
@@ -1067,7 +1135,6 @@ void LLSelectFirstFilteredItem::doFolder(LLFolderViewFolder* folder)
{
folder->getParentFolder()->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP);
}
- folder->getRoot()->scrollToShowSelection();
mItemSelected = TRUE;
}
}