diff options
| author | Leslie Linden <leslie@lindenlab.com> | 2012-01-30 15:54:39 -0800 |
|---|---|---|
| committer | Leslie Linden <leslie@lindenlab.com> | 2012-01-30 15:54:39 -0800 |
| commit | fd56967dea7e4c53080a1ef89cc550492baf3fc8 (patch) | |
| tree | 2a7a7993a550afbd7e92975cc53d633e41404583 /indra/newview/llinventorymodel.cpp | |
| parent | c4084c71386e34f6c28d4c10199eaf1155a2855b (diff) | |
| parent | 56973912198ba3410d1ab32d1a8a63a1c8c3348e (diff) | |
Merge with latest
Diffstat (limited to 'indra/newview/llinventorymodel.cpp')
| -rw-r--r-- | indra/newview/llinventorymodel.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 568ec4c5e2..a71b699fdd 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -217,6 +217,38 @@ const LLViewerInventoryCategory *LLInventoryModel::getFirstNondefaultParent(cons return NULL; } +// +// Search up the parent chain until we get to the specified parent, then return the first child category under it +// +const LLViewerInventoryCategory* LLInventoryModel::getFirstDescendantOf(const LLUUID& master_parent_id, const LLUUID& obj_id) const +{ + if (master_parent_id == obj_id) + { + return NULL; + } + + const LLViewerInventoryCategory* current_cat = getCategory(obj_id); + + if (current_cat == NULL) + { + current_cat = getCategory(getObject(obj_id)->getParentUUID()); + } + + while (current_cat != NULL) + { + const LLUUID& current_parent_id = current_cat->getParentUUID(); + + if (current_parent_id == master_parent_id) + { + return current_cat; + } + + current_cat = getCategory(current_parent_id); + } + + return NULL; +} + // Get the object by id. Returns NULL if not found. LLInventoryObject* LLInventoryModel::getObject(const LLUUID& id) const { |
