summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llinventoryitemslist.cpp58
-rw-r--r--indra/newview/llinventoryitemslist.h26
-rw-r--r--indra/newview/lloutfitslist.cpp28
3 files changed, 100 insertions, 12 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;
diff --git a/indra/newview/llinventoryitemslist.h b/indra/newview/llinventoryitemslist.h
index 152aafbd7e..bc04eb6f5b 100644
--- a/indra/newview/llinventoryitemslist.h
+++ b/indra/newview/llinventoryitemslist.h
@@ -64,13 +64,16 @@ class LLViewerInventoryItem;
class LLPanelInventoryListItemBase : public LLPanel
{
public:
-
static LLPanelInventoryListItemBase* create(LLViewerInventoryItem* item);
+ virtual void draw();
+
/**
- * Called after inventory item was updated, update panel widgets to reflect inventory changes.
+ * Let item know it need to be refreshed in next draw()
*/
- virtual void updateItem();
+ void setNeedsRefresh(bool needs_refresh){ mNeedsRefresh = needs_refresh; }
+
+ bool getNeedsRefresh(){ return mNeedsRefresh; }
/**
* Add widget to left side
@@ -107,6 +110,11 @@ public:
*/
/*virtual*/ void setValue(const LLSD& value);
+ /**
+ * Handles filter request
+ */
+ /*virtual*/ S32 notify(const LLSD& info);
+
/* Highlights item */
/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
/* Removes item highlight */
@@ -125,6 +133,11 @@ protected:
*/
virtual void init();
+ /**
+ * Called after inventory item was updated, update panel widgets to reflect inventory changes.
+ */
+ virtual void updateItem();
+
/** setter for mIconCtrl */
void setIconCtrl(LLIconCtrl* icon) { mIconCtrl = icon; }
/** setter for MTitleCtrl */
@@ -178,14 +191,15 @@ private:
S32 mLeftWidgetsWidth;
S32 mRightWidgetsWidth;
+ bool mNeedsRefresh;
};
//////////////////////////////////////////////////////////////////////////
-class LLInventoryItemsList : public LLFlatListView
+class LLInventoryItemsList : public LLFlatListViewEx
{
public:
- struct Params : public LLInitParam::Block<Params, LLFlatListView::Params>
+ struct Params : public LLInitParam::Block<Params, LLFlatListViewEx::Params>
{
Params();
};
@@ -225,7 +239,7 @@ protected:
/**
* Add an item to the list
*/
- virtual void addNewItem(LLViewerInventoryItem* item);
+ virtual void addNewItem(LLViewerInventoryItem* item, bool rearrange = true);
private:
uuid_vec_t mIDs; // IDs of items that were added in refreshList().
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index b103ec45d0..18bd610dd9 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -245,6 +245,34 @@ void LLOutfitsList::performAction(std::string action)
void LLOutfitsList::setFilterSubString(const std::string& string)
{
mFilterSubString = string;
+
+ for (outfits_map_t::iterator
+ iter = mOutfitsMap.begin(),
+ iter_end = mOutfitsMap.end();
+ iter != iter_end; ++iter)
+ {
+ LLAccordionCtrlTab* tab = iter->second;
+ if (tab)
+ {
+ LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*> (tab->getAccordionView());
+ if (list)
+ {
+ list->setFilterSubString(mFilterSubString);
+ }
+
+ if(!mFilterSubString.empty())
+ {
+ //store accordion tab state when filter is not empty
+ tab->notifyChildren(LLSD().with("action","store_state"));
+ tab->setDisplayChildren(true);
+ }
+ else
+ {
+ //restore accordion state after all those accodrion tab manipulations
+ tab->notifyChildren(LLSD().with("action","restore_state"));
+ }
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////