diff options
author | Vadim Savchuk <vsavchuk@productengine.com> | 2010-04-30 19:08:31 +0300 |
---|---|---|
committer | Vadim Savchuk <vsavchuk@productengine.com> | 2010-04-30 19:08:31 +0300 |
commit | 05c662528a6754d2d1c15d39c7605945c2b776e2 (patch) | |
tree | 4ffa7bee8100a343a0d3349c12b5f32ecab78654 /indra/newview | |
parent | 9fda462330692dafc66f1b47d67c5378cf4e3552 (diff) | |
parent | d6edc4cd12c015003cd665028b69a7b34b3aa54f (diff) |
merge
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llcofwearables.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llinventoryitemslist.cpp | 58 | ||||
-rw-r--r-- | indra/newview/llinventoryitemslist.h | 26 | ||||
-rw-r--r-- | indra/newview/lloutfitslist.cpp | 28 |
4 files changed, 127 insertions, 12 deletions
diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp index 36a8031cce..1925b818f2 100644 --- a/indra/newview/llcofwearables.cpp +++ b/indra/newview/llcofwearables.cpp @@ -94,6 +94,16 @@ void LLCOFWearables::onSelectionChange(LLFlatListView* selected_list) void LLCOFWearables::refresh() { + typedef std::vector<LLSD> values_vector_t; + typedef std::map<LLFlatListView*, values_vector_t> selection_map_t; + + selection_map_t preserve_selection; + + // Save current selection + mAttachments->getSelectedValues(preserve_selection[mAttachments]); + mClothing->getSelectedValues(preserve_selection[mClothing]); + mBodyParts->getSelectedValues(preserve_selection[mBodyParts]); + clear(); LLInventoryModel::cat_array_t cats; @@ -108,6 +118,23 @@ void LLCOFWearables::refresh() LLAppearanceMgr::getInstance()->divvyWearablesByType(cof_items, clothing_by_type); populateClothingList(clothing_by_type); + + // Restore previous selection + for (selection_map_t::iterator + iter = preserve_selection.begin(), + iter_end = preserve_selection.end(); + iter != iter_end; ++iter) + { + LLFlatListView* list = iter->first; + const values_vector_t& values = iter->second; + for (values_vector_t::const_iterator + value_it = values.begin(), + value_it_end = values.end(); + value_it != value_it_end; ++value_it) + { + list->selectItemByValue(*value_it); + } + } } 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")); + } + } + } } ////////////////////////////////////////////////////////////////////////// |