diff options
Diffstat (limited to 'indra/newview/llinventoryfilter.cpp')
| -rw-r--r-- | indra/newview/llinventoryfilter.cpp | 171 |
1 files changed, 38 insertions, 133 deletions
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index ef4774a06d..1a488175ac 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -3,25 +3,31 @@ * @brief Support for filtering your inventory to only display a subset of the * available items. * -* $LicenseInfo:firstyear=2005&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2010, Linden Research, Inc. +* $LicenseInfo:firstyear=2005&license=viewergpl$ +* +* Copyright (c) 2005-2009, Linden Research, Inc. * -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. +* Second Life Viewer Source Code +* The source code in this file ("Source Code") is provided by Linden Lab +* to you under the terms of the GNU General Public License, version 2.0 +* ("GPL"), unless you have obtained a separate licensing agreement +* ("Other License"), formally executed by you and Linden Lab. Terms of +* the GPL can be found in doc/GPL-license.txt in this distribution, or +* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. +* There are special exceptions to the terms and conditions of the GPL as +* it is applied to this Source Code. View the full text of the exception +* in the file doc/FLOSS-exception.txt in this software distribution, or +* online at +* http://secondlifegrid.net/programs/open_source/licensing/flossexception * -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* By copying, modifying or distributing this software, you acknowledge +* that you have read and understood your obligations described above, +* and agree to abide by those obligations. * -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO +* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +* COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ #include "llviewerprecompiledheaders.h" @@ -35,7 +41,6 @@ #include "llinventorymodelbackgroundfetch.h" #include "llviewercontrol.h" #include "llfolderview.h" -#include "llinventorybridge.h" // linden library includes #include "lltrans.h" @@ -43,15 +48,13 @@ LLInventoryFilter::FilterOps::FilterOps() : mFilterObjectTypes(0xffffffffffffffffULL), mFilterCategoryTypes(0xffffffffffffffffULL), - mFilterWearableTypes(0xffffffffffffffffULL), mMinDate(time_min()), mMaxDate(time_max()), mHoursAgo(0), mShowFolderState(SHOW_NON_EMPTY_FOLDERS), mPermissions(PERM_NONE), mFilterTypes(FILTERTYPE_OBJECT), - mFilterUUID(LLUUID::null), - mFilterLinks(FILTERLINK_INCLUDE_LINKS) + mFilterUUID(LLUUID::null) { } @@ -94,25 +97,23 @@ BOOL LLInventoryFilter::check(const LLFolderViewItem* item) return TRUE; } + const LLFolderViewEventListener* listener = item->getListener(); 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)); + const BOOL passed = passed_filtertype && + (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos) && + ((listener->getPermissionMask() & mFilterOps.mPermissions) == mFilterOps.mPermissions); return passed; } -BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) const +BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) { const LLFolderViewEventListener* listener = item->getListener(); if (!listener) return FALSE; - LLInventoryType::EType object_type = listener->getInventoryType(); + const LLInventoryType::EType object_type = listener->getInventoryType(); const LLUUID object_id = listener->getUUID(); const LLInventoryObject *object = gInventory.getObject(object_id); @@ -127,15 +128,15 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con if (object_type == LLInventoryType::IT_NONE) { if (object && object->getIsLinkType()) - { return FALSE; - } } else if ((1LL << object_type & mFilterOps.mFilterObjectTypes) == U64(0)) { return FALSE; } } + // + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -159,6 +160,8 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con if ((1LL << cat->getPreferredType() & mFilterOps.mFilterCategoryTypes) == U64(0)) return FALSE; } + // + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -171,6 +174,8 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con if (object->getLinkedUUID() != mFilterOps.mFilterUUID) return FALSE; } + // + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -192,55 +197,12 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con listener->getCreationDate() > mFilterOps.mMaxDate) return FALSE; } - + // //////////////////////////////////////////////////////////////////////////////// - // FILTERTYPE_WEARABLE - // Pass if this item is a wearable of the appropriate type - if (filterTypes & FILTERTYPE_WEARABLE) - { - LLWearableType::EType type = listener->getWearableType(); - if ((0x1LL << type & mFilterOps.mFilterWearableTypes) == 0) - { - return FALSE; - } - } return TRUE; } -BOOL LLInventoryFilter::checkAgainstPermissions(const LLFolderViewItem* item) const -{ - const LLFolderViewEventListener* listener = item->getListener(); - if (!listener) return FALSE; - - PermissionMask perm = listener->getPermissionMask(); - const LLInvFVBridge *bridge = dynamic_cast<const LLInvFVBridge *>(item->getListener()); - if (bridge && bridge->isLink()) - { - const LLUUID& linked_uuid = gInventory.getLinkedItemID(bridge->getUUID()); - const LLViewerInventoryItem *linked_item = gInventory.getItem(linked_uuid); - if (linked_item) - perm = linked_item->getPermissionMask(); - } - return (perm & mFilterOps.mPermissions) == mFilterOps.mPermissions; -} - -BOOL LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewItem* item) const -{ - const LLFolderViewEventListener* listener = item->getListener(); - if (!listener) return TRUE; - - const LLUUID object_id = listener->getUUID(); - const LLInventoryObject *object = gInventory.getObject(object_id); - if (!object) return TRUE; - - const BOOL is_link = object->getIsLinkType(); - if (is_link && (mFilterOps.mFilterLinks == FILTERLINK_EXCLUDE_LINKS)) - return FALSE; - if (!is_link && (mFilterOps.mFilterLinks == FILTERLINK_ONLY_LINKS)) - return FALSE; - return TRUE; -} const std::string& LLInventoryFilter::getFilterSubString(BOOL trim) const { @@ -256,10 +218,7 @@ std::string::size_type LLInventoryFilter::getStringMatchOffset() const BOOL LLInventoryFilter::isNotDefault() const { return mFilterOps.mFilterObjectTypes != mDefaultFilterOps.mFilterObjectTypes - || mFilterOps.mFilterCategoryTypes != mDefaultFilterOps.mFilterCategoryTypes - || mFilterOps.mFilterWearableTypes != mDefaultFilterOps.mFilterWearableTypes || mFilterOps.mFilterTypes != FILTERTYPE_OBJECT - || mFilterOps.mFilterLinks != FILTERLINK_INCLUDE_LINKS || mFilterSubString.size() || mFilterOps.mPermissions != mDefaultFilterOps.mPermissions || mFilterOps.mMinDate != mDefaultFilterOps.mMinDate @@ -270,10 +229,7 @@ BOOL LLInventoryFilter::isNotDefault() const BOOL LLInventoryFilter::isActive() const { return mFilterOps.mFilterObjectTypes != 0xffffffffffffffffULL - || mFilterOps.mFilterCategoryTypes != 0xffffffffffffffffULL - || mFilterOps.mFilterWearableTypes != 0xffffffffffffffffULL || mFilterOps.mFilterTypes != FILTERTYPE_OBJECT - || mFilterOps.mFilterLinks != FILTERLINK_INCLUDE_LINKS || mFilterSubString.size() || mFilterOps.mPermissions != PERM_NONE || mFilterOps.mMinDate != time_min() @@ -346,35 +302,7 @@ void LLInventoryFilter::setFilterCategoryTypes(U64 types) setModified(FILTER_MORE_RESTRICTIVE); } } - mFilterOps.mFilterTypes |= FILTERTYPE_OBJECT; -} - -void LLInventoryFilter::setFilterWearableTypes(U64 types) -{ - if (mFilterOps.mFilterWearableTypes != types) - { - // keep current items only if no type bits getting turned off - BOOL fewer_bits_set = (mFilterOps.mFilterWearableTypes & ~types); - BOOL more_bits_set = (~mFilterOps.mFilterWearableTypes & types); - - mFilterOps.mFilterWearableTypes = types; - if (more_bits_set && fewer_bits_set) - { - // neither less or more restrive, both simultaneously - // so we need to filter from scratch - setModified(FILTER_RESTART); - } - else if (more_bits_set) - { - // target is only one of all requested types so more type bits == less restrictive - setModified(FILTER_LESS_RESTRICTIVE); - } - else if (fewer_bits_set) - { - setModified(FILTER_MORE_RESTRICTIVE); - } - } - mFilterOps.mFilterTypes |= FILTERTYPE_WEARABLE; + mFilterOps.mFilterTypes |= FILTERTYPE_CATEGORY; } void LLInventoryFilter::setFilterUUID(const LLUUID& object_id) @@ -401,10 +329,9 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) // appending new characters const BOOL more_restrictive = mFilterSubString.size() < string.size() && !string.substr(0, mFilterSubString.size()).compare(mFilterSubString); - mFilterSubStringOrig = string; - LLStringUtil::trimHead(mFilterSubStringOrig); - mFilterSubString = mFilterSubStringOrig; + mFilterSubString = string; LLStringUtil::toUpper(mFilterSubString); + LLStringUtil::trimHead(mFilterSubString); if (less_restrictive) { setModified(FILTER_LESS_RESTRICTIVE); @@ -425,11 +352,6 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) mFilterOps.mFilterUUID == LLUUID::null; setModified(FILTER_RESTART); } - - // Cancel out filter links once the search string is modified - { - mFilterOps.mFilterLinks = FILTERLINK_INCLUDE_LINKS; - } } } @@ -528,19 +450,6 @@ void LLInventoryFilter::setHoursAgo(U32 hours) mFilterOps.mFilterTypes |= FILTERTYPE_DATE; } -void LLInventoryFilter::setFilterLinks(U64 filter_links) -{ - if (mFilterOps.mFilterLinks != filter_links) - { - if (mFilterOps.mFilterLinks == FILTERLINK_EXCLUDE_LINKS || - mFilterOps.mFilterLinks == FILTERLINK_ONLY_LINKS) - setModified(FILTER_MORE_RESTRICTIVE); - else - setModified(FILTER_LESS_RESTRICTIVE); - } - mFilterOps.mFilterLinks = filter_links; -} - void LLInventoryFilter::setShowFolderState(EFolderShow state) { if (mFilterOps.mShowFolderState != state) @@ -916,10 +825,6 @@ U32 LLInventoryFilter::getHoursAgo() const { return mFilterOps.mHoursAgo; } -U64 LLInventoryFilter::getFilterLinks() const -{ - return mFilterOps.mFilterLinks; -} LLInventoryFilter::EFolderShow LLInventoryFilter::getShowFolderState() const { return mFilterOps.mShowFolderState; |
