diff options
author | Eugene Mutavchi <emutavchi@productengine.com> | 2010-04-30 18:27:24 +0300 |
---|---|---|
committer | Eugene Mutavchi <emutavchi@productengine.com> | 2010-04-30 18:27:24 +0300 |
commit | d6edc4cd12c015003cd665028b69a7b34b3aa54f (patch) | |
tree | 58ffcac02b74dab72a7260e99d2d2bb87ed1b6de /indra/newview/llinventoryitemslist.cpp | |
parent | 779bf4bb59e9c8d832de84bc926e8839827735b7 (diff) |
Implemented normal EXT-7002 (Inventory flat list needs optimization.):
- changed the LLInventoryItemsList::addNewItem() to add item to the list without immediately rearranging
- implemented LLFlatListViewEx::setFilterSubString(), sets up new filter string and filters the list.
- implemented LLFlatListViewEx::filterItems(), filters the list, rearranges and notifies parent about shape changes. The list items are filtered using the notify() functionality, without need in adding/removing them on each filter call. It sends 'match_filter' request to items and interprets the returned zero as sign of matched filter string, i.e. we don't hide items that don't support 'match_filter' action(separators etc).
- filtring of LLOutfitsList.
Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/342/
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview/llinventoryitemslist.cpp')
-rw-r--r-- | indra/newview/llinventoryitemslist.cpp | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/indra/newview/llinventoryitemslist.cpp b/indra/newview/llinventoryitemslist.cpp index 8dfdb0788a..9719de4650 100644 --- a/indra/newview/llinventoryitemslist.cpp +++ b/indra/newview/llinventoryitemslist.cpp @@ -45,6 +45,7 @@ #include "llinventoryfunctions.h" #include "llinventorymodel.h" #include "lltextutil.h" +#include "lltrans.h" //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -63,6 +64,16 @@ LLPanelInventoryListItemBase* LLPanelInventoryListItemBase::create(LLViewerInven return list_item; } +void LLPanelInventoryListItemBase::draw() +{ + if (getNeedsRefresh()) + { + updateItem(); + setNeedsRefresh(false); + } + LLPanel::draw(); +} + void LLPanelInventoryListItemBase::updateItem() { setIconImage(mIconImage); @@ -121,7 +132,7 @@ BOOL LLPanelInventoryListItemBase::postBuild() mIconImage = get_item_icon(mItem->getType(), mItem->getInventoryType(), mItem->getFlags(), FALSE); - updateItem(); + setNeedsRefresh(true); setWidgetsVisible(false); reshapeWidgets(); @@ -148,6 +159,34 @@ void LLPanelInventoryListItemBase::onMouseLeave(S32 x, S32 y, MASK mask) LLPanel::onMouseLeave(x, y, mask); } +S32 LLPanelInventoryListItemBase::notify(const LLSD& info) +{ + S32 rv = 0; + if(info.has("match_filter")) + { + mHighlightedText = info["match_filter"].asString(); + + std::string test(mItem->getName()); + LLStringUtil::toUpper(test); + + if(mHighlightedText.empty() || std::string::npos != test.find(mHighlightedText)) + { + rv = 0; // substring is found + } + else + { + rv = -1; + } + + setNeedsRefresh(true); + } + else + { + rv = LLPanel::notify(info); + } + return rv; +} + LLPanelInventoryListItemBase::LLPanelInventoryListItemBase(LLViewerInventoryItem* item) : LLPanel() , mItem(item) @@ -156,6 +195,7 @@ LLPanelInventoryListItemBase::LLPanelInventoryListItemBase(LLViewerInventoryItem , mWidgetSpacing(WIDGET_SPACING) , mLeftWidgetsWidth(0) , mRightWidgetsWidth(0) +, mNeedsRefresh(false) { } @@ -278,13 +318,15 @@ LLInventoryItemsList::Params::Params() {} LLInventoryItemsList::LLInventoryItemsList(const LLInventoryItemsList::Params& p) -: LLFlatListView(p) +: LLFlatListViewEx(p) , mNeedsRefresh(false) { // TODO: mCommitOnSelectionChange is set to "false" in LLFlatListView // but reset to true in all derived classes. This settings might need to // be added to LLFlatListView::Params() and/or set to "true" by default. setCommitOnSelectionChange(true); + + setNoFilteredItemsMsg(LLTrans::getString("InventoryNoMatchingItems")); } // virtual @@ -304,7 +346,7 @@ void LLInventoryItemsList::refreshList(const LLInventoryModel::item_array_t item void LLInventoryItemsList::draw() { - LLFlatListView::draw(); + LLFlatListViewEx::draw(); if(mNeedsRefresh) { refresh(); @@ -332,7 +374,8 @@ void LLInventoryItemsList::refresh() break; } LLViewerInventoryItem* item = gInventory.getItem(*it); - addNewItem(item); + // Do not rearrange items on each adding, let's do that on filter call + addNewItem(item, false); ++nadded; } @@ -342,6 +385,9 @@ void LLInventoryItemsList::refresh() removeItemByUUID(*it); } + // Filter, rearrange and notify parent about shape changes + filterItems(); + bool needs_refresh = add_limit_exceeded; setNeedsRefresh(needs_refresh); } @@ -363,7 +409,7 @@ void LLInventoryItemsList::computeDifference( LLCommonUtils::computeDifference(vnew, vcur, vadded, vremoved); } -void LLInventoryItemsList::addNewItem(LLViewerInventoryItem* item) +void LLInventoryItemsList::addNewItem(LLViewerInventoryItem* item, bool rearrange /*= true*/) { if (!item) { @@ -375,7 +421,7 @@ void LLInventoryItemsList::addNewItem(LLViewerInventoryItem* item) if (!list_item) return; - bool is_item_added = addItem(list_item, item->getUUID()); + bool is_item_added = addItem(list_item, item->getUUID(), ADD_BOTTOM, rearrange); if (!is_item_added) { llwarns << "Couldn't add flat list item." << llendl; |