diff options
author | Vadim Savchuk <vsavchuk@productengine.com> | 2010-06-17 19:35:29 +0300 |
---|---|---|
committer | Vadim Savchuk <vsavchuk@productengine.com> | 2010-06-17 19:35:29 +0300 |
commit | c75c247bc9a434e4a9e3166145e665d7811da7dc (patch) | |
tree | 721902161e079525c8eb226b32edfbedf956801e /indra/newview | |
parent | 9f996443604a902e03de87d2d14545b4adffa69c (diff) |
EXT-7620 FIXED Save outfit selection when applying filter and restore it after filter has been reset.
Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/603/
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/lloutfitslist.cpp | 117 | ||||
-rw-r--r-- | indra/newview/lloutfitslist.h | 19 |
2 files changed, 86 insertions, 50 deletions
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 73c850e1fb..927ea19d98 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -326,19 +326,13 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) // 1. Remove outfit category from observer to stop monitoring its changes. mCategoriesObserver->removeCategory(outfit_id); - // 2. Remove selected lists map entry. - mSelectedListsMap.erase(outfit_id); + // 2. Remove the outfit from selection. + deselectOutfit(outfit_id); - // 3. Reset currently selected outfit id if it is being removed. - if (outfit_id == mSelectedOutfitUUID) - { - setSelectedOutfitUUID(LLUUID()); - } - - // 4. Remove category UUID to accordion tab mapping. + // 3. Remove category UUID to accordion tab mapping. mOutfitsMap.erase(outfits_iter); - // 5. Remove outfit tab from accordion. + // 4. Remove outfit tab from accordion. mAccordion->removeCollapsibleCtrl(tab); } } @@ -494,6 +488,27 @@ void LLOutfitsList::setSelectedOutfitUUID(const LLUUID& category_id) mSelectionChangeSignal(mSelectedOutfitUUID = category_id); } +void LLOutfitsList::deselectOutfit(const LLUUID& category_id) +{ + // Remove selected lists map entry. + mSelectedListsMap.erase(category_id); + + // Reset selection if the outfit is selected. + if (category_id == mSelectedOutfitUUID) + { + setSelectedOutfitUUID(LLUUID::null); + } +} + +void LLOutfitsList::restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID& category_id) +{ + // Try restoring outfit selection after filtering. + if (mAccordion->getSelectedTab() == tab) + { + setSelectedOutfitUUID(category_id); + } +} + void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl) { if (!ctrl || mFilterSubString.empty()) @@ -510,26 +525,7 @@ void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl) LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (list != ctrl) continue; - std::string title = tab->getTitle(); - LLStringUtil::toUpper(title); - - std::string cur_filter = mFilterSubString; - LLStringUtil::toUpper(cur_filter); - - if (std::string::npos == title.find(cur_filter)) - { - // hide tab if its title doesn't pass filter - // and it has no visible items - tab->setVisible(list->size() != 0); - - // remove title highlighting because it might - // have been previously highlighted by less restrictive filter - tab->setTitle(tab->getTitle()); - } - else - { - tab->setTitle(tab->getTitle(), cur_filter); - } + applyFilterToTab(iter->first, tab, mFilterSubString); } } @@ -568,26 +564,7 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) if (!new_filter_substring.empty()) { - std::string title = tab->getTitle(); - LLStringUtil::toUpper(title); - - std::string cur_filter = new_filter_substring; - LLStringUtil::toUpper(cur_filter); - - if (std::string::npos == title.find(cur_filter)) - { - // hide tab if its title doesn't pass filter - // and it has no visible items - tab->setVisible(list->size() != 0); - - // remove title highlighting because it might - // have been previously highlighted by less restrictive filter - tab->setTitle(tab->getTitle()); - } - else - { - tab->setTitle(tab->getTitle(), cur_filter); - } + applyFilterToTab(iter->first, tab, new_filter_substring); if (tab->getVisible()) { @@ -608,10 +585,50 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) //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); } } } +void LLOutfitsList::applyFilterToTab( + const LLUUID& category_id, + LLAccordionCtrlTab* tab, + const std::string& filter_substring) +{ + if (!tab) return; + LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); + if (!list) return; + + std::string title = tab->getTitle(); + LLStringUtil::toUpper(title); + + std::string cur_filter = filter_substring; + LLStringUtil::toUpper(cur_filter); + + tab->setTitle(tab->getTitle(), cur_filter); + + if (std::string::npos == title.find(cur_filter)) + { + // hide tab if its title doesn't pass filter + // and it has no visible items + tab->setVisible(!list->empty()); + + // remove title highlighting because it might + // have been previously highlighted by less restrictive filter + tab->setTitle(tab->getTitle()); + + // Remove the tab from selection. + deselectOutfit(category_id); + } + else + { + // Try restoring the tab selection. + restoreOutfitSelection(tab, category_id); + } +} + void LLOutfitsList::onAccordionTabRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id) { LLAccordionCtrlTab* tab = dynamic_cast<LLAccordionCtrlTab*>(ctrl); diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index 5605044f41..33791fbe62 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -120,6 +120,18 @@ private: void setSelectedOutfitUUID(const LLUUID& category_id); /** + * Removes the outfit from selection. + */ + void deselectOutfit(const LLUUID& category_id); + + /** + * Try restoring selection for a temporary hidden tab. + * + * A tab may be hidden if it doesn't match current filter. + */ + void restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID& category_id); + + /** * Called upon list refresh event to update tab visibility depending on * the results of applying filter to the title and list items of the tab. */ @@ -130,6 +142,13 @@ private: */ void applyFilter(const std::string& new_filter_substring); + /** + * Applies filter to the given tab + * + * @see applyFilter() + */ + void applyFilterToTab(const LLUUID& category_id, LLAccordionCtrlTab* tab, const std::string& filter_substring); + void onAccordionTabRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id); void onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y); void onCOFChanged(); |