diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-10-12 14:07:05 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-10-12 14:07:05 +0300 |
commit | 56101002a460ecd9bb7a264d55b6f8ecb9a348a0 (patch) | |
tree | da613ed4e420551235416b8f68e0ed87204469a3 /indra/newview/llinventoryfunctions.cpp | |
parent | dcb5cf5bc21ba2e316cc2889b2c1371860b0348d (diff) | |
parent | 25b19eb6b8b8482d5f6cff0cae8665a0f7518eb1 (diff) |
Merge commit '25b19eb6b8' into marchcat/c-develop
# Conflicts:
# indra/newview/lloutfitgallery.cpp
# indra/newview/lloutfitslist.cpp
# indra/newview/llpanelwearing.cpp
# indra/newview/llwearableitemslist.cpp
Diffstat (limited to 'indra/newview/llinventoryfunctions.cpp')
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 879c562af7..9ae542f2d3 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2427,16 +2427,31 @@ public: /* virtual */ void fire(const LLUUID& inv_item_id) override { gInventory.addChangedMask(LLInventoryObserver::UPDATE_FAVORITE, mInvItemID); + + LLInventoryModel::item_array_t items; + LLInventoryModel::cat_array_t cat_array; + LLLinkedItemIDMatches matches(mInvItemID); + gInventory.collectDescendentsIf(gInventory.getRootFolderID(), + cat_array, + items, + LLInventoryModel::INCLUDE_TRASH, + matches); + + std::set<LLUUID> link_ids; + for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); ++it) + { + LLPointer<LLViewerInventoryItem> item = *it; + + gInventory.addChangedMask(LLInventoryObserver::UPDATE_FAVORITE, item->getUUID()); + } + gInventory.notifyObservers(); } private: LLUUID mInvItemID; }; -void set_favorite(const LLUUID& obj_id, bool favorite) -{ - LLInventoryObject* obj = gInventory.getObject(obj_id); - if (obj->getIsFavorite() != favorite) +void favorite_send(LLInventoryObject* obj, const LLUUID& obj_id, bool favorite) { LLSD val; if (favorite) @@ -2467,51 +2482,57 @@ void set_favorite(const LLUUID& obj_id, bool favorite) update_inventory_item(obj_id, updates, cb); } } -} -void toggle_favorite(const LLUUID& obj_id) +bool get_is_favorite(const LLInventoryObject* object) { - LLInventoryObject* obj = gInventory.getObject(obj_id); - if (!obj) + if (object->getIsLinkType()) { - return; + LLInventoryObject* obj = gInventory.getObject(object->getLinkedUUID()); + return obj && obj->getIsFavorite(); } - LLSD updates; - if (!obj->getIsFavorite()) - { - updates["favorite"] = LLSD().with("toggled", true); - } - else + return object->getIsFavorite(); +} + +bool get_is_favorite(const LLUUID& obj_id) +{ + LLInventoryObject* object = gInventory.getObject(obj_id); + if (object && object->getIsLinkType()) { - updates["favorite"] = LLSD(); + LLInventoryObject* obj = gInventory.getObject(object->getLinkedUUID()); + return obj && obj->getIsFavorite(); } - LLPointer<LLInventoryCallback> cb = new LLUpdateFavorite(obj_id); + return object->getIsFavorite(); +} - LLViewerInventoryCategory* view_folder = dynamic_cast<LLViewerInventoryCategory*>(obj); - if (view_folder) +void set_favorite(const LLUUID& obj_id, bool favorite) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + + if (obj && obj->getIsLinkType()) { - update_inventory_category(obj_id, updates, cb); + obj = gInventory.getObject(obj_id); } - LLViewerInventoryItem* view_item = dynamic_cast<LLViewerInventoryItem*>(obj); - if (view_item) + + if (obj && obj->getIsFavorite() != favorite) { - update_inventory_item(obj_id, updates, cb); + favorite_send(obj, obj_id, favorite); } } -void toggle_linked_favorite(const LLUUID& obj_id) +void toggle_favorite(const LLUUID& obj_id) { - LLViewerInventoryItem* item = gInventory.getItem(obj_id); - if (!item) + LLInventoryObject* obj = gInventory.getObject(obj_id); + if (obj && obj->getIsLinkType()) { - LL_WARNS() << "Invalid item" << LL_ENDL; - return; + obj = gInventory.getObject(obj_id); } - LLUUID linked_id = item->getLinkedUUID(); - toggle_favorite(linked_id); + if (obj) + { + favorite_send(obj, obj_id, !obj->getIsFavorite()); + } } std::string get_searchable_description(LLInventoryModel* model, const LLUUID& item_id) |