summaryrefslogtreecommitdiff
path: root/indra/newview/lloutfitslist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lloutfitslist.cpp')
-rw-r--r--indra/newview/lloutfitslist.cpp117
1 files changed, 67 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);