diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-10-12 13:34:06 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-10-12 13:34:06 +0300 |
commit | dcb5cf5bc21ba2e316cc2889b2c1371860b0348d (patch) | |
tree | 2ccd2671ce46abb8bf12786ccf53e597e6a0049d /indra/newview/llinventoryfunctions.cpp | |
parent | 1b19919eff1104f9f1ee97004420e91c45349e29 (diff) | |
parent | 738cf84c340d8ade3ab462340d1444c4e70ef9f5 (diff) |
Merge commit '738cf84c34' into marchcat/c-develop
# Conflicts:
# indra/llui/llfolderviewitem.cpp
# indra/llui/llfolderviewitem.h
# indra/llui/llfolderviewmodel.h
# indra/newview/llconversationmodel.h
# indra/newview/llfloaterinventorysettings.cpp
# indra/newview/llfolderviewmodelinventory.h
# indra/newview/llinventorybridge.cpp
# indra/newview/llinventorybridge.h
# indra/newview/llinventoryfunctions.cpp
# indra/newview/llinventorygallery.h
# indra/newview/llinventorygallerymenu.cpp
# indra/newview/llinventorypanel.cpp
# indra/newview/llinventorypanel.h
# indra/newview/lloutfitgallery.cpp
# indra/newview/lloutfitgallery.h
# indra/newview/lloutfitslist.cpp
# indra/newview/lloutfitslist.h
# indra/newview/llpanelobjectinventory.cpp
# indra/newview/llpaneloutfitsinventory.h
# indra/newview/llpanelwearing.cpp
# indra/newview/llsidepanelappearance.cpp
# indra/newview/llwearableitemslist.cpp
Diffstat (limited to 'indra/newview/llinventoryfunctions.cpp')
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index fdf77ab8df..879c562af7 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2418,6 +2418,102 @@ void ungroup_folder_items(const LLUUID& folder_id) gInventory.notifyObservers(); } +class LLUpdateFavorite : public LLInventoryCallback +{ +public: + LLUpdateFavorite(const LLUUID& inv_item_id) + : mInvItemID(inv_item_id) + {} + /* virtual */ void fire(const LLUUID& inv_item_id) override + { + gInventory.addChangedMask(LLInventoryObserver::UPDATE_FAVORITE, mInvItemID); + gInventory.notifyObservers(); + } +private: + LLUUID mInvItemID; +}; + +void set_favorite(const LLUUID& obj_id, bool favorite) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + if (obj->getIsFavorite() != favorite) + { + LLSD val; + if (favorite) + { + val = true; + } // else leave undefined to remove unneeded metadata field + + LLSD updates; + if (favorite) + { + updates["favorite"] = LLSD().with("toggled", true); + } + else + { + updates["favorite"] = LLSD(); + } + + LLPointer<LLInventoryCallback> cb = new LLUpdateFavorite(obj_id); + + LLViewerInventoryCategory* view_folder = dynamic_cast<LLViewerInventoryCategory*>(obj); + if (view_folder) + { + update_inventory_category(obj_id, updates, cb); + } + LLViewerInventoryItem* view_item = dynamic_cast<LLViewerInventoryItem*>(obj); + if (view_item) + { + update_inventory_item(obj_id, updates, cb); + } + } +} + +void toggle_favorite(const LLUUID& obj_id) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + if (!obj) + { + return; + } + + LLSD updates; + if (!obj->getIsFavorite()) + { + updates["favorite"] = LLSD().with("toggled", true); + } + else + { + updates["favorite"] = LLSD(); + } + + LLPointer<LLInventoryCallback> cb = new LLUpdateFavorite(obj_id); + + LLViewerInventoryCategory* view_folder = dynamic_cast<LLViewerInventoryCategory*>(obj); + if (view_folder) + { + update_inventory_category(obj_id, updates, cb); + } + LLViewerInventoryItem* view_item = dynamic_cast<LLViewerInventoryItem*>(obj); + if (view_item) + { + update_inventory_item(obj_id, updates, cb); + } +} + +void toggle_linked_favorite(const LLUUID& obj_id) +{ + LLViewerInventoryItem* item = gInventory.getItem(obj_id); + if (!item) + { + LL_WARNS() << "Invalid item" << LL_ENDL; + return; + } + + LLUUID linked_id = item->getLinkedUUID(); + toggle_favorite(linked_id); +} + std::string get_searchable_description(LLInventoryModel* model, const LLUUID& item_id) { if (model) @@ -2697,6 +2793,20 @@ bool LLIsTypeWithPermissions::operator()(LLInventoryCategory* cat, LLInventoryIt return false; } +bool LLFavoritesCollector::operator()(LLInventoryCategory* cat, + LLInventoryItem* item) +{ + if (item && item->getIsFavorite()) + { + return true; + } + if (cat && cat->getIsFavorite()) + { + return true; + } + return false; +} + bool LLBuddyCollector::operator()(LLInventoryCategory* cat, LLInventoryItem* item) { @@ -3481,6 +3591,20 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root LLFloaterReg::showInstance("change_item_thumbnail", data); } } + else if ("add_to_favorites" == action) + { + for (const LLUUID& id : ids) + { + set_favorite(id, true); + } + } + else if ("remove_from_favorites" == action) + { + for (const LLUUID& id : ids) + { + set_favorite(id, false); + } + } else { std::set<LLFolderViewItem*>::iterator set_iter; |