diff options
| -rw-r--r-- | indra/newview/llinventoryfilter.cpp | 74 | ||||
| -rw-r--r-- | indra/newview/llinventoryfilter.h | 3 | 
2 files changed, 74 insertions, 3 deletions
| diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 16385928b4..e8bc915f22 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -42,7 +42,7 @@  #include "llviewerfoldertype.h"  #include "llradiogroup.h"  #include "llstartup.h" - +#include <boost/regex.hpp>  // linden library includes  #include "llclipboard.h"  #include "lltrans.h" @@ -116,7 +116,39 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item)  			break;  	} -	bool passed = (mFilterSubString.size() ? desc.find(mFilterSubString) != std::string::npos : true); + +	bool passed = true; +	if (!mExactToken.empty() && (mSearchType == SEARCHTYPE_NAME)) +	{ +		passed = false; +		typedef boost::tokenizer<boost::char_separator<char> > tokenizer; +		boost::char_separator<char> sep(" "); +		tokenizer tokens(desc, sep); + +		for (auto token_iter : tokens) +		{ +			if (token_iter == mExactToken) +			{ +				passed = true; +				break; +			} +		}	 +	} +	else if ((mFilterTokens.size() > 0) && (mSearchType == SEARCHTYPE_NAME)) +	{ +		for (auto token_iter : mFilterTokens) +		{ +			if (desc.find(token_iter) == std::string::npos) +			{ +				return false; +			} +		} +	} +	else +	{ +		passed = (mFilterSubString.size() ? desc.find(mFilterSubString) != std::string::npos : true); +	} +  	passed = passed && checkAgainstFilterType(listener);  	passed = passed && checkAgainstPermissions(listener);  	passed = passed && checkAgainstFilterLinks(listener); @@ -693,6 +725,38 @@ 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) +		{ +			typedef boost::tokenizer<boost::char_separator<char> > tokenizer; +			boost::char_separator<char> sep("+"); +			tokenizer tokens(filter_sub_string_new, sep); + +			for (auto token_iter : tokens) +			{ +				mFilterTokens.push_back(token_iter); +			} +		} + +		std::string old_token = mExactToken; +		mExactToken.clear(); +		bool exact_token_changed = false; +		if (mFilterTokens.empty() && filter_sub_string_new.size() > 2) +		{ +			boost::regex mPattern = boost::regex("\"\\s*([^<]*)?\\s*\"", +				boost::regex::perl | boost::regex::icase); +			boost::match_results<std::string::const_iterator> matches; +			mExactToken = (boost::regex_match(filter_sub_string_new, matches, mPattern) && matches[1].matched) +				? matches[1] +				: LLStringUtil::null; +			if ((old_token.empty() && !mExactToken.empty())  +				|| (!old_token.empty() && mExactToken.empty())) +			{ +				exact_token_changed = true; +			} +		} +  		// hitting BACKSPACE, for example  		const BOOL less_restrictive = mFilterSubString.size() >= filter_sub_string_new.size()  			&& !mFilterSubString.substr(0, filter_sub_string_new.size()).compare(filter_sub_string_new); @@ -702,7 +766,11 @@ void LLInventoryFilter::setFilterSubString(const std::string& string)  			&& !filter_sub_string_new.substr(0, mFilterSubString.size()).compare(mFilterSubString);  		mFilterSubString = filter_sub_string_new; -		if (less_restrictive) +		if (exact_token_changed) +		{ +			setModified(FILTER_RESTART); +		} +		else if (less_restrictive)  		{  			setModified(FILTER_LESS_RESTRICTIVE);  		} diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 4a1fec8454..3f24211f41 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -327,6 +327,9 @@ private:  	std::string 			mEmptyLookupMessage;  	ESearchType 			mSearchType; + +	std::vector<std::string> mFilterTokens; +	std::string				 mExactToken;  };  #endif | 
