Exemplo n.º 1
0
BOOL LLInventoryFilter::check(const LLFolderViewItem* item) 
{
	// Clipboard cut items are *always* filtered so we need this value upfront
	// <FS:Ansariel> FIRE-6714: Don't move objects to trash during cut&paste
	// Don't hide cut items in inventory
	//const LLFolderViewEventListener* listener = item->getListener();
	//const BOOL passed_clipboard = (listener ? checkAgainstClipboard(listener->getUUID()) : TRUE);
	const BOOL passed_clipboard = TRUE;
	// </FS:Ansariel> FIRE-6714: Don't move objects to trash during cut&paste

	// If it's a folder and we're showing all folders, return automatically.
	const BOOL is_folder = (dynamic_cast<const LLFolderViewFolder*>(item) != NULL);
	if (is_folder && (mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS))
	{
		return passed_clipboard;
	}
	
	//	Begin Multi-substring inventory search
	mSubStringMatchOffset = std::string::npos;
	if (mFilterSubStrings.size())
	{
		const std::string& searchLabel=getSearchableTarget(item);		// ## Zi: Extended Inventory Search

		U32 index = 0;
		for (std::vector<std::string>::iterator it=mFilterSubStrings.begin();
			it<mFilterSubStrings.end(); it++, index++)
		{
			std::string::size_type sub_string_offset = searchLabel.find(*it);

			mSubStringMatchOffsets[index] = sub_string_offset;

			if (sub_string_offset == std::string::npos)
			{
				mSubStringMatchOffset = std::string::npos;
				for (std::vector<std::string::size_type>::iterator it=mSubStringMatchOffsets.begin();
					it<mSubStringMatchOffsets.end(); it++)
				{
					*it = std::string::npos;
				}
				break;
			}
			else if (mSubStringMatchOffset == std::string::npos)
			{
				mSubStringMatchOffset = sub_string_offset;
			}
		}
	}
	//	End Multi-substring inventory search

	const BOOL passed_filtertype = checkAgainstFilterType(item);
	const BOOL passed_permissions = checkAgainstPermissions(item);
	const BOOL passed_filterlink = checkAgainstFilterLinks(item);
	const BOOL passed = (passed_filtertype &&
						 passed_permissions &&
						 passed_filterlink &&
						 passed_clipboard &&
						 (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos));

	return passed;
}
BOOL LLInventoryFilter::check(LLFolderViewItem* item) 
{
	// If it's a folder and we're showing all folders, return TRUE automatically.
	const BOOL is_folder = (dynamic_cast<const LLFolderViewFolder*>(item) != NULL);
	if (is_folder && (mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS))
	{
		return TRUE;
	}

	const LLFolderViewEventListener* listener = item->getListener();
	const LLUUID item_id = listener ? listener->getUUID() : LLUUID::null;

	mSubStringMatchOffset = mFilterSubString.size() ? item->getSearchableLabel().find(mFilterSubString) : std::string::npos;

	const BOOL passed_filtertype = checkAgainstFilterType(item);
	const BOOL passed_permissions = checkAgainstPermissions(item);
	const BOOL passed_filterlink = checkAgainstFilterLinks(item);
	const BOOL passed_wearable = !mFilterOps.mFilterWorn || (gAgentWearables.isWearingItem(item_id) || (gAgentAvatarp && gAgentAvatarp->isWearingAttachment(item_id)));
	const BOOL passed = (passed_filtertype &&
						 passed_permissions &&
						 passed_filterlink &&
						 passed_wearable &&
						 (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos));

	return passed;
}
BOOL LLInventoryFilter::check(const LLFolderViewItem* item) 
{
	// If it's a folder and we're showing all folders, return TRUE automatically.
	const BOOL is_folder = (dynamic_cast<const LLFolderViewFolder*>(item) != NULL);
	if (is_folder && (mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS))
	{
		return TRUE;
	}

	mSubStringMatchOffset = mFilterSubString.size() ? item->getSearchableLabel().find(mFilterSubString) : std::string::npos;

	const BOOL passed_filtertype = checkAgainstFilterType(item);
	const BOOL passed_permissions = checkAgainstPermissions(item);
	const BOOL passed_filterlink = checkAgainstFilterLinks(item);
	const BOOL passed = (passed_filtertype &&
						 passed_permissions &&
						 passed_filterlink &&
						 (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos));

	return passed;
}
bool LLInventoryFilter::check(const LLFolderViewModelItem* item) 
{
	const LLFolderViewModelItemInventory* listener = dynamic_cast<const LLFolderViewModelItemInventory*>(item);

	// Clipboard cut items are *always* filtered so we need this value upfront
	// <FS:Ansariel> FIRE-6714: Don't move objects to trash during cut&paste
	// Don't hide cut items in inventory
	//const BOOL passed_clipboard = (listener ? checkAgainstClipboard(listener->getUUID()) : TRUE);
	const BOOL passed_clipboard = TRUE;
	// </FS:Ansariel> FIRE-6714: Don't move objects to trash during cut&paste

	// If it's a folder and we're showing all folders, return automatically.
	const BOOL is_folder = listener->getInventoryType() == LLInventoryType::IT_CATEGORY;
	if (is_folder && (mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS))
	{
		return passed_clipboard;
	}
	
	// <FS:Zi> Multi-substring inventory search
	//bool passed = (mFilterSubString.size() ? listener->getSearchableName().find(mFilterSubString) != std::string::npos : true);
	std::string::size_type string_offset = std::string::npos;
	if (mFilterSubStrings.size())
	{
		std::string searchLabel;
		switch (mFilterSubStringTarget)
		{
			case SUBST_TARGET_NAME:
				searchLabel = listener->getSearchableName();
				break;
			case SUBST_TARGET_CREATOR:
				searchLabel = listener->getSearchableCreator();
				break;
			case SUBST_TARGET_DESCRIPTION:
				searchLabel = listener->getSearchableDescription();
				break;
			case SUBST_TARGET_UUID:
				searchLabel = listener->getSearchableUUID();
				break;
			case SUBST_TARGET_ALL:
				searchLabel = listener->getSearchableAll();
				break;
			default:
				LL_WARNS("LLInventoryFilter") << "Unknown search substring target: " << mFilterSubStringTarget << LL_ENDL;
				searchLabel = listener->getSearchableName();
				break;
		}

		U32 index = 0;
		for (std::vector<std::string>::iterator it = mFilterSubStrings.begin();
			it < mFilterSubStrings.end(); it++, index++)
		{
			std::string::size_type sub_string_offset = searchLabel.find(*it);

			mSubStringMatchOffsets[index] = sub_string_offset;

			if (sub_string_offset == std::string::npos)
			{
				string_offset = std::string::npos;
				for (std::vector<std::string::size_type>::iterator it = mSubStringMatchOffsets.begin();
					it < mSubStringMatchOffsets.end(); it++)
				{
					*it = std::string::npos;
				}
				break;
			}
			else if (string_offset == std::string::npos)
			{
				string_offset = sub_string_offset;
			}
		}
	}
	bool passed = (mFilterSubString.size() == 0 || string_offset != std::string::npos);
	// </FS:Zi> Multi-substring inventory search

	passed = passed && checkAgainstFilterType(listener);
	passed = passed && checkAgainstPermissions(listener);
	passed = passed && checkAgainstFilterLinks(listener);
	passed = passed && passed_clipboard;

	return passed;
}