diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2023-10-10 23:21:08 +0200 |
---|---|---|
committer | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2023-10-11 08:40:50 +0200 |
commit | 45a1a94a35142da71c507c724ae4d1498217e449 (patch) | |
tree | b50cdef12e969b0bc66a54bd48749abdc3eb6a15 /indra/newview/lloutfitslist.cpp | |
parent | e9ffe7ee471a2bbe428ec6a3ad07a7ef998c2e36 (diff) |
SL-20432 Filtering My Outfits with big number of items freezes UI
Diffstat (limited to 'indra/newview/lloutfitslist.cpp')
-rw-r--r-- | indra/newview/lloutfitslist.cpp | 110 |
1 files changed, 40 insertions, 70 deletions
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 8042b87a44..27d73fc4ae 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -188,7 +188,7 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_id) list->setCommitCallback(boost::bind(&LLOutfitsList::onListSelectionChange, this, _1)); // Setting list refresh callback to apply filter on list change. - list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onFilteredWearableItemsListRefresh, this, _1)); + list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onRefreshComplete, this, _1)); list->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onWearableItemsListRightClick, this, _1, _2, _3)); @@ -199,19 +199,17 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_id) // Further list updates will be triggered by the category observer. list->updateList(cat_id); - // If filter is currently applied we store the initial tab state and - // open it to show matched items if any. - if (!sFilterSubString.empty()) + // If filter is currently applied we store the initial tab state. + if (!getFilterSubString().empty()) { tab->notifyChildren(LLSD().with("action", "store_state")); - tab->setDisplayChildren(true); // Setting mForceRefresh flag will make the list refresh its contents // even if it is not currently visible. This is required to apply the // filter to the newly added list. list->setForceRefresh(true); - list->setFilterSubString(sFilterSubString); + list->setFilterSubString(getFilterSubString(), false); } } @@ -314,14 +312,6 @@ void LLOutfitsList::onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid) } // virtual -void LLOutfitsList::setFilterSubString(const std::string& string) -{ - applyFilter(string); - - sFilterSubString = string; -} - -// virtual bool LLOutfitListBase::isActionEnabled(const LLSD& userdata) { if (mSelectedOutfitUUID.isNull()) return false; @@ -494,9 +484,9 @@ void LLOutfitsList::restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID } } -void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl) +void LLOutfitsList::onRefreshComplete(LLUICtrl* ctrl) { - if (!ctrl || sFilterSubString.empty()) + if (!ctrl || getFilterSubString().empty()) return; for (outfits_map_t::iterator @@ -510,57 +500,50 @@ void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl) LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (list != ctrl) continue; - applyFilterToTab(iter->first, tab, sFilterSubString); + applyFilterToTab(iter->first, tab, getFilterSubString()); } } -void LLOutfitsList::applyFilter(const std::string& new_filter_substring) +// virtual +void LLOutfitsList::onFilterSubStringChanged(const std::string& new_string, const std::string& old_string) { - mAccordion->setFilterSubString(new_filter_substring); + mAccordion->setFilterSubString(new_string); - for (outfits_map_t::iterator - iter = mOutfitsMap.begin(), - iter_end = mOutfitsMap.end(); - iter != iter_end; ++iter) + outfits_map_t::iterator iter = mOutfitsMap.begin(), iter_end = mOutfitsMap.end(); + while (iter != iter_end) { - LLAccordionCtrlTab* tab = iter->second; + const LLUUID& category_id = iter->first; + LLAccordionCtrlTab* tab = iter++->second; if (!tab) continue; - bool more_restrictive = sFilterSubString.size() < new_filter_substring.size() && !new_filter_substring.substr(0, sFilterSubString.size()).compare(sFilterSubString); - - // Restore tab visibility in case of less restrictive filter - // to compare it with updated string if it was previously hidden. - if (!more_restrictive) - { - tab->setVisible(TRUE); - } - LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (list) { - list->setFilterSubString(new_filter_substring); + list->setFilterSubString(new_string, tab->getDisplayChildren()); } - if(sFilterSubString.empty() && !new_filter_substring.empty()) + if (old_string.empty()) { - //store accordion tab state when filter is not empty - tab->notifyChildren(LLSD().with("action","store_state")); + // Store accordion tab state when filter is not empty + tab->notifyChildren(LLSD().with("action", "store_state")); } - if (!new_filter_substring.empty()) + if (!new_string.empty()) { - applyFilterToTab(iter->first, tab, new_filter_substring); + applyFilterToTab(category_id, tab, new_string); } else { - // restore tab title when filter is empty + tab->setVisible(TRUE); + + // Restore tab title when filter is empty tab->setTitle(tab->getTitle()); - //restore accordion state after all those accodrion tab manipulations - tab->notifyChildren(LLSD().with("action","restore_state")); + // Restore accordion state after all those accodrion tab manipulations + tab->notifyChildren(LLSD().with("action", "restore_state")); // Try restoring the tab selection. - restoreOutfitSelection(tab, iter->first); + restoreOutfitSelection(tab, category_id); } } @@ -586,11 +569,11 @@ void LLOutfitsList::applyFilterToTab( if (std::string::npos == title.find(cur_filter)) { - // hide tab if its title doesn't pass filter - // and it has no visible items + // Hide tab if its title doesn't pass filter + // and it has no matched items tab->setVisible(list->hasMatchedItems()); - // remove title highlighting because it might + // Remove title highlighting because it might // have been previously highlighted by less restrictive filter tab->setTitle(tab->getTitle()); @@ -602,18 +585,6 @@ void LLOutfitsList::applyFilterToTab( // Try restoring the tab selection. restoreOutfitSelection(tab, category_id); } - - if (tab->getVisible()) - { - // Open tab if it has passed the filter. - tab->setDisplayChildren(true); - } - else - { - // Set force refresh flag to refresh not visible list - // when some changes occur in it. - list->setForceRefresh(true); - } } bool LLOutfitsList::canWearSelected() @@ -698,11 +669,10 @@ void LLOutfitsList::onCOFChanged() // These links UUIDs are not the same UUIDs that we have in each wearable items list. // So we collect base items' UUIDs to find them or links that point to them in wearable // items lists and update their worn state there. - for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin(); - iter != item_array.end(); - ++iter) + LLInventoryModel::item_array_t::const_iterator array_iter = item_array.begin(), array_end = item_array.end(); + while (array_iter < array_end) { - vnew.push_back((*iter)->getLinkedUUID()); + vnew.push_back((*(array_iter++))->getLinkedUUID()); } // We need to update only items that were added or removed from COF. @@ -711,20 +681,20 @@ void LLOutfitsList::onCOFChanged() // Store the ids of items currently linked from COF. mCOFLinkedItems = vnew; - for (outfits_map_t::iterator iter = mOutfitsMap.begin(); - iter != mOutfitsMap.end(); - ++iter) + // Append removed ids to added ids because we should update all of them. + vadded.reserve(vadded.size() + vremoved.size()); + vadded.insert(vadded.end(), vremoved.begin(), vremoved.end()); + vremoved.clear(); + + outfits_map_t::iterator map_iter = mOutfitsMap.begin(), map_end = mOutfitsMap.end(); + while (map_iter != map_end) { - LLAccordionCtrlTab* tab = iter->second; + LLAccordionCtrlTab* tab = (map_iter++)->second; if (!tab) continue; LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (!list) continue; - // Append removed ids to added ids because we should update all of them. - vadded.reserve(vadded.size() + vremoved.size()); - vadded.insert(vadded.end(), vremoved.begin(), vremoved.end()); - // Every list updates the labels of changed items or // the links that point to these items. list->updateChangedItems(vadded); |