summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-04-03 21:34:37 +0300
committerMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-04-03 21:35:35 +0300
commitbc285ed41e86e685df07f4039c64c0402833b047 (patch)
tree6f96b93d820940e21e756635dd0779a813d6ab1a
parent6306b1fa6e1d663a2a3adc43eb97e9044ca80e88 (diff)
SL-19521 Inventory filters floater should affect Inventory Gallery
-rw-r--r--indra/newview/llinventorygallery.cpp154
-rw-r--r--indra/newview/llinventorygallery.h11
-rw-r--r--indra/newview/llpanelmaininventory.cpp96
-rw-r--r--indra/newview/llpanelmaininventory.h2
4 files changed, 203 insertions, 60 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp
index 290688f179..da58aa70f9 100644
--- a/indra/newview/llinventorygallery.cpp
+++ b/indra/newview/llinventorygallery.cpp
@@ -84,12 +84,14 @@ LLInventoryGallery::LLInventoryGallery(const LLInventoryGallery::Params& p)
mRowPanWidthFactor(p.row_panel_width_factor),
mGalleryWidthFactor(p.gallery_width_factor),
mIsInitialized(false),
- mSearchType(LLInventoryFilter::SEARCHTYPE_NAME),
- mSearchLinks(true)
+ mSearchType(LLInventoryFilter::SEARCHTYPE_NAME)
{
updateGalleryWidth();
-
+ mFilter = new LLInventoryFilter();
mCategoriesObserver = new LLInventoryCategoriesObserver();
+
+ mUsername = gAgentUsername;
+ LLStringUtil::toUpper(mUsername);
}
LLInventoryGallery::Params::Params()
@@ -124,6 +126,7 @@ BOOL LLInventoryGallery::postBuild()
LLInventoryGallery::~LLInventoryGallery()
{
delete mInventoryGalleryMenu;
+ delete mFilter;
while (!mUnusedRowPanels.empty())
{
@@ -254,20 +257,26 @@ void LLInventoryGallery::draw()
LLPanel::draw();
if (mGalleryCreated)
{
- updateRowsIfNeeded();
+ if(!updateRowsIfNeeded() && mFilter->isModified())
+ {
+ reArrangeRows();
+ }
}
}
-void LLInventoryGallery::updateRowsIfNeeded()
+bool LLInventoryGallery::updateRowsIfNeeded()
{
if(((getRect().getWidth() - mRowPanelWidth) > mItemWidth) && mRowCount > 1)
{
reArrangeRows(1);
+ return true;
}
else if((mRowPanelWidth > (getRect().getWidth() + mItemHorizontalGap)) && mItemsInRow > GALLERY_ITEMS_PER_ROW_MIN)
{
reArrangeRows(-1);
+ return true;
}
+ return false;
}
bool compareGalleryItem(LLInventoryGalleryItem* item1, LLInventoryGalleryItem* item2)
@@ -312,6 +321,7 @@ void LLInventoryGallery::reArrangeRows(S32 row_diff)
applyFilter(*it, mFilterSubString);
addToGallery(*it);
}
+ mFilter->clearModified();
updateMessageVisibility();
}
@@ -558,20 +568,50 @@ void LLInventoryGallery::moveRowPanel(LLPanel* stack, int left, int bottom)
void LLInventoryGallery::setFilterSubString(const std::string& string)
{
mFilterSubString = string;
- reArrangeRows();
+ mFilter->setFilterSubString(string);
+
+ //reArrangeRows();
}
void LLInventoryGallery::applyFilter(LLInventoryGalleryItem* item, const std::string& filter_substring)
{
if (!item) return;
- std::string desc;
- if(!mSearchLinks && item->isLink())
+ if (item->isFolder() && (mFilter->getShowFolderState() == LLInventoryFilter::SHOW_ALL_FOLDERS))
+ {
+ item->setHidden(false);
+ return;
+ }
+
+ if(item->isLink() && ((mFilter->getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_LINKS) == 0) && !filter_substring.empty())
+ {
+ item->setHidden(true);
+ return;
+ }
+
+ bool hidden = false;
+
+ if(mFilter->getFilterCreatorType() == LLInventoryFilter::FILTERCREATOR_SELF)
+ {
+ hidden = (item->getCreatorName() == mUsername) || item->isFolder();
+ }
+ else if(mFilter->getFilterCreatorType() == LLInventoryFilter::FILTERCREATOR_OTHERS)
+ {
+ hidden = (item->getCreatorName() != mUsername) || item->isFolder();
+ }
+ if(hidden)
+ {
+ item->setHidden(true);
+ return;
+ }
+
+ if(!checkAgainstFilterType(item->getUUID()))
{
item->setHidden(true);
return;
}
+ std::string desc;
switch(mSearchType)
{
case LLInventoryFilter::SEARCHTYPE_CREATOR:
@@ -594,7 +634,7 @@ void LLInventoryGallery::applyFilter(LLInventoryGalleryItem* item, const std::st
std::string cur_filter = filter_substring;
LLStringUtil::toUpper(cur_filter);
- bool hidden = (std::string::npos == desc.find(cur_filter));
+ hidden = (std::string::npos == desc.find(cur_filter));
item->setHidden(hidden);
}
@@ -610,15 +650,6 @@ void LLInventoryGallery::setSearchType(LLInventoryFilter::ESearchType type)
}
}
-void LLInventoryGallery::toggleSearchLinks()
-{
- mSearchLinks = !mSearchLinks;
- if(!mFilterSubString.empty())
- {
- reArrangeRows();
- }
-}
-
void LLInventoryGallery::getCurrentCategories(uuid_vec_t& vcur)
{
for (gallery_item_map_t::const_iterator iter = mItemMap.begin();
@@ -777,7 +808,13 @@ void LLInventoryGallery::onChangeItemSelection(const LLUUID& category_id)
void LLInventoryGallery::updateMessageVisibility()
{
+
mMessageTextBox->setVisible(mItems.empty());
+ if(mItems.empty())
+ {
+ mMessageTextBox->setText(hasDescendents(mFolderID) ? LLTrans::getString("InventorySingleFolderEmpty") : LLTrans::getString("InventorySingleFolderNoMatches"));
+ }
+
mScrollPanel->setVisible(!mItems.empty());
}
@@ -1001,6 +1038,87 @@ BOOL LLInventoryGallery::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
return handled;
}
+bool LLInventoryGallery::hasDescendents(const LLUUID& cat_id)
+{
+ LLInventoryModel::cat_array_t* cats;
+ LLInventoryModel::item_array_t* items;
+ gInventory.getDirectDescendentsOf(cat_id, cats, items);
+
+ return (cats->empty() && items->empty());
+}
+
+bool LLInventoryGallery::checkAgainstFilterType(const LLUUID& object_id)
+{
+ const LLInventoryObject *object = gInventory.getObject(object_id);
+ if(!object) return false;
+
+ LLInventoryType::EType object_type = LLInventoryType::IT_CATEGORY;
+ LLInventoryItem* inv_item = gInventory.getItem(object_id);
+ if (inv_item)
+ {
+ object_type = inv_item->getInventoryType();
+ }
+ const U32 filterTypes = mFilter->getFilterTypes();
+
+ if ((filterTypes & LLInventoryFilter::FILTERTYPE_OBJECT) && inv_item)
+ {
+ switch (object_type)
+ {
+ case LLInventoryType::IT_NONE:
+ // If it has no type, pass it, unless it's a link.
+ if (object && object->getIsLinkType())
+ {
+ return false;
+ }
+ break;
+ case LLInventoryType::IT_UNKNOWN:
+ {
+ // Unknows are only shown when we show every type.
+ // Unknows are 255 and won't fit in 64 bits.
+ if (mFilter->getFilterObjectTypes() != 0xffffffffffffffffULL)
+ {
+ return false;
+ }
+ break;
+ }
+ default:
+ if ((1LL << object_type & mFilter->getFilterObjectTypes()) == U64(0))
+ {
+ return false;
+ }
+ break;
+ }
+ }
+
+ if (filterTypes & LLInventoryFilter::FILTERTYPE_DATE)
+ {
+ const U16 HOURS_TO_SECONDS = 3600;
+ time_t earliest = time_corrected() - mFilter->getHoursAgo() * HOURS_TO_SECONDS;
+
+ if (mFilter->getMinDate() > time_min() && mFilter->getMinDate() < earliest)
+ {
+ earliest = mFilter->getMinDate();
+ }
+ else if (!mFilter->getHoursAgo())
+ {
+ earliest = 0;
+ }
+
+ if (LLInventoryFilter::FILTERDATEDIRECTION_NEWER == mFilter->getDateSearchDirection() || mFilter->isSinceLogoff())
+ {
+ if (object->getCreationDate() < earliest ||
+ object->getCreationDate() > mFilter->getMaxDate())
+ return false;
+ }
+ else
+ {
+ if (object->getCreationDate() > earliest ||
+ object->getCreationDate() > mFilter->getMaxDate())
+ return false;
+ }
+ }
+ return true;
+}
//-----------------------------
// LLInventoryGalleryItem
//-----------------------------
diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h
index 036817de93..cef7574093 100644
--- a/indra/newview/llinventorygallery.h
+++ b/indra/newview/llinventorygallery.h
@@ -75,6 +75,8 @@ public:
void setFilterSubString(const std::string& string);
std::string getFilterSubString() { return mFilterSubString; }
+ LLInventoryFilter& getFilter() const { return *mFilter; }
+ bool checkAgainstFilterType(const LLUUID& object_id);
void getCurrentCategories(uuid_vec_t& vcur);
void updateAddedItem(LLUUID item_id);
@@ -114,8 +116,8 @@ public:
void setSearchType(LLInventoryFilter::ESearchType type);
LLInventoryFilter::ESearchType getSearchType() { return mSearchType; }
- void toggleSearchLinks();
- bool getSearchLinks(){ return mSearchLinks; }
+
+ bool hasDescendents(const LLUUID& cat_id);
protected:
@@ -146,7 +148,7 @@ private:
LLPanel* addToRow(LLPanel* row_stack, LLInventoryGalleryItem* item, int pos, int hgap);
void removeFromLastRow(LLInventoryGalleryItem* item);
void reArrangeRows(S32 row_diff = 0);
- void updateRowsIfNeeded();
+ bool updateRowsIfNeeded();
void updateGalleryWidth();
LLInventoryGalleryItem* buildGalleryItem(std::string name, LLUUID item_id, LLAssetType::EType type, LLUUID thumbnail_id, LLInventoryType::EType inventory_type, U32 flags, bool is_link, bool is_worn);
@@ -186,6 +188,7 @@ private:
LLInventoryGalleryContextMenu* mInventoryGalleryMenu;
std::string mFilterSubString;
+ LLInventoryFilter* mFilter;
typedef std::map<LLUUID, LLInventoryGalleryItem*> gallery_item_map_t;
gallery_item_map_t mItemMap;
@@ -193,7 +196,7 @@ private:
std::map<LLInventoryGalleryItem*, S32> mItemIndexMap;
LLInventoryFilter::ESearchType mSearchType;
- bool mSearchLinks;
+ std::string mUsername;
};
class LLInventoryGalleryItem : public LLPanel
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index e55d1f19f4..383250e3ac 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -506,7 +506,7 @@ void LLPanelMainInventory::doCreate(const LLSD& userdata)
void LLPanelMainInventory::resetFilters()
{
LLFloaterInventoryFinder *finder = getFinder();
- getActivePanel()->getFilter().resetDefault();
+ getCurrentFilter().resetDefault();
if (finder)
{
finder->updateElementsFromFilter();
@@ -802,7 +802,7 @@ void LLPanelMainInventory::onFilterSelected()
}
updateSearchTypeCombo();
setFilterSubString(mFilterSubString);
- LLInventoryFilter& filter = mActivePanel->getFilter();
+ LLInventoryFilter& filter = getCurrentFilter();
LLFloaterInventoryFinder *finder = getFinder();
if (finder)
{
@@ -956,7 +956,7 @@ void LLPanelMainInventory::onFocusReceived()
void LLPanelMainInventory::setFilterTextFromFilter()
{
- mFilterText = mActivePanel->getFilter().getFilterText();
+ mFilterText = getCurrentFilter().getFilterText();
}
void LLPanelMainInventory::toggleFindOptions()
@@ -1210,10 +1210,21 @@ void LLFloaterInventoryFinder::draw()
filter &= ~(0x1 << LLInventoryType::IT_CATEGORY);
}
- // update the panel, panel will update the filter
- mPanelMainInventory->getPanel()->setShowFolderState(getCheckShowEmpty() ?
- LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
- mPanelMainInventory->getPanel()->setFilterTypes(filter);
+
+ bool is_gallery = mPanelMainInventory->isSingleFolderMode() && mPanelMainInventory->isGalleryViewMode();
+ if(is_gallery)
+ {
+ mPanelMainInventory->mInventoryGalleryPanel->getFilter().setShowFolderState(getCheckShowEmpty() ?
+ LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
+ mPanelMainInventory->mInventoryGalleryPanel->getFilter().setFilterObjectTypes(filter);
+ }
+ else
+ {
+ // update the panel, panel will update the filter
+ mPanelMainInventory->getPanel()->setShowFolderState(getCheckShowEmpty() ?
+ LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
+ mPanelMainInventory->getPanel()->setFilterTypes(filter);
+ }
if (getCheckSinceLogoff())
{
@@ -1235,10 +1246,20 @@ void LLFloaterInventoryFinder::draw()
}
hours += days * 24;
- mPanelMainInventory->getPanel()->setHoursAgo(hours);
- mPanelMainInventory->getPanel()->setSinceLogoff(getCheckSinceLogoff());
+
mPanelMainInventory->setFilterTextFromFilter();
- mPanelMainInventory->getPanel()->setDateSearchDirection(getDateSearchDirection());
+ if(is_gallery)
+ {
+ mPanelMainInventory->mInventoryGalleryPanel->getFilter().setHoursAgo(hours);
+ mPanelMainInventory->mInventoryGalleryPanel->getFilter().setDateRangeLastLogoff(getCheckSinceLogoff());
+ mPanelMainInventory->mInventoryGalleryPanel->getFilter().setDateSearchDirection(getDateSearchDirection());
+ }
+ else
+ {
+ mPanelMainInventory->getPanel()->setHoursAgo(hours);
+ mPanelMainInventory->getPanel()->setSinceLogoff(getCheckSinceLogoff());
+ mPanelMainInventory->getPanel()->setDateSearchDirection(getDateSearchDirection());
+ }
LLPanel::draw();
}
@@ -1250,15 +1271,15 @@ void LLFloaterInventoryFinder::onCreatorSelfFilterCommit()
if(show_creator_self && show_creator_other)
{
- mFilter->setFilterCreator(LLInventoryFilter::FILTERCREATOR_ALL);
+ mPanelMainInventory->getCurrentFilter().setFilterCreator(LLInventoryFilter::FILTERCREATOR_ALL);
}
else if(show_creator_self)
{
- mFilter->setFilterCreator(LLInventoryFilter::FILTERCREATOR_SELF);
+ mPanelMainInventory->getCurrentFilter().setFilterCreator(LLInventoryFilter::FILTERCREATOR_SELF);
}
else if(!show_creator_self || !show_creator_other)
{
- mFilter->setFilterCreator(LLInventoryFilter::FILTERCREATOR_OTHERS);
+ mPanelMainInventory->getCurrentFilter().setFilterCreator(LLInventoryFilter::FILTERCREATOR_OTHERS);
mCreatorOthers->set(TRUE);
}
}
@@ -1270,15 +1291,15 @@ void LLFloaterInventoryFinder::onCreatorOtherFilterCommit()
if(show_creator_self && show_creator_other)
{
- mFilter->setFilterCreator(LLInventoryFilter::FILTERCREATOR_ALL);
+ mPanelMainInventory->getCurrentFilter().setFilterCreator(LLInventoryFilter::FILTERCREATOR_ALL);
}
else if(show_creator_other)
{
- mFilter->setFilterCreator(LLInventoryFilter::FILTERCREATOR_OTHERS);
+ mPanelMainInventory->getCurrentFilter().setFilterCreator(LLInventoryFilter::FILTERCREATOR_OTHERS);
}
else if(!show_creator_other || !show_creator_self)
{
- mFilter->setFilterCreator(LLInventoryFilter::FILTERCREATOR_SELF);
+ mPanelMainInventory->getCurrentFilter().setFilterCreator(LLInventoryFilter::FILTERCREATOR_SELF);
mCreatorSelf->set(TRUE);
}
}
@@ -1763,29 +1784,22 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata)
if (command_name == "toggle_search_outfits")
{
- mActivePanel->getFilter().toggleSearchVisibilityOutfits();
+ getCurrentFilter().toggleSearchVisibilityOutfits();
}
if (command_name == "toggle_search_trash")
{
- mActivePanel->getFilter().toggleSearchVisibilityTrash();
+ getCurrentFilter().toggleSearchVisibilityTrash();
}
if (command_name == "toggle_search_library")
{
- mActivePanel->getFilter().toggleSearchVisibilityLibrary();
+ getCurrentFilter().toggleSearchVisibilityLibrary();
}
if (command_name == "include_links")
{
- if(mSingleFolderMode && isGalleryViewMode())
- {
- mInventoryGalleryPanel->toggleSearchLinks();
- }
- else
- {
- mActivePanel->getFilter().toggleSearchVisibilityLinks();
- }
+ getCurrentFilter().toggleSearchVisibilityLinks();
}
if (command_name == "share")
@@ -2000,29 +2014,22 @@ BOOL LLPanelMainInventory::isActionChecked(const LLSD& userdata)
if (command_name == "toggle_search_outfits")
{
- return (mActivePanel->getFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_OUTFITS) != 0;
+ return (getCurrentFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_OUTFITS) != 0;
}
if (command_name == "toggle_search_trash")
{
- return (mActivePanel->getFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_TRASH) != 0;
+ return (getCurrentFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_TRASH) != 0;
}
if (command_name == "toggle_search_library")
{
- return (mActivePanel->getFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_LIBRARY) != 0;
+ return (getCurrentFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_LIBRARY) != 0;
}
if (command_name == "include_links")
{
- if(mSingleFolderMode && isGalleryViewMode())
- {
- return mInventoryGalleryPanel->getSearchLinks();
- }
- else
- {
- return (mActivePanel->getFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_LINKS) != 0;
- }
+ return (getCurrentFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_LINKS) != 0;
}
if (command_name == "list_view")
@@ -2135,6 +2142,7 @@ void LLPanelMainInventory::setViewMode(EViewModeType mode)
}
updateNavButtons();
+ onFilterSelected();
if((isListViewMode() && (mActivePanel->getFilterSubString() != mFilterSubString)) ||
(isGalleryViewMode() && (mInventoryGalleryPanel->getFilterSubString() != mFilterSubString)))
{
@@ -2160,5 +2168,17 @@ LLUUID LLPanelMainInventory::getCurrentSFVRoot()
}
return LLUUID::null;
}
+
+LLInventoryFilter& LLPanelMainInventory::getCurrentFilter()
+{
+ if(mSingleFolderMode && isGalleryViewMode())
+ {
+ return mInventoryGalleryPanel->getFilter();
+ }
+ else
+ {
+ return mActivePanel->getFilter();
+ }
+}
// List Commands //
////////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h
index bd51830ebb..1f0dfc82d2 100644
--- a/indra/newview/llpanelmaininventory.h
+++ b/indra/newview/llpanelmaininventory.h
@@ -127,6 +127,8 @@ public:
LLUUID getCurrentSFVRoot();
std::string getLocalizedRootName();
+ LLInventoryFilter& getCurrentFilter();
+
protected:
//
// Misc functions