Skip to content
Snippets Groups Projects
Commit d8b989a8 authored by Sergei Litovchuk's avatar Sergei Litovchuk
Browse files

EXT-7158 ADDITIONAL FIX Optimization and implementation fix

- Fixed issue with filter not applied to outfit newly added while filtering is active.
- Optimization of refreshing outfit list when filter is applied - list is not refreshed on every list visibility change.

Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/394/

--HG--
branch : product-engine
parent fcea61df
Branches
Tags
No related merge requests found
...@@ -322,7 +322,7 @@ LLInventoryItemsList::Params::Params() ...@@ -322,7 +322,7 @@ LLInventoryItemsList::Params::Params()
LLInventoryItemsList::LLInventoryItemsList(const LLInventoryItemsList::Params& p) LLInventoryItemsList::LLInventoryItemsList(const LLInventoryItemsList::Params& p)
: LLFlatListViewEx(p) : LLFlatListViewEx(p)
, mNeedsRefresh(false) , mNeedsRefresh(false)
, mPrevVisibility(false) , mForceRefresh(false)
{ {
// TODO: mCommitOnSelectionChange is set to "false" in LLFlatListView // TODO: mCommitOnSelectionChange is set to "false" in LLFlatListView
// but reset to true in all derived classes. This settings might need to // but reset to true in all derived classes. This settings might need to
...@@ -356,14 +356,13 @@ boost::signals2::connection LLInventoryItemsList::setRefreshCompleteCallback(con ...@@ -356,14 +356,13 @@ boost::signals2::connection LLInventoryItemsList::setRefreshCompleteCallback(con
void LLInventoryItemsList::doIdle() void LLInventoryItemsList::doIdle()
{ {
bool cur_visibility = getVisible(); if (!mNeedsRefresh) return;
if(cur_visibility != mPrevVisibility || mNeedsRefresh)
if (isInVisibleChain() || mForceRefresh)
{ {
refresh(); refresh();
mRefreshCompleteSignal(this, LLSD()); mRefreshCompleteSignal(this, LLSD());
mPrevVisibility = getVisible();
} }
} }
...@@ -414,6 +413,7 @@ void LLInventoryItemsList::refresh() ...@@ -414,6 +413,7 @@ void LLInventoryItemsList::refresh()
bool needs_refresh = add_limit_exceeded; bool needs_refresh = add_limit_exceeded;
setNeedsRefresh(needs_refresh); setNeedsRefresh(needs_refresh);
setForceRefresh(needs_refresh);
} }
void LLInventoryItemsList::computeDifference( void LLInventoryItemsList::computeDifference(
......
...@@ -221,6 +221,12 @@ class LLInventoryItemsList : public LLFlatListViewEx ...@@ -221,6 +221,12 @@ class LLInventoryItemsList : public LLFlatListViewEx
bool getNeedsRefresh(){ return mNeedsRefresh; } bool getNeedsRefresh(){ return mNeedsRefresh; }
/**
* Sets the flag indicating that the list needs to be refreshed even if it is
* not currently visible.
*/
void setForceRefresh(bool force_refresh){ mForceRefresh = force_refresh; }
/** /**
* Idle routine used to refresh the list regardless of the current list * Idle routine used to refresh the list regardless of the current list
* visibility, unlike draw() which is called only for the visible list. * visibility, unlike draw() which is called only for the visible list.
...@@ -259,7 +265,7 @@ class LLInventoryItemsList : public LLFlatListViewEx ...@@ -259,7 +265,7 @@ class LLInventoryItemsList : public LLFlatListViewEx
// Will be used in refresh() to determine added and removed ids // Will be used in refresh() to determine added and removed ids
bool mNeedsRefresh; bool mNeedsRefresh;
bool mPrevVisibility; bool mForceRefresh;
commit_signal_t mRefreshCompleteSignal; commit_signal_t mRefreshCompleteSignal;
}; };
......
...@@ -170,7 +170,7 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) ...@@ -170,7 +170,7 @@ void LLOutfitsList::refreshList(const LLUUID& category_id)
list->setCommitCallback(boost::bind(&LLOutfitsList::onSelectionChange, this, _1)); list->setCommitCallback(boost::bind(&LLOutfitsList::onSelectionChange, this, _1));
// Setting list refresh callback to apply filter on list change. // Setting list refresh callback to apply filter on list change.
list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onWearableItemsListRefresh, this, _1)); list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onFilteredWearableItemsListRefresh, this, _1));
// Fetch the new outfit contents. // Fetch the new outfit contents.
cat->fetch(); cat->fetch();
...@@ -178,6 +178,21 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) ...@@ -178,6 +178,21 @@ void LLOutfitsList::refreshList(const LLUUID& category_id)
// Refresh the list of outfit items after fetch(). // Refresh the list of outfit items after fetch().
// Further list updates will be triggered by the category observer. // Further list updates will be triggered by the category observer.
list->updateList(cat_id); 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 (!mFilterSubString.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(mFilterSubString);
}
} }
// Handle removed tabs. // Handle removed tabs.
...@@ -327,7 +342,7 @@ void LLOutfitsList::changeOutfitSelection(LLWearableItemsList* list, const LLUUI ...@@ -327,7 +342,7 @@ void LLOutfitsList::changeOutfitSelection(LLWearableItemsList* list, const LLUUI
mSelectedOutfitUUID = category_id; mSelectedOutfitUUID = category_id;
} }
void LLOutfitsList::onWearableItemsListRefresh(LLUICtrl* ctrl) void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl)
{ {
if (!ctrl || mFilterSubString.empty()) if (!ctrl || mFilterSubString.empty())
return; return;
...@@ -338,7 +353,7 @@ void LLOutfitsList::onWearableItemsListRefresh(LLUICtrl* ctrl) ...@@ -338,7 +353,7 @@ void LLOutfitsList::onWearableItemsListRefresh(LLUICtrl* ctrl)
iter != iter_end; ++iter) iter != iter_end; ++iter)
{ {
LLAccordionCtrlTab* tab = iter->second; LLAccordionCtrlTab* tab = iter->second;
if (tab) continue; if (!tab) continue;
LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView());
if (list != ctrl) continue; if (list != ctrl) continue;
...@@ -395,8 +410,6 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) ...@@ -395,8 +410,6 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring)
if (!new_filter_substring.empty()) if (!new_filter_substring.empty())
{ {
tab->setDisplayChildren(true);
std::string title = tab->getTitle(); std::string title = tab->getTitle();
LLStringUtil::toUpper(title); LLStringUtil::toUpper(title);
...@@ -413,6 +426,18 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring) ...@@ -413,6 +426,18 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring)
{ {
tab->setTitle(tab->getTitle(), cur_filter); tab->setTitle(tab->getTitle(), cur_filter);
} }
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);
}
} }
else else
{ {
......
...@@ -98,7 +98,7 @@ class LLOutfitsList : public LLPanel, public LLInventoryObserver ...@@ -98,7 +98,7 @@ class LLOutfitsList : public LLPanel, public LLInventoryObserver
* Called upon list refresh event to update tab visibility depending on * 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. * the results of applying filter to the title and list items of the tab.
*/ */
void onWearableItemsListRefresh(LLUICtrl* ctrl); void onFilteredWearableItemsListRefresh(LLUICtrl* ctrl);
/** /**
* Highlights filtered items and hides tabs which haven't passed filter. * Highlights filtered items and hides tabs which haven't passed filter.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment