diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-05-17 22:22:45 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-05-17 22:22:45 +0300 |
commit | 25b19eb6b8b8482d5f6cff0cae8665a0f7518eb1 (patch) | |
tree | 3a352e745f83e52a17400247b5e5cccb20c6ca93 | |
parent | 4c676acedd3c99234e599b77bcfdec6ad3274efb (diff) |
viewer#1424 Proper links support for favorites
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llinventoryfilter.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 117 | ||||
-rw-r--r-- | indra/newview/llinventoryfunctions.h | 3 | ||||
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llinventorygallerymenu.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 7 | ||||
-rw-r--r-- | indra/newview/llpanelwearing.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llwearableitemslist.cpp | 2 |
9 files changed, 94 insertions, 65 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index e930af2d27..aa6d747622 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2283,11 +2283,11 @@ bool LLItemBridge::isFavorite() const LLInventoryModel* model = getInventoryModel(); if (model) { - item = (LLViewerInventoryItem*)model->getItem(mUUID); + item = model->getItem(mUUID); } if (item) { - return item->getIsFavorite(); + return get_is_favorite(item); } return false; } diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index cb54645ce5..52d03e302e 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -624,12 +624,15 @@ bool LLInventoryFilter::checkAgainstFilterFavorites(const LLUUID& object_id) con const LLInventoryObject* object = gInventory.getObject(object_id); if (!object) return true; - const bool is_favorite = object->getIsFavorite(); - if (is_favorite && (mFilterOps.mFilterFavorites == FILTER_EXCLUDE_FAVORITES)) - return false; - if (!is_favorite && (mFilterOps.mFilterFavorites == FILTER_ONLY_FAVORITES)) - return false; + if (mFilterOps.mFilterFavorites != FILTER_INCLUDE_FAVORITES) + { + bool is_favorite = get_is_favorite(object); + if (is_favorite && (mFilterOps.mFilterFavorites == FILTER_EXCLUDE_FAVORITES)) + return false; + if (!is_favorite && (mFilterOps.mFilterFavorites == FILTER_ONLY_FAVORITES)) + return false; + } return true; } diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 3e19bf885d..930e9e48ea 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2353,58 +2353,40 @@ public: /* 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 + 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); - LLSD updates; - if (favorite) + std::set<LLUUID> link_ids; + for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); ++it) { - updates["favorite"] = LLSD().with("toggled", true); - } - else - { - updates["favorite"] = LLSD(); - } + LLPointer<LLViewerInventoryItem> item = *it; - 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); + gInventory.addChangedMask(LLInventoryObserver::UPDATE_FAVORITE, item->getUUID()); } + + gInventory.notifyObservers(); } -} +private: + LLUUID mInvItemID; +}; -void toggle_favorite(const LLUUID& obj_id) +void favorite_send(LLInventoryObject* obj, const LLUUID& obj_id, bool favorite) { - LLInventoryObject* obj = gInventory.getObject(obj_id); - if (!obj) + LLSD val; + if (favorite) { - return; - } + val = true; + } // else leave undefined to remove unneeded metadata field LLSD updates; - if (!obj->getIsFavorite()) + if (favorite) { updates["favorite"] = LLSD().with("toggled", true); } @@ -2427,17 +2409,56 @@ void toggle_favorite(const LLUUID& obj_id) } } -void toggle_linked_favorite(const LLUUID& obj_id) +bool get_is_favorite(const LLInventoryObject* object) { - LLViewerInventoryItem* item = gInventory.getItem(obj_id); - if (!item) + if (object->getIsLinkType()) { - LL_WARNS() << "Invalid item" << LL_ENDL; - return; + LLInventoryObject* obj = gInventory.getObject(object->getLinkedUUID()); + return obj && obj->getIsFavorite(); + } + + return object->getIsFavorite(); +} + +bool get_is_favorite(const LLUUID& obj_id) +{ + LLInventoryObject* object = gInventory.getObject(obj_id); + if (object && object->getIsLinkType()) + { + LLInventoryObject* obj = gInventory.getObject(object->getLinkedUUID()); + return obj && obj->getIsFavorite(); + } + + return object->getIsFavorite(); +} + +void set_favorite(const LLUUID& obj_id, bool favorite) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + + if (obj && obj->getIsLinkType()) + { + obj = gInventory.getObject(obj_id); + } + + if (obj && obj->getIsFavorite() != favorite) + { + favorite_send(obj, obj_id, favorite); + } +} + +void toggle_favorite(const LLUUID& obj_id) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + if (obj && obj->getIsLinkType()) + { + 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) diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 681d5e1611..d90198d59b 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -114,9 +114,10 @@ bool can_move_to_my_outfits(LLInventoryModel* model, LLInventoryCategory* inv_ca std::string get_localized_folder_name(LLUUID cat_uuid); void new_folder_window(const LLUUID& folder_id); void ungroup_folder_items(const LLUUID& folder_id); +bool get_is_favorite(const LLInventoryObject* object); +bool get_is_favorite(const LLUUID& obj_id); void set_favorite(const LLUUID& obj_id, bool favorite); void toggle_favorite(const LLUUID& obj_id); -void toggle_linked_favorite(const LLUUID& obj_id); std::string get_searchable_description(LLInventoryModel* model, const LLUUID& item_id); std::string get_searchable_creator_name(LLInventoryModel* model, const LLUUID& item_id); std::string get_searchable_UUID(LLInventoryModel* model, const LLUUID& item_id); diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 5991697ab7..d2f1257444 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -929,6 +929,7 @@ bool LLInventoryGallery::updateAddedItem(LLUUID item_id) } bool res = false; + bool is_favorite = get_is_favorite(obj); LLInventoryGalleryItem* item = buildGalleryItem( name, @@ -940,7 +941,7 @@ bool LLInventoryGallery::updateAddedItem(LLUUID item_id) obj->getCreationDate(), obj->getIsLinkType(), is_worn, - obj->getIsFavorite()); + is_favorite); mItemMap.insert(LLInventoryGallery::gallery_item_map_t::value_type(item_id, item)); if (mGalleryCreated) { @@ -2154,7 +2155,7 @@ void LLInventoryGallery::refreshList(const LLUUID& category_id) return; } - updateChangedItemData(*items_iter, obj->getName(), obj->getIsFavorite()); + updateChangedItemData(*items_iter, obj->getName(), get_is_favorite(obj)); mNeedsArrange = true; } diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index de7ebd5ca8..00c8b191f5 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -549,7 +549,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men if (!is_trash && !is_in_trash && gInventory.getRootFolderID() != selected_id) { - if (obj->getIsFavorite()) + if (get_is_favorite(obj)) { items.push_back(std::string("Remove from Favorites")); } @@ -601,7 +601,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("Cut")); if (!is_in_trash) { - if (obj->getIsFavorite()) + if (get_is_favorite(obj)) { items.push_back(std::string("Remove from Favorites")); } @@ -745,7 +745,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men disabled_items.push_back(std::string("upload_def")); } - if (obj->getIsFavorite()) + if (get_is_favorite(obj)) { items.push_back(std::string("Remove from Favorites")); } diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 4682f2085b..8450c344a7 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -626,10 +626,11 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve { if (view_item) { + view_item->refresh(); LLFolderViewFolder* parent = view_item->getParentFolder(); if (parent) { - parent->updateHasFavorites(view_item->isFavorite()); + parent->updateHasFavorites(get_is_favorite(model_item)); } } } @@ -662,7 +663,8 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve setSelection(item_id, FALSE); } updateFolderLabel(model_item->getParentUUID()); - if (model_item->getIsFavorite()) + + if (get_is_favorite(model_item)) { LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getItemByID(model_item->getParentUUID()); if (new_parent) @@ -2424,6 +2426,7 @@ void LLInventoryFavoritesItemsPanel::itemChanged(const LLUUID& id, U32 mask, con LLInventoryObserver::ADD | LLInventoryObserver::REMOVE)) { + // specifically exlude links and not get_is_favorite(model_item) if (model_item && model_item->getIsFavorite()) { LLFolderViewItem* view_item = getItemByID(id); diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index aecdf13495..dbabe935f5 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -113,7 +113,7 @@ protected: boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); registrar.add("Wearing.Detach", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); - registrar.add("Wearing.Favorite", boost::bind(toggle_linked_favorite, mUUIDs.front())); + registrar.add("Wearing.Favorite", boost::bind(toggle_favorite, mUUIDs.front())); LLContextMenu* menu = createFromFile("menu_wearing_tab.xml"); updateMenuItemsVisibility(menu); diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 8e44271efb..71b765ce71 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -936,7 +936,7 @@ LLContextMenu* LLWearableItemsList::ContextMenu::createMenu() // Register handlers for attachments. registrar.add("Attachment.Detach", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), ids)); - registrar.add("Attachment.Favorite", boost::bind(toggle_linked_favorite, selected_id)); + registrar.add("Attachment.Favorite", boost::bind(toggle_favorite, selected_id)); registrar.add("Attachment.Touch", boost::bind(handle_attachment_touch, selected_id)); registrar.add("Attachment.Profile", boost::bind(show_item_profile, selected_id)); registrar.add("Object.Attach", boost::bind(LLViewerAttachMenu::attachObjects, ids, _2)); |