summaryrefslogtreecommitdiff
path: root/indra/newview/llinventoryfilter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventoryfilter.cpp')
-rw-r--r--indra/newview/llinventoryfilter.cpp86
1 files changed, 83 insertions, 3 deletions
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index 1433ea36bf..9193613e9f 100644
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -29,6 +29,7 @@
#include "llinventoryfilter.h"
// viewer includes
+#include "llagent.h"
#include "llfolderviewmodel.h"
#include "llfolderviewitem.h"
#include "llinventorymodel.h"
@@ -76,10 +77,14 @@ LLInventoryFilter::LLInventoryFilter(const Params& p)
mFilterSubString(p.substring),
mCurrentGeneration(0),
mFirstRequiredGeneration(0),
- mFirstSuccessGeneration(0)
+ mFirstSuccessGeneration(0),
+ mSearchType(SEARCHTYPE_NAME),
+ mFilterCreatorType(FILTERCREATOR_ALL)
{
// copy mFilterOps into mDefaultFilterOps
markDefault();
+ mUsername = gAgentUsername;
+ LLStringUtil::toUpper(mUsername);
}
bool LLInventoryFilter::check(const LLFolderViewModelItem* item)
@@ -93,10 +98,29 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item)
return true;
}
- bool passed = (mFilterSubString.size() ? listener->getSearchableName().find(mFilterSubString) != std::string::npos : true);
+ std::string desc = listener->getSearchableCreatorName();
+ switch(mSearchType)
+ {
+ case SEARCHTYPE_CREATOR:
+ desc = listener->getSearchableCreatorName();
+ break;
+ case SEARCHTYPE_DESCRIPTION:
+ desc = listener->getSearchableDescription();
+ break;
+ case SEARCHTYPE_UUID:
+ desc = listener->getSearchableUUIDString();
+ break;
+ case SEARCHTYPE_NAME:
+ default:
+ desc = listener->getSearchableName();
+ break;
+ }
+
+ bool passed = (mFilterSubString.size() ? desc.find(mFilterSubString) != std::string::npos : true);
passed = passed && checkAgainstFilterType(listener);
passed = passed && checkAgainstPermissions(listener);
passed = passed && checkAgainstFilterLinks(listener);
+ passed = passed && checkAgainstCreator(listener);
return passed;
}
@@ -245,6 +269,14 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent
}
}
+ if(filterTypes & FILTERTYPE_WORN)
+ {
+ if (!get_is_item_worn(object_id))
+ {
+ return FALSE;
+ }
+ }
+
////////////////////////////////////////////////////////////////////////////////
// FILTERTYPE_UUID
// Pass if this item is the target UUID or if it links to the target UUID
@@ -453,6 +485,24 @@ bool LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewModelItemInven
return TRUE;
}
+bool LLInventoryFilter::checkAgainstCreator(const LLFolderViewModelItemInventory* listener) const
+{
+ if (!listener) return TRUE;
+ const BOOL is_folder = listener->getInventoryType() == LLInventoryType::IT_CATEGORY;
+ switch(mFilterCreatorType)
+ {
+ case FILTERCREATOR_SELF:
+ if(is_folder) return FALSE;
+ return (listener->getSearchableCreatorName() == mUsername);
+ case FILTERCREATOR_OTHERS:
+ if(is_folder) return FALSE;
+ return (listener->getSearchableCreatorName() != mUsername);
+ case FILTERCREATOR_ALL:
+ default:
+ return TRUE;
+ }
+}
+
const std::string& LLInventoryFilter::getFilterSubString(BOOL trim) const
{
return mFilterSubString;
@@ -460,7 +510,14 @@ const std::string& LLInventoryFilter::getFilterSubString(BOOL trim) const
std::string::size_type LLInventoryFilter::getStringMatchOffset(LLFolderViewModelItem* item) const
{
- return mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos;
+ if (mSearchType == SEARCHTYPE_NAME)
+ {
+ return mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos;
+ }
+ else
+ {
+ return std::string::npos;
+ }
}
bool LLInventoryFilter::isDefault() const
@@ -533,6 +590,24 @@ void LLInventoryFilter::updateFilterTypes(U64 types, U64& current_types)
}
}
+void LLInventoryFilter::setSearchType(ESearchType type)
+{
+ if(mSearchType != type)
+ {
+ mSearchType = type;
+ setModified();
+ }
+}
+
+void LLInventoryFilter::setFilterCreator(EFilterCreatorType type)
+{
+ if(mFilterCreatorType != type)
+ {
+ mFilterCreatorType = type;
+ setModified();
+ }
+}
+
void LLInventoryFilter::setFilterObjectTypes(U64 types)
{
updateFilterTypes(types, mFilterOps.mFilterObjectTypes);
@@ -556,6 +631,11 @@ void LLInventoryFilter::setFilterEmptySystemFolders()
mFilterOps.mFilterTypes |= FILTERTYPE_EMPTYFOLDERS;
}
+void LLInventoryFilter::setFilterWorn()
+{
+ mFilterOps.mFilterTypes |= FILTERTYPE_WORN;
+}
+
void LLInventoryFilter::setFilterMarketplaceActiveFolders()
{
mFilterOps.mFilterTypes |= FILTERTYPE_MARKETPLACE_ACTIVE;