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.cpp94
1 files changed, 55 insertions, 39 deletions
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index e3d4645701..5c0905af3c 100644
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -103,7 +103,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item)
}
std::string desc = listener->getSearchableCreatorName();
- switch(mSearchType)
+ switch (mSearchType)
{
case SEARCHTYPE_CREATOR:
desc = listener->getSearchableCreatorName();
@@ -129,7 +129,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item)
boost::char_separator<char> sep(" ");
tokenizer tokens(desc, sep);
- for (auto token_iter : tokens)
+ for (const auto& token_iter : tokens)
{
if (token_iter == mExactToken)
{
@@ -138,9 +138,9 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item)
}
}
}
- else if ((mFilterTokens.size() > 0) && (mSearchType == SEARCHTYPE_NAME))
+ else if (!mFilterTokens.empty() && mSearchType == SEARCHTYPE_NAME)
{
- for (auto token_iter : mFilterTokens)
+ for (const auto& token_iter : mFilterTokens)
{
if (desc.find(token_iter) == std::string::npos)
{
@@ -150,7 +150,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item)
}
else
{
- passed = (mFilterSubString.size() ? desc.find(mFilterSubString) != std::string::npos : true);
+ passed = checkAgainstFilterSubString(desc);
}
passed = passed && checkAgainstFilterType(listener);
@@ -166,7 +166,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item)
bool LLInventoryFilter::check(const LLInventoryItem* item)
{
- const bool passed_string = (mFilterSubString.size() ? item->getName().find(mFilterSubString) != std::string::npos : true);
+ const bool passed_string = checkAgainstFilterSubString(item->getName());
const bool passed_filtertype = checkAgainstFilterType(item);
const bool passed_permissions = checkAgainstPermissions(item);
@@ -295,9 +295,19 @@ bool LLInventoryFilter::checkFolder(const LLUUID& folder_id) const
return true;
}
+bool LLInventoryFilter::checkAgainstFilterSubString(const std::string& desc) const
+{
+ if (mFilterSubString.empty())
+ return true;
+
+ size_t pos = desc.find(mFilterSubString);
+ return pos != std::string::npos;
+}
+
bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInventory* listener) const
{
- if (!listener) return false;
+ if (!listener)
+ return false;
LLInventoryType::EType object_type = listener->getInventoryType();
const LLUUID object_id = listener->getUUID();
@@ -338,7 +348,7 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent
}
}
- if(filterTypes & FILTERTYPE_WORN)
+ if (filterTypes & FILTERTYPE_WORN)
{
if (!get_is_item_worn(object_id))
{
@@ -351,7 +361,8 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent
// Pass if this item is the target UUID or if it links to the target UUID
if (filterTypes & FILTERTYPE_UUID)
{
- if (!object) return false;
+ if (!object)
+ return false;
if (object->getLinkedUUID() != mFilterOps.mFilterUUID)
return false;
@@ -363,7 +374,7 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent
if (filterTypes & FILTERTYPE_DATE)
{
const U16 HOURS_TO_SECONDS = 3600;
- time_t earliest = time_corrected() - mFilterOps.mHoursAgo * HOURS_TO_SECONDS;
+ time_t earliest = time_corrected() - (U64)mFilterOps.mHoursAgo * HOURS_TO_SECONDS;
if (mFilterOps.mMinDate > time_min() && mFilterOps.mMinDate < earliest)
{
@@ -494,7 +505,8 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLInventoryItem* item) cons
// Pass if this item is the target UUID or if it links to the target UUID
if (filterTypes & FILTERTYPE_UUID)
{
- if (!item) return false;
+ if (!item)
+ return false;
if (item->getLinkedUUID() != mFilterOps.mFilterUUID)
return false;
@@ -540,7 +552,8 @@ bool LLInventoryFilter::checkAgainstClipboard(const LLUUID& object_id) const
bool LLInventoryFilter::checkAgainstPermissions(const LLFolderViewModelItemInventory* listener) const
{
- if (!listener) return false;
+ if (!listener)
+ return false;
PermissionMask perm = listener->getPermissionMask();
const LLInvFVBridge *bridge = dynamic_cast<const LLInvFVBridge *>(listener);
@@ -556,7 +569,8 @@ bool LLInventoryFilter::checkAgainstPermissions(const LLFolderViewModelItemInven
bool LLInventoryFilter::checkAgainstPermissions(const LLInventoryItem* item) const
{
- if (!item) return false;
+ if (!item)
+ return false;
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
PermissionMask perm = new_item->getPermissionMask();
@@ -567,11 +581,13 @@ bool LLInventoryFilter::checkAgainstPermissions(const LLInventoryItem* item) con
bool LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewModelItemInventory* listener) const
{
- if (!listener) return true;
+ if (!listener)
+ return true;
const LLUUID object_id = listener->getUUID();
const LLInventoryObject *object = gInventory.getObject(object_id);
- if (!object) return true;
+ if (!object)
+ return true;
const bool is_link = object->getIsLinkType();
if (is_link && (mFilterOps.mFilterLinks == FILTERLINK_EXCLUDE_LINKS))
@@ -584,7 +600,8 @@ bool LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewModelItemInven
bool LLInventoryFilter::checkAgainstFilterThumbnails(const LLUUID& object_id) const
{
const LLInventoryObject *object = gInventory.getObject(object_id);
- if (!object) return true;
+ if (!object)
+ return true;
const bool is_thumbnail = object->getThumbnailUUID().notNull();
if (is_thumbnail && (mFilterOps.mFilterThumbnails == FILTER_EXCLUDE_THUMBNAILS))
@@ -596,16 +613,20 @@ bool LLInventoryFilter::checkAgainstFilterThumbnails(const LLUUID& object_id) co
bool LLInventoryFilter::checkAgainstCreator(const LLFolderViewModelItemInventory* listener) const
{
- if (!listener) return true;
+ if (!listener)
+ return true;
+
const bool is_folder = listener->getInventoryType() == LLInventoryType::IT_CATEGORY;
switch (mFilterOps.mFilterCreatorType)
{
case FILTERCREATOR_SELF:
- if(is_folder) return false;
- return (listener->getSearchableCreatorName() == mUsername);
+ if (is_folder)
+ return false;
+ return listener->getSearchableCreatorName() == mUsername;
case FILTERCREATOR_OTHERS:
- if(is_folder) return false;
- return (listener->getSearchableCreatorName() != mUsername);
+ if (is_folder)
+ return false;
+ return listener->getSearchableCreatorName() != mUsername;
case FILTERCREATOR_ALL:
default:
return true;
@@ -618,7 +639,8 @@ bool LLInventoryFilter::checkAgainstSearchVisibility(const LLFolderViewModelItem
const LLUUID object_id = listener->getUUID();
const LLInventoryObject *object = gInventory.getObject(object_id);
- if (!object) return true;
+ if (!object)
+ return true;
const bool is_link = object->getIsLinkType();
if (is_link && ((mFilterOps.mSearchVisibility & VISIBILITY_LINKS) == 0))
@@ -647,10 +669,8 @@ std::string::size_type LLInventoryFilter::getStringMatchOffset(LLFolderViewModel
{
return mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos;
}
- else
- {
- return std::string::npos;
- }
+
+ return std::string::npos;
}
bool LLInventoryFilter::isDefault() const
@@ -725,7 +745,7 @@ void LLInventoryFilter::updateFilterTypes(U64 types, U64& current_types)
void LLInventoryFilter::setSearchType(ESearchType type)
{
- if(mSearchType != type)
+ if (mSearchType != type)
{
mSearchType = type;
setModified();
@@ -918,6 +938,7 @@ void LLInventoryFilter::setFilterUUID(const LLUUID& object_id)
{
setModified(FILTER_RESTART);
}
+
mFilterOps.mFilterUUID = object_id;
mFilterOps.mFilterTypes = FILTERTYPE_UUID;
}
@@ -931,7 +952,6 @@ void LLInventoryFilter::setFilterSubString(const std::string& string)
if (mFilterSubString != filter_sub_string_new)
{
-
mFilterTokens.clear();
if (filter_sub_string_new.find_first_of("+") != std::string::npos)
{
@@ -1243,7 +1263,7 @@ void LLInventoryFilter::setFindAllLinksMode(const std::string &search_name, cons
{
// Save a copy of settings so that we will be able to restore it later
// but make sure we are not searching for links already
- if(mFilterOps.mFilterLinks != FILTERLINK_ONLY_LINKS)
+ if (mFilterOps.mFilterLinks != FILTERLINK_ONLY_LINKS)
{
mBackupFilterOps = mFilterOps;
}
@@ -1283,7 +1303,7 @@ void LLInventoryFilter::setModified(EFilterModified behavior)
}
// if not keeping current filter results, update last valid as well
- switch(mFilterModified)
+ switch (mFilterModified)
{
case FILTER_RESTART:
mFirstRequiredGeneration = mCurrentGeneration;
@@ -1499,11 +1519,11 @@ const std::string& LLInventoryFilter::getFilterText()
{
mFilterText += LLTrans::getString("Since Logoff");
}
+
return mFilterText;
}
-
-LLInventoryFilter& LLInventoryFilter::operator=( const LLInventoryFilter& other )
+LLInventoryFilter& LLInventoryFilter::operator =(const LLInventoryFilter& other)
{
setFilterObjectTypes(other.getFilterObjectTypes());
setDateRange(other.getMinDate(), other.getMaxDate());
@@ -1516,7 +1536,6 @@ LLInventoryFilter& LLInventoryFilter::operator=( const LLInventoryFilter& othe
return *this;
}
-
void LLInventoryFilter::toParams(Params& params) const
{
params.filter_ops.types = (U32)getFilterObjectTypes();
@@ -1686,14 +1705,13 @@ std::string LLInventoryFilter::getEmptyLookupMessage(bool is_empty_folder) const
return LLTrans::getString(mEmptyLookupMessage, args);
}
-
}
bool LLInventoryFilter::areDateLimitsSet()
{
- return mFilterOps.mMinDate != time_min()
- || mFilterOps.mMaxDate != time_max()
- || mFilterOps.mHoursAgo != 0;
+ return mFilterOps.mMinDate != time_min()
+ || mFilterOps.mMaxDate != time_max()
+ || mFilterOps.mHoursAgo != 0;
}
bool LLInventoryFilter::showAllResults() const
@@ -1701,8 +1719,6 @@ bool LLInventoryFilter::showAllResults() const
return hasFilterString() && !mSingleFolderMode;
}
-
-
bool LLInventoryFilter::FilterOps::DateRange::validateBlock( bool emit_errors /*= true*/ ) const
{
bool valid = LLInitParam::Block<DateRange>::validateBlock(emit_errors);