summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2016-05-30 15:03:40 +0300
committerMnikolenko Productengine <mnikolenko@productengine.com>2016-05-30 15:03:40 +0300
commit2b9927863ff6826bc448379e2f829b1de5e6c3fb (patch)
treed08425d49db951ee9b2dc29db7b0ca50f6a5528c
parent5b49f5c56e0178d1f2f655ee678a9bea58edd5d5 (diff)
MAINT-6444 Outfits filter doesn't work in Outfit gallery
-rw-r--r--indra/newview/lloutfitgallery.cpp42
-rw-r--r--indra/newview/lloutfitgallery.h7
2 files changed, 46 insertions, 3 deletions
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp
index f29fc53dea..6a8256d41c 100644
--- a/indra/newview/lloutfitgallery.cpp
+++ b/indra/newview/lloutfitgallery.cpp
@@ -152,6 +152,11 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff)
{
removeFromGalleryLast(*it);
}
+ for (std::vector<LLOutfitGalleryItem*>::const_reverse_iterator it = mHiddenItems.rbegin(); it != mHiddenItems.rend(); ++it)
+ {
+ buf_items.push_back(*it);
+ }
+ mHiddenItems.clear();
mItemsInRow+= row_diff;
updateGalleryWidth();
@@ -159,7 +164,9 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff)
for (std::vector<LLOutfitGalleryItem*>::const_iterator it = buf_items.begin(); it != buf_items.end(); ++it)
{
- addToGallery(*it);
+ (*it)->setHidden(false);
+ applyFilter(*it,sFilterSubString);
+ addToGallery(*it);
}
}
@@ -214,6 +221,11 @@ LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item
void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item)
{
+ if(item->isHidden())
+ {
+ mHiddenItems.push_back(item);
+ return;
+ }
mItemsAddedCount++;
mItemIndexMap[item] = mItemsAddedCount - 1;
int n = mItemsAddedCount;
@@ -241,6 +253,11 @@ void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item)
void LLOutfitGallery::removeFromGalleryLast(LLOutfitGalleryItem* item)
{
+ if(item->isHidden())
+ {
+ mHiddenItems.pop_back();
+ return;
+ }
int n_prev = mItemsAddedCount;
int n = mItemsAddedCount - 1;
int row_count = (n % mItemsInRow) == 0 ? n / mItemsInRow : n / mItemsInRow + 1;
@@ -264,6 +281,11 @@ void LLOutfitGallery::removeFromGalleryLast(LLOutfitGalleryItem* item)
void LLOutfitGallery::removeFromGalleryMiddle(LLOutfitGalleryItem* item)
{
+ if(item->isHidden())
+ {
+ mHiddenItems.erase(std::remove(mHiddenItems.begin(), mHiddenItems.end(), item), mHiddenItems.end());
+ return;
+ }
int n = mItemIndexMap[item];
mItemIndexMap.erase(item);
std::vector<LLOutfitGalleryItem*> saved;
@@ -371,9 +393,8 @@ LLOutfitGallery::~LLOutfitGallery()
void LLOutfitGallery::setFilterSubString(const std::string& string)
{
- //TODO: Implement filtering
-
sFilterSubString = string;
+ reArrangeRows();
}
void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id)
@@ -388,6 +409,20 @@ void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id)
}
}
+void LLOutfitGallery::applyFilter(LLOutfitGalleryItem* item, const std::string& filter_substring)
+{
+ if (!item) return;
+
+ std::string outfit_name = item->getItemName();
+ LLStringUtil::toUpper(outfit_name);
+
+ std::string cur_filter = filter_substring;
+ LLStringUtil::toUpper(cur_filter);
+
+ bool hidden = (std::string::npos == outfit_name.find(cur_filter));
+ item->setHidden(hidden);
+}
+
void LLOutfitGallery::onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid)
{
}
@@ -555,6 +590,7 @@ BOOL LLOutfitGalleryItem::postBuild()
mFotoBgPanel = getChild<LLPanel>("foto_bg_panel");
mTextBgPanel = getChild<LLPanel>("text_bg_panel");
setOutfitWorn(false);
+ mHidden = false;
return TRUE;
}
diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h
index a22e86df83..b3e699e0e7 100644
--- a/indra/newview/lloutfitgallery.h
+++ b/indra/newview/lloutfitgallery.h
@@ -120,6 +120,8 @@ protected:
/*virtual*/ void onExpandAllFolders() {}
/*virtual*/ LLOutfitListGearMenuBase* createGearMenu();
+ void applyFilter(LLOutfitGalleryItem* item, const std::string& filter_substring);
+
private:
void loadPhotos();
void uploadPhoto(LLUUID outfit_id);
@@ -153,6 +155,7 @@ private:
std::vector<LLPanel*> mRowPanels;
std::vector<LLPanel*> mItemPanels;
std::vector<LLOutfitGalleryItem*> mItems;
+ std::vector<LLOutfitGalleryItem*> mHiddenItems;
LLScrollContainer* mScrollPanel;
LLPanel* mGalleryPanel;
LLPanel* mLastRowPanel;
@@ -250,6 +253,9 @@ public:
std::string getItemName() {return mOutfitName;}
bool mIsDefaultImage() {return mDefaultImage;}
+ bool isHidden() {return mHidden;}
+ void setHidden(bool hidden) {mHidden = hidden;}
+
struct compareGalleryItem
{
bool operator()(LLOutfitGalleryItem* a, LLOutfitGalleryItem* b)
@@ -275,6 +281,7 @@ private:
bool mSelected;
bool mWorn;
bool mDefaultImage;
+ bool mHidden;
std::string mOutfitName;
};