summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorymodel.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-03-27 18:40:17 -0400
committerNat Goodspeed <nat@lindenlab.com>2012-03-27 18:40:17 -0400
commitfdd018783a0cc06a467443ca7c9ea0876a87ef49 (patch)
treeb99d4dfaf888450b914b7f414f6b740992033622 /indra/newview/llinventorymodel.cpp
parentb187aeb8f177bd76e792652e773617beff18b47b (diff)
CHOP-854: move change_(item|category)_parent() into LLInventoryModel.
It's not really clear why they're in llinventoryfunctions.{h,cpp} instead of LLInventoryModel, and in fact LLInventoryModel::removeItem() already contains code essentially cloned from change_item_parent() -- or perhaps vice-versa. This changeset addresses only migrating the functions, and fixing up existing references, to simplify code review.
Diffstat (limited to 'indra/newview/llinventorymodel.cpp')
-rw-r--r--indra/newview/llinventorymodel.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index a71b699fdd..6cc0d6768e 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -1017,6 +1017,58 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id)
}
}
+// Migrated from llinventoryfunctions
+void LLInventoryModel::changeItemParent(LLViewerInventoryItem* item,
+ const LLUUID& new_parent_id,
+ BOOL restamp)
+{
+ if (item->getParentUUID() != new_parent_id)
+ {
+ LLInventoryModel::update_list_t update;
+ LLInventoryModel::LLCategoryUpdate old_folder(item->getParentUUID(),-1);
+ update.push_back(old_folder);
+ LLInventoryModel::LLCategoryUpdate new_folder(new_parent_id, 1);
+ update.push_back(new_folder);
+ accountForUpdate(update);
+
+ LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
+ new_item->setParent(new_parent_id);
+ new_item->updateParentOnServer(restamp);
+ updateItem(new_item);
+ notifyObservers();
+ }
+}
+
+// Migrated from llinventoryfunctions
+void LLInventoryModel::changeCategoryParent(LLViewerInventoryCategory* cat,
+ const LLUUID& new_parent_id,
+ BOOL restamp)
+{
+ if (!cat)
+ {
+ return;
+ }
+
+ // Can't move a folder into a child of itself.
+ if (isObjectDescendentOf(new_parent_id, cat->getUUID()))
+ {
+ return;
+ }
+
+ LLInventoryModel::update_list_t update;
+ LLInventoryModel::LLCategoryUpdate old_folder(cat->getParentUUID(), -1);
+ update.push_back(old_folder);
+ LLInventoryModel::LLCategoryUpdate new_folder(new_parent_id, 1);
+ update.push_back(new_folder);
+ accountForUpdate(update);
+
+ LLPointer<LLViewerInventoryCategory> new_cat = new LLViewerInventoryCategory(cat);
+ new_cat->setParent(new_parent_id);
+ new_cat->updateParentOnServer(restamp);
+ updateCategory(new_cat);
+ notifyObservers();
+}
+
// Delete a particular inventory object by ID.
void LLInventoryModel::deleteObject(const LLUUID& id)
{