From 0f2f846a12936991f0434d5aac50c850d76ce2a4 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Thu, 3 Dec 2009 20:50:21 -0500 Subject: EXT-3125 : INFRASTRUCTURE : Cleanup LLInventoryFilter to disambiguate various filter options EXT-3124 : Add lookup for finding all linked items to an item LLInventoryFilter cleanup, including adding ability to lookup item by UUID. --HG-- branch : avatar-pipeline --- indra/newview/llinventoryfilter.cpp | 225 +++++++++++++++++++++++++----------- 1 file changed, 157 insertions(+), 68 deletions(-) (limited to 'indra/newview/llinventoryfilter.cpp') diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 085c96c93d..3664d7d117 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -44,6 +44,18 @@ // linden library includes #include "lltrans.h" +LLInventoryFilter::FilterOps::FilterOps() : + mFilterObjectTypes(0xffffffffffffffffULL), + mMinDate(time_min()), + mMaxDate(time_max()), + mHoursAgo(0), + mShowFolderState(SHOW_NON_EMPTY_FOLDERS), + mPermissions(PERM_NONE), + mFilterType(FILTERTYPE_ITEM), + mFilterUUID(LLUUID::null) +{ +} + ///---------------------------------------------------------------------------- /// Class LLInventoryFilter ///---------------------------------------------------------------------------- @@ -52,14 +64,6 @@ LLInventoryFilter::LLInventoryFilter(const std::string& name) mModified(FALSE), mNeedTextRebuild(TRUE) { - mFilterOps.mFilterTypes = 0xffffffffffffffffULL; - mFilterOps.mMinDate = time_min(); - mFilterOps.mMaxDate = time_max(); - mFilterOps.mHoursAgo = 0; - mFilterOps.mShowFolderState = SHOW_NON_EMPTY_FOLDERS; - mFilterOps.mPermissions = PERM_NONE; - mFilterOps.mFilterForCategories = FALSE; - mOrder = SO_FOLDERS_BY_NAME; // This gets overridden by a pref immediately mSubStringMatchOffset = 0; @@ -81,11 +85,17 @@ LLInventoryFilter::~LLInventoryFilter() { } -BOOL LLInventoryFilter::check(LLFolderViewItem* item) +BOOL LLInventoryFilter::check(const LLFolderViewItem* item) { - time_t earliest; + // If it's a folder and we're showing all folders, return TRUE automatically. + const BOOL is_folder = (dynamic_cast(item) != NULL); + if (is_folder && (mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS)) + { + return TRUE; + } - earliest = time_corrected() - mFilterOps.mHoursAgo * 3600; + const U16 HOURS_TO_SECONDS = 3600; + time_t earliest = time_corrected() - mFilterOps.mHoursAgo * HOURS_TO_SECONDS; if (mFilterOps.mMinDate > time_min() && mFilterOps.mMinDate < earliest) { earliest = mFilterOps.mMinDate; @@ -94,59 +104,64 @@ BOOL LLInventoryFilter::check(LLFolderViewItem* item) { earliest = 0; } - LLFolderViewEventListener* listener = item->getListener(); + + const LLFolderViewEventListener* listener = item->getListener(); mSubStringMatchOffset = mFilterSubString.size() ? item->getSearchableLabel().find(mFilterSubString) : std::string::npos; - bool passed_type = false; - if (mFilterOps.mFilterForCategories) - { - // Pass if this item is a category of the filter type, or - // if its parent is a category of the filter type. - LLUUID uuid = listener->getUUID(); - if (listener->getInventoryType() != LLInventoryType::IT_CATEGORY) - { - const LLInventoryObject *obj = gInventory.getObject(uuid); - uuid = obj->getParentUUID(); - } - LLViewerInventoryCategory *cat = gInventory.getCategory(uuid); - if (cat) - { - passed_type |= ((1LL << cat->getPreferredType() & mFilterOps.mFilterTypes) != U64(0)); - } - } - else + const BOOL passed_filtertype = checkAgainstFilterType(item); + const BOOL passed = passed_filtertype && + (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos) && + ((listener->getPermissionMask() & mFilterOps.mPermissions) == mFilterOps.mPermissions) && + (listener->getCreationDate() >= earliest && listener->getCreationDate() <= mFilterOps.mMaxDate); + + return passed; +} + +BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) +{ + const LLFolderViewEventListener* listener = item->getListener(); + if (!listener) return FALSE; + + const LLInventoryType::EType object_type = listener->getInventoryType(); + const LLUUID object_id = listener->getUUID(); + const LLInventoryObject *object = gInventory.getObject(object_id); + + if (!object) return FALSE; + + switch (mFilterOps.mFilterType) { - LLInventoryType::EType type = listener->getInventoryType(); - passed_type |= ((1LL << type & mFilterOps.mFilterTypes) != U64(0)); - if (type == LLInventoryType::IT_NONE) + case FILTERTYPE_ITEM: { - const LLInventoryObject *obj = gInventory.getObject(listener->getUUID()); - if (obj && obj->getIsLinkType()) + // If it has no type, pass it, unless it's a link. + if (object_type == LLInventoryType::IT_NONE) { - passed_type = FALSE; + return !object->getIsLinkType(); } - else + return (1LL << object_type & mFilterOps.mFilterObjectTypes) != U64(0); + } + // Pass if this item is a category of the filter type, or + // if its parent is a category of the filter type. + case FILTERTYPE_CATEGORY: + { + LLUUID cat_id = object_id; + if (listener->getInventoryType() != LLInventoryType::IT_CATEGORY) { - passed_type = TRUE; + cat_id = object->getParentUUID(); } + const LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); + if (!cat) return FALSE; + return (1LL << cat->getPreferredType() & mFilterOps.mFilterObjectTypes) != U64(0); + } + case FILTERTYPE_UUID: + { + return (object->getLinkedUUID() == mFilterOps.mFilterUUID); } } - - BOOL passed = passed_type - && (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos) - && ((listener->getPermissionMask() & mFilterOps.mPermissions) == mFilterOps.mPermissions) - && (listener->getCreationDate() >= earliest && listener->getCreationDate() <= mFilterOps.mMaxDate); - - BOOL is_folder = (dynamic_cast(item) != NULL); - if (is_folder && mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS) - { - passed = TRUE; - } - - return passed; + return FALSE; } -const std::string LLInventoryFilter::getFilterSubString(BOOL trim) + +const std::string& LLInventoryFilter::getFilterSubString(BOOL trim) const { return mFilterSubString; } @@ -157,9 +172,9 @@ std::string::size_type LLInventoryFilter::getStringMatchOffset() const } // has user modified default filter params? -BOOL LLInventoryFilter::isNotDefault() +BOOL LLInventoryFilter::isNotDefault() const { - return mFilterOps.mFilterTypes != mDefaultFilterOps.mFilterTypes + return mFilterOps.mFilterObjectTypes != mDefaultFilterOps.mFilterObjectTypes || mFilterSubString.size() || mFilterOps.mPermissions != mDefaultFilterOps.mPermissions || mFilterOps.mMinDate != mDefaultFilterOps.mMinDate @@ -167,9 +182,9 @@ BOOL LLInventoryFilter::isNotDefault() || mFilterOps.mHoursAgo != mDefaultFilterOps.mHoursAgo; } -BOOL LLInventoryFilter::isActive() +BOOL LLInventoryFilter::isActive() const { - return mFilterOps.mFilterTypes != 0xffffffffffffffffULL + return mFilterOps.mFilterObjectTypes != 0xffffffffffffffffULL || mFilterSubString.size() || mFilterOps.mPermissions != PERM_NONE || mFilterOps.mMinDate != time_min() @@ -177,7 +192,7 @@ BOOL LLInventoryFilter::isActive() || mFilterOps.mHoursAgo != 0; } -BOOL LLInventoryFilter::isModified() +BOOL LLInventoryFilter::isModified() const { return mModified; } @@ -189,15 +204,15 @@ BOOL LLInventoryFilter::isModifiedAndClear() return ret; } -void LLInventoryFilter::setFilterTypes(U64 types, BOOL filter_for_categories) +void LLInventoryFilter::setFilterTypes(U64 types, EFilterType filter_type) { - if (mFilterOps.mFilterTypes != types) + if (mFilterOps.mFilterObjectTypes != types) { // keep current items only if no type bits getting turned off - BOOL fewer_bits_set = (mFilterOps.mFilterTypes & ~types); - BOOL more_bits_set = (~mFilterOps.mFilterTypes & types); + BOOL fewer_bits_set = (mFilterOps.mFilterObjectTypes & ~types); + BOOL more_bits_set = (~mFilterOps.mFilterObjectTypes & types); - mFilterOps.mFilterTypes = types; + mFilterOps.mFilterObjectTypes = types; if (more_bits_set && fewer_bits_set) { // neither less or more restrive, both simultaneously @@ -214,7 +229,7 @@ void LLInventoryFilter::setFilterTypes(U64 types, BOOL filter_for_categories) setModified(FILTER_MORE_RESTRICTIVE); } } - mFilterOps.mFilterForCategories = filter_for_categories; + mFilterOps.mFilterType = filter_type; } void LLInventoryFilter::setFilterSubString(const std::string& string) @@ -298,12 +313,18 @@ void LLInventoryFilter::setDateRangeLastLogoff(BOOL sl) } } -BOOL LLInventoryFilter::isSinceLogoff() +BOOL LLInventoryFilter::isSinceLogoff() const { return (mFilterOps.mMinDate == (time_t)mLastLogoff) && (mFilterOps.mMaxDate == time_max()); } +void LLInventoryFilter::clearModified() +{ + mModified = FALSE; + mFilterBehavior = FILTER_NONE; +} + void LLInventoryFilter::setHoursAgo(U32 hours) { if (mFilterOps.mHoursAgo != hours) @@ -417,12 +438,12 @@ void LLInventoryFilter::setModified(EFilterBehavior behavior) } } -BOOL LLInventoryFilter::isFilterWith(LLInventoryType::EType t) +BOOL LLInventoryFilter::isFilterWith(LLInventoryType::EType t) const { - return mFilterOps.mFilterTypes & (1LL << t); + return mFilterOps.mFilterObjectTypes & (1LL << t); } -std::string LLInventoryFilter::getFilterText() +const std::string& LLInventoryFilter::getFilterText() { if (!mNeedTextRebuild) { @@ -619,7 +640,7 @@ std::string LLInventoryFilter::getFilterText() return mFilterText; } -void LLInventoryFilter::toLLSD(LLSD& data) +void LLInventoryFilter::toLLSD(LLSD& data) const { data["filter_types"] = (LLSD::Integer)getFilterTypes(); data["min_date"] = (LLSD::Integer)getMinDate(); @@ -674,3 +695,71 @@ void LLInventoryFilter::fromLLSD(LLSD& data) setDateRangeLastLogoff((bool)data["since_logoff"].asBoolean()); } } + +U32 LLInventoryFilter::getFilterTypes() const +{ + return mFilterOps.mFilterObjectTypes; +} + +BOOL LLInventoryFilter::hasFilterString() const +{ + return mFilterSubString.size() > 0; +} + +PermissionMask LLInventoryFilter::getFilterPermissions() const +{ + return mFilterOps.mPermissions; +} + +time_t LLInventoryFilter::getMinDate() const +{ + return mFilterOps.mMinDate; +} + +time_t LLInventoryFilter::getMaxDate() const +{ + return mFilterOps.mMaxDate; +} +U32 LLInventoryFilter::getHoursAgo() const +{ + return mFilterOps.mHoursAgo; +} +LLInventoryFilter::EFolderShow LLInventoryFilter::getShowFolderState() const +{ + return mFilterOps.mShowFolderState; +} +U32 LLInventoryFilter::getSortOrder() const +{ + return mOrder; +} +const std::string& LLInventoryFilter::getName() const +{ + return mName; +} + +void LLInventoryFilter::setFilterCount(S32 count) +{ + mFilterCount = count; +} +S32 LLInventoryFilter::getFilterCount() const +{ + return mFilterCount; +} + +void LLInventoryFilter::decrementFilterCount() +{ + mFilterCount--; +} + +S32 LLInventoryFilter::getCurrentGeneration() const +{ + return mFilterGeneration; +} +S32 LLInventoryFilter::getMinRequiredGeneration() const +{ + return mMinRequiredGeneration; +} +S32 LLInventoryFilter::getMustPassGeneration() const +{ + return mMustPassGeneration; +} -- cgit v1.3 From 71cd24b4799f8bc0bed2665cca103c39fec3a965 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Thu, 3 Dec 2009 21:32:03 -0500 Subject: EXT-3124 : Add lookup for finding all linked items to an item Added ability to filter by UUID. Work in progress. --HG-- branch : avatar-pipeline --- indra/newview/llinventorybridge.cpp | 58 ++++++++++++---------- indra/newview/llinventorybridge.h | 2 - indra/newview/llinventoryfilter.cpp | 7 +++ indra/newview/llinventoryfilter.h | 2 + indra/newview/llinventorypanel.cpp | 22 ++++---- indra/newview/llpanelmaininventory.cpp | 23 +++++++++ .../default/xui/en/menu_inventory_gear_default.xml | 13 ++++- 7 files changed, 88 insertions(+), 39 deletions(-) (limited to 'indra/newview/llinventoryfilter.cpp') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 5bfad0695c..96e64051a2 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -512,37 +512,44 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, std::vector &disabled_items, U32 flags) { const LLInventoryObject *obj = getInventoryObject(); - if (obj && obj->getIsLinkType()) - { - items.push_back(std::string("Find Original")); - if (isLinkedObjectMissing()) - { - disabled_items.push_back(std::string("Find Original")); - } - } - else + if (obj) { - items.push_back(std::string("Rename")); - if (!isItemRenameable() || (flags & FIRST_SELECTED_ITEM) == 0) - { - disabled_items.push_back(std::string("Rename")); - } - - if (show_asset_id) + if (obj->getIsLinkType()) { - items.push_back(std::string("Copy Asset UUID")); - if ( (! ( isItemPermissive() || gAgent.isGodlike() ) ) - || (flags & FIRST_SELECTED_ITEM) == 0) + items.push_back(std::string("Find Original")); + if (isLinkedObjectMissing()) { - disabled_items.push_back(std::string("Copy Asset UUID")); + disabled_items.push_back(std::string("Find Original")); } } - items.push_back(std::string("Copy Separator")); - - items.push_back(std::string("Copy")); - if (!isItemCopyable()) + else { - disabled_items.push_back(std::string("Copy")); + if (LLAssetType::lookupCanLink(obj->getType())) + { + items.push_back(std::string("Find Links")); + } + items.push_back(std::string("Rename")); + if (!isItemRenameable() || (flags & FIRST_SELECTED_ITEM) == 0) + { + disabled_items.push_back(std::string("Rename")); + } + + if (show_asset_id) + { + items.push_back(std::string("Copy Asset UUID")); + if ( (! ( isItemPermissive() || gAgent.isGodlike() ) ) + || (flags & FIRST_SELECTED_ITEM) == 0) + { + disabled_items.push_back(std::string("Copy Asset UUID")); + } + } + items.push_back(std::string("Copy Separator")); + + items.push_back(std::string("Copy")); + if (!isItemCopyable()) + { + disabled_items.push_back(std::string("Copy")); + } } } @@ -931,6 +938,7 @@ void LLItemBridge::performAction(LLFolderView* folder, LLInventoryModel* model, { gotoItem(folder); } + if ("open" == action) { openItem(); diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 67dfc5b6f9..63be9dcdb8 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -154,7 +154,6 @@ public: virtual std::string getLabelSuffix() const { return LLStringUtil::null; } virtual void openItem() {} virtual void closeItem() {} - virtual void gotoItem(LLFolderView *folder) {} // for links virtual void previewItem() {openItem();} virtual void showProperties(); virtual BOOL isItemRenameable() const { return TRUE; } @@ -241,7 +240,6 @@ public: virtual void restoreItem(); virtual void restoreToWorld(); virtual void gotoItem(LLFolderView *folder); - virtual LLUIImagePtr getIcon() const; virtual const std::string& getDisplayName() const; virtual std::string getLabelSuffix() const; diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 3664d7d117..e5851bb624 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -232,6 +232,13 @@ void LLInventoryFilter::setFilterTypes(U64 types, EFilterType filter_type) mFilterOps.mFilterType = filter_type; } +void LLInventoryFilter::setFilterUUID(const LLUUID& object_id) +{ + mFilterOps.mFilterUUID = object_id; + mFilterOps.mFilterType = FILTERTYPE_UUID; + setModified(FILTER_RESTART); +} + void LLInventoryFilter::setFilterSubString(const std::string& string) { if (mFilterSubString != string) diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 20a4a15028..47407eb86c 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -86,6 +86,8 @@ public: U32 getFilterTypes() const; BOOL isFilterWith(LLInventoryType::EType t) const; + void setFilterUUID(const LLUUID &object_id); + void setFilterSubString(const std::string& string); const std::string& getFilterSubString(BOOL trim = FALSE) const; BOOL hasFilterString() const; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 53b78ad438..932c72f4cb 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -169,7 +169,7 @@ BOOL LLInventoryPanel::postBuild() { setSortOrder(gSavedSettings.getU32(DEFAULT_SORT_ORDER)); } - mFolders->setSortOrder(mFolders->getFilter()->getSortOrder()); + mFolders->setSortOrder(getFilter()->getSortOrder()); return TRUE; } @@ -209,23 +209,23 @@ LLInventoryFilter* LLInventoryPanel::getFilter() void LLInventoryPanel::setFilterTypes(U64 types, LLInventoryFilter::EFilterType filter_type) { - mFolders->getFilter()->setFilterTypes(types, filter_type); + getFilter()->setFilterTypes(types, filter_type); } void LLInventoryPanel::setFilterPermMask(PermissionMask filter_perm_mask) { - mFolders->getFilter()->setFilterPermissions(filter_perm_mask); + getFilter()->setFilterPermissions(filter_perm_mask); } void LLInventoryPanel::setFilterSubString(const std::string& string) { - mFolders->getFilter()->setFilterSubString(string); + getFilter()->setFilterSubString(string); } void LLInventoryPanel::setSortOrder(U32 order) { - mFolders->getFilter()->setSortOrder(order); - if (mFolders->getFilter()->isModified()) + getFilter()->setSortOrder(order); + if (getFilter()->isModified()) { mFolders->setSortOrder(order); // try to keep selection onscreen, even if it wasn't to start with @@ -235,22 +235,22 @@ void LLInventoryPanel::setSortOrder(U32 order) void LLInventoryPanel::setSinceLogoff(BOOL sl) { - mFolders->getFilter()->setDateRangeLastLogoff(sl); + getFilter()->setDateRangeLastLogoff(sl); } void LLInventoryPanel::setHoursAgo(U32 hours) { - mFolders->getFilter()->setHoursAgo(hours); + getFilter()->setHoursAgo(hours); } void LLInventoryPanel::setShowFolderState(LLInventoryFilter::EFolderShow show) { - mFolders->getFilter()->setShowFolderState(show); + getFilter()->setShowFolderState(show); } LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState() { - return mFolders->getFilter()->getShowFolderState(); + return getFilter()->getShowFolderState(); } void LLInventoryPanel::modelChanged(U32 mask) @@ -845,7 +845,7 @@ bool LLInventoryPanel::attachObject(const LLSD& userdata) BOOL LLInventoryPanel::getSinceLogoff() { - return mFolders->getFilter()->isSinceLogoff(); + return getFilter()->isSinceLogoff(); } // DEBUG ONLY diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 74c1420cf3..3fd83bd784 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -966,6 +966,17 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) preview_texture->openToSave(); } } + if (command_name == "find_links") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) + { + return; + } + + const LLUUID& item_id = current_item->getListener()->getUUID(); + mActivePanel->getFilter()->setFilterUUID(item_id); + } } BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) @@ -1001,6 +1012,18 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) } return FALSE; } + if (command_name == "find_links") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) return FALSE; + const LLUUID& item_id = current_item->getListener()->getUUID(); + LLInventoryObject *obj = gInventory.getObject(item_id); + if (obj && !obj->getIsLinkType() && LLAssetType::lookupCanLink(obj->getType())) + { + return TRUE; + } + return FALSE; + } return TRUE; } diff --git a/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml b/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml index 435a3e6d34..7a3e91d5a1 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml @@ -76,7 +76,7 @@ function="Inventory.GearDefault.Custom.Action" parameter="empty_lostnfound" /> - @@ -87,4 +87,15 @@ function="Inventory.GearDefault.Enable" parameter="save_texture" /> + + + + -- cgit v1.3 From 9b89325cc9a02c3305eb32148cc8de7dccf8808b Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Fri, 4 Dec 2009 11:42:17 -0500 Subject: EXT-3124 : Add lookup for finding all linked items to an item Filter now works correctly. Made some naming changes (e.g. setFilterType -> setFilterObjectType) so that what you choose to filter by is more explicit. --HG-- branch : avatar-pipeline --- indra/newview/llfolderview.cpp | 4 +- indra/newview/llfolderview.h | 2 +- indra/newview/llinventoryfilter.cpp | 147 ++++++++++++++++++++++----------- indra/newview/llinventoryfilter.h | 21 ++--- indra/newview/llinventorypanel.cpp | 7 +- indra/newview/llinventorypanel.h | 4 +- indra/newview/llpanelmaininventory.cpp | 10 ++- 7 files changed, 129 insertions(+), 66 deletions(-) (limited to 'indra/newview/llinventoryfilter.cpp') diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index ab49739d58..8bea8850b6 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -2217,9 +2217,9 @@ void LLFolderView::setFilterPermMask( PermissionMask filter_perm_mask ) mFilter->setFilterPermissions(filter_perm_mask); } -U32 LLFolderView::getFilterTypes() const +U32 LLFolderView::getFilterObjectTypes() const { - return mFilter->getFilterTypes(); + return mFilter->getFilterObjectTypes(); } PermissionMask LLFolderView::getFilterPermissions() const diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index bbd92b487f..8e9dd923a0 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -116,7 +116,7 @@ public: // filter is never null LLInventoryFilter* getFilter(); const std::string getFilterSubString(BOOL trim = FALSE); - U32 getFilterTypes() const; + U32 getFilterObjectTypes() const; PermissionMask getFilterPermissions() const; // JAMESDEBUG use getFilter()->getShowFolderState(); //LLInventoryFilter::EFolderShow getShowFolderState(); diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index e5851bb624..4c5e4d5607 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -46,12 +46,13 @@ LLInventoryFilter::FilterOps::FilterOps() : mFilterObjectTypes(0xffffffffffffffffULL), + mFilterCategoryTypes(0xffffffffffffffffULL), mMinDate(time_min()), mMaxDate(time_max()), mHoursAgo(0), mShowFolderState(SHOW_NON_EMPTY_FOLDERS), mPermissions(PERM_NONE), - mFilterType(FILTERTYPE_ITEM), + mFilterTypes(FILTERTYPE_OBJECT), mFilterUUID(LLUUID::null) { } @@ -128,36 +129,45 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) if (!object) return FALSE; - switch (mFilterOps.mFilterType) + const U32 filterTypes = mFilterOps.mFilterTypes; + + // Pass if this item's type is of the correct filter type + if (filterTypes & FILTERTYPE_OBJECT) { - case FILTERTYPE_ITEM: - { - // If it has no type, pass it, unless it's a link. - if (object_type == LLInventoryType::IT_NONE) - { - return !object->getIsLinkType(); - } - return (1LL << object_type & mFilterOps.mFilterObjectTypes) != U64(0); - } - // Pass if this item is a category of the filter type, or - // if its parent is a category of the filter type. - case FILTERTYPE_CATEGORY: + // If it has no type, pass it, unless it's a link. + if (object_type == LLInventoryType::IT_NONE) { - LLUUID cat_id = object_id; - if (listener->getInventoryType() != LLInventoryType::IT_CATEGORY) - { - cat_id = object->getParentUUID(); - } - const LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); - if (!cat) return FALSE; - return (1LL << cat->getPreferredType() & mFilterOps.mFilterObjectTypes) != U64(0); + if (object->getIsLinkType()) + return FALSE; } - case FILTERTYPE_UUID: + if ((1LL << object_type & mFilterOps.mFilterObjectTypes) == U64(0)) + return FALSE; + } + + // Pass if this item is a category of the filter type, or + // if its parent is a category of the filter type. + if (filterTypes & FILTERTYPE_CATEGORY) + { + LLUUID cat_id = object_id; + if (listener->getInventoryType() != LLInventoryType::IT_CATEGORY) { - return (object->getLinkedUUID() == mFilterOps.mFilterUUID); + cat_id = object->getParentUUID(); } + const LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); + if (!cat) + return FALSE; + if ((1LL << cat->getPreferredType() & mFilterOps.mFilterCategoryTypes) == U64(0)) + return FALSE; } - return FALSE; + + // Pass if this item is the target UUID or if it links to the target UUID + if (filterTypes & FILTERTYPE_UUID) + { + if (object->getLinkedUUID() != mFilterOps.mFilterUUID) + return FALSE; + } + + return TRUE; } @@ -204,7 +214,7 @@ BOOL LLInventoryFilter::isModifiedAndClear() return ret; } -void LLInventoryFilter::setFilterTypes(U64 types, EFilterType filter_type) +void LLInventoryFilter::setFilterObjectTypes(U64 types) { if (mFilterOps.mFilterObjectTypes != types) { @@ -229,14 +239,49 @@ void LLInventoryFilter::setFilterTypes(U64 types, EFilterType filter_type) setModified(FILTER_MORE_RESTRICTIVE); } } - mFilterOps.mFilterType = filter_type; + mFilterOps.mFilterTypes |= FILTERTYPE_OBJECT; +} + +void LLInventoryFilter::setFilterCategoryTypes(U64 types) +{ + if (mFilterOps.mFilterCategoryTypes != types) + { + // keep current items only if no type bits getting turned off + BOOL fewer_bits_set = (mFilterOps.mFilterCategoryTypes & ~types); + BOOL more_bits_set = (~mFilterOps.mFilterCategoryTypes & types); + + mFilterOps.mFilterCategoryTypes = 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_CATEGORY; } void LLInventoryFilter::setFilterUUID(const LLUUID& object_id) { + if (mFilterOps.mFilterUUID == LLUUID::null) + { + setModified(FILTER_MORE_RESTRICTIVE); + } + else + { + setModified(FILTER_RESTART); + } mFilterOps.mFilterUUID = object_id; - mFilterOps.mFilterType = FILTERTYPE_UUID; - setModified(FILTER_RESTART); + mFilterOps.mFilterTypes = FILTERTYPE_UUID; } void LLInventoryFilter::setFilterSubString(const std::string& string) @@ -244,9 +289,11 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) if (mFilterSubString != string) { // hitting BACKSPACE, for example - BOOL less_restrictive = mFilterSubString.size() >= string.size() && !mFilterSubString.substr(0, string.size()).compare(string); + const BOOL less_restrictive = mFilterSubString.size() >= string.size() && !mFilterSubString.substr(0, string.size()).compare(string); + // appending new characters - BOOL more_restrictive = mFilterSubString.size() < string.size() && !string.substr(0, mFilterSubString.size()).compare(mFilterSubString); + const BOOL more_restrictive = mFilterSubString.size() < string.size() && !string.substr(0, mFilterSubString.size()).compare(mFilterSubString); + mFilterSubString = string; LLStringUtil::toUpper(mFilterSubString); LLStringUtil::trimHead(mFilterSubString); @@ -263,6 +310,14 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) { setModified(FILTER_RESTART); } + + // Cancel out UUID once the search string is modified + if (mFilterOps.mFilterTypes == FILTERTYPE_UUID) + { + mFilterOps.mFilterTypes &= ~FILTERTYPE_UUID; + mFilterOps.mFilterUUID == LLUUID::null; + setModified(FILTER_RESTART); + } } } @@ -445,7 +500,7 @@ void LLInventoryFilter::setModified(EFilterBehavior behavior) } } -BOOL LLInventoryFilter::isFilterWith(LLInventoryType::EType t) const +BOOL LLInventoryFilter::isFilterObjectTypesWith(LLInventoryType::EType t) const { return mFilterOps.mFilterObjectTypes & (1LL << t); } @@ -465,7 +520,7 @@ const std::string& LLInventoryFilter::getFilterText() S32 num_filter_types = 0; mFilterText.clear(); - if (isFilterWith(LLInventoryType::IT_ANIMATION)) + if (isFilterObjectTypesWith(LLInventoryType::IT_ANIMATION)) { //filtered_types += " Animations,"; filtered_types += LLTrans::getString("Animations"); @@ -480,7 +535,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_CALLINGCARD)) + if (isFilterObjectTypesWith(LLInventoryType::IT_CALLINGCARD)) { //filtered_types += " Calling Cards,"; filtered_types += LLTrans::getString("Calling Cards"); @@ -494,7 +549,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_WEARABLE)) + if (isFilterObjectTypesWith(LLInventoryType::IT_WEARABLE)) { //filtered_types += " Clothing,"; filtered_types += LLTrans::getString("Clothing"); @@ -508,7 +563,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_GESTURE)) + if (isFilterObjectTypesWith(LLInventoryType::IT_GESTURE)) { //filtered_types += " Gestures,"; filtered_types += LLTrans::getString("Gestures"); @@ -522,7 +577,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_LANDMARK)) + if (isFilterObjectTypesWith(LLInventoryType::IT_LANDMARK)) { //filtered_types += " Landmarks,"; filtered_types += LLTrans::getString("Landmarks"); @@ -536,7 +591,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_NOTECARD)) + if (isFilterObjectTypesWith(LLInventoryType::IT_NOTECARD)) { //filtered_types += " Notecards,"; filtered_types += LLTrans::getString("Notecards"); @@ -550,7 +605,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_OBJECT) && isFilterWith(LLInventoryType::IT_ATTACHMENT)) + if (isFilterObjectTypesWith(LLInventoryType::IT_OBJECT) && isFilterObjectTypesWith(LLInventoryType::IT_ATTACHMENT)) { //filtered_types += " Objects,"; filtered_types += LLTrans::getString("Objects"); @@ -564,7 +619,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_LSL)) + if (isFilterObjectTypesWith(LLInventoryType::IT_LSL)) { //filtered_types += " Scripts,"; filtered_types += LLTrans::getString("Scripts"); @@ -578,7 +633,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_SOUND)) + if (isFilterObjectTypesWith(LLInventoryType::IT_SOUND)) { //filtered_types += " Sounds,"; filtered_types += LLTrans::getString("Sounds"); @@ -592,7 +647,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_TEXTURE)) + if (isFilterObjectTypesWith(LLInventoryType::IT_TEXTURE)) { //filtered_types += " Textures,"; filtered_types += LLTrans::getString("Textures"); @@ -606,7 +661,7 @@ const std::string& LLInventoryFilter::getFilterText() filtered_by_all_types = FALSE; } - if (isFilterWith(LLInventoryType::IT_SNAPSHOT)) + if (isFilterObjectTypesWith(LLInventoryType::IT_SNAPSHOT)) { //filtered_types += " Snapshots,"; filtered_types += LLTrans::getString("Snapshots"); @@ -649,7 +704,7 @@ const std::string& LLInventoryFilter::getFilterText() void LLInventoryFilter::toLLSD(LLSD& data) const { - data["filter_types"] = (LLSD::Integer)getFilterTypes(); + data["filter_types"] = (LLSD::Integer)getFilterObjectTypes(); data["min_date"] = (LLSD::Integer)getMinDate(); data["max_date"] = (LLSD::Integer)getMaxDate(); data["hours_ago"] = (LLSD::Integer)getHoursAgo(); @@ -664,7 +719,7 @@ void LLInventoryFilter::fromLLSD(LLSD& data) { if(data.has("filter_types")) { - setFilterTypes((U32)data["filter_types"].asInteger()); + setFilterObjectTypes((U32)data["filter_types"].asInteger()); } if(data.has("min_date") && data.has("max_date")) @@ -703,7 +758,7 @@ void LLInventoryFilter::fromLLSD(LLSD& data) } } -U32 LLInventoryFilter::getFilterTypes() const +U32 LLInventoryFilter::getFilterObjectTypes() const { return mFilterOps.mFilterObjectTypes; } diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 47407eb86c..d65fb8f27c 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -58,10 +58,10 @@ public: enum EFilterType { - FILTERTYPE_NONE, - FILTERTYPE_ITEM, // normal default search-by-item-type - FILTERTYPE_CATEGORY, // search by folder type - FILTERTYPE_UUID // find the object with UUID and any links to it + FILTERTYPE_NONE = 0, + FILTERTYPE_OBJECT = 1, // normal default search-by-object-type + FILTERTYPE_CATEGORY = 2, // search by folder type + FILTERTYPE_UUID = 4 // find the object with UUID and any links to it }; // REFACTOR: Change this to an enum. @@ -82,10 +82,10 @@ public: // +-------------------------------------------------------------------+ // + Parameters // +-------------------------------------------------------------------+ - void setFilterTypes(U64 types, EFilterType filter_type = FILTERTYPE_ITEM); - U32 getFilterTypes() const; - BOOL isFilterWith(LLInventoryType::EType t) const; - + void setFilterObjectTypes(U64 types); + U32 getFilterObjectTypes() const; + BOOL isFilterObjectTypesWith(LLInventoryType::EType t) const; + void setFilterCategoryTypes(U64 types); void setFilterUUID(const LLUUID &object_id); void setFilterSubString(const std::string& string); @@ -153,9 +153,10 @@ private: struct FilterOps { FilterOps(); - EFilterType mFilterType; + U32 mFilterTypes; - U64 mFilterObjectTypes; // For _ITEM or _CATEGORY + U64 mFilterObjectTypes; // For _ITEM + U64 mFilterCategoryTypes; // For _ITEM LLUUID mFilterUUID; // for UUID time_t mMinDate; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 932c72f4cb..54f528de8d 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -209,8 +209,11 @@ LLInventoryFilter* LLInventoryPanel::getFilter() void LLInventoryPanel::setFilterTypes(U64 types, LLInventoryFilter::EFilterType filter_type) { - getFilter()->setFilterTypes(types, filter_type); -} + if (filter_type == LLInventoryFilter::FILTERTYPE_OBJECT) + getFilter()->setFilterObjectTypes(types); + if (filter_type == LLInventoryFilter::FILTERTYPE_CATEGORY) + getFilter()->setFilterCategoryTypes(types); +} void LLInventoryPanel::setFilterPermMask(PermissionMask filter_perm_mask) { diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 56f7b39480..cbbd433c1d 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -126,8 +126,8 @@ public: void setSelectCallback(const LLFolderView::signal_t::slot_type& cb) { if (mFolders) mFolders->setSelectCallback(cb); } void clearSelection(); LLInventoryFilter* getFilter(); - void setFilterTypes(U64 filter, LLInventoryFilter::EFilterType = LLInventoryFilter::FILTERTYPE_ITEM); - U32 getFilterTypes() const { return mFolders->getFilterTypes(); } + void setFilterTypes(U64 filter, LLInventoryFilter::EFilterType = LLInventoryFilter::FILTERTYPE_OBJECT); + U32 getFilterObjectTypes() const { return mFolders->getFilterObjectTypes(); } void setFilterPermMask(PermissionMask filter_perm_mask); U32 getFilterPermMask() const { return mFolders->getFilterPermissions(); } void setFilterSubString(const std::string& string); diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 3fd83bd784..1f7e0c3a95 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -653,7 +653,7 @@ void LLFloaterInventoryFinder::updateElementsFromFilter() return; // Get data needed for filter display - U32 filter_types = mFilter->getFilterTypes(); + U32 filter_types = mFilter->getFilterObjectTypes(); std::string filter_string = mFilter->getFilterSubString(); LLInventoryFilter::EFolderShow show_folders = mFilter->getShowFolderState(); U32 hours = mFilter->getHoursAgo(); @@ -973,9 +973,13 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) { return; } - const LLUUID& item_id = current_item->getListener()->getUUID(); - mActivePanel->getFilter()->setFilterUUID(item_id); + const std::string &item_name = current_item->getListener()->getName(); + LLInventoryFilter *filter = mActivePanel->getFilter(); + filter->setFilterSubString(item_name); + mFilterEditor->setText(item_name); + filter->setFilterUUID(item_id); + filter->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); } } -- cgit v1.3