Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows to limit search to folders only in inventory #71

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions indra/newview/llfolderviewmodelinventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class LLFolderViewModelItemInventory
virtual PermissionMask getPermissionMask() const = 0;
virtual LLFolderType::EType getPreferredType() const = 0;
virtual void showProperties(void) = 0;
virtual bool isItemNotAFolder( void) const { return false; } // TODO: make into pure virtual.
virtual bool isItemInTrash( void) const { return false; } // TODO: make into pure virtual.
virtual bool isItemInOutfits() const { return false; }
virtual bool isAgentInventory() const { return false; }
Expand Down
11 changes: 11 additions & 0 deletions indra/newview/llinventorybridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,17 @@ LLInventoryFilter* LLInvFVBridge::getInventoryFilter() const
return panel ? &(panel->getFilter()) : NULL;
}

bool LLInvFVBridge::isItemNotAFolder() const
{
LLInventoryModel* model = getInventoryModel();
if(!model) return false;

const LLViewerInventoryItem* item = model->getItem(mUUID);
if (!item) return false;

return LLAssetType::AT_CATEGORY != item->getType();
}

bool LLInvFVBridge::isItemInTrash() const
{
LLInventoryModel* model = getInventoryModel();
Expand Down
1 change: 1 addition & 0 deletions indra/newview/llinventorybridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class LLInvFVBridge : public LLFolderViewModelItemInventory
//virtual bool renameItem(const std::string& new_name) {}
virtual bool isItemRemovable(bool check_worn = true) const;
virtual bool isItemMovable() const;
virtual bool isItemNotAFolder() const;
virtual bool isItemInTrash() const;
virtual bool isItemInOutfits() const;
virtual bool isLink() const;
Expand Down
29 changes: 24 additions & 5 deletions indra/newview/llinventoryfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,17 +702,19 @@ bool LLInventoryFilter::checkAgainstSearchVisibility(const LLFolderViewModelItem
if (!object)
return true;

const bool is_link = object->getIsLinkType();
if (is_link && ((mFilterOps.mSearchVisibility & VISIBILITY_LINKS) == 0))
if (((mFilterOps.mSearchVisibility & VISIBILITY_LINKS) == 0) && object->getIsLinkType())
return false;

if (((mFilterOps.mSearchVisibility & VISIBILITY_ITEMS) == 0) && listener->isItemNotAFolder())
return false;

if (listener->isItemInOutfits() && ((mFilterOps.mSearchVisibility & VISIBILITY_OUTFITS) == 0))
if (((mFilterOps.mSearchVisibility & VISIBILITY_OUTFITS) == 0) && listener->isItemInOutfits())
return false;

if (listener->isItemInTrash() && ((mFilterOps.mSearchVisibility & VISIBILITY_TRASH) == 0))
if (((mFilterOps.mSearchVisibility & VISIBILITY_TRASH) == 0) && listener->isItemInTrash())
return false;

if (!listener->isAgentInventory() && ((mFilterOps.mSearchVisibility & VISIBILITY_LIBRARY) == 0))
if (((mFilterOps.mSearchVisibility & VISIBILITY_LIBRARY) == 0) && !listener->isAgentInventory())
return false;

return true;
Expand Down Expand Up @@ -932,6 +934,23 @@ void LLInventoryFilter::setFilterMarketplaceListingFolders(bool select_only_list
}
}

void LLInventoryFilter::toggleSearchVisibilityItems()
{
bool hide_items = mFilterOps.mSearchVisibility & VISIBILITY_ITEMS;
if (hide_items)
{
mFilterOps.mSearchVisibility &= ~VISIBILITY_ITEMS;
}
else
{
mFilterOps.mSearchVisibility |= VISIBILITY_ITEMS;
}

if (hasFilterString())
{
setModified(hide_items ? FILTER_MORE_RESTRICTIVE : FILTER_LESS_RESTRICTIVE);
}
}

void LLInventoryFilter::toggleSearchVisibilityLinks()
{
Expand Down
4 changes: 3 additions & 1 deletion indra/newview/llinventoryfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class LLInventoryFilter : public LLFolderViewFilter
VISIBILITY_TRASH = 0x1 << 0,
VISIBILITY_LIBRARY = 0x1 << 1,
VISIBILITY_LINKS = 0x1 << 2,
VISIBILITY_OUTFITS = 0x1 << 3
VISIBILITY_OUTFITS = 0x1 << 3,
VISIBILITY_ITEMS = 0x1 << 4
};

struct FilterOps
Expand Down Expand Up @@ -246,6 +247,7 @@ class LLInventoryFilter : public LLFolderViewFilter
ESearchType getSearchType() { return mSearchType; }
void setFilterCreator(EFilterCreatorType type);

void toggleSearchVisibilityItems();
void toggleSearchVisibilityLinks();
void toggleSearchVisibilityTrash();
void toggleSearchVisibilityOutfits();
Expand Down
10 changes: 10 additions & 0 deletions indra/newview/llpanelmaininventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2574,6 +2574,11 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata)
getCurrentFilter().toggleSearchVisibilityLinks();
}

if (command_name == "toggle_include_items")
{
getCurrentFilter().toggleSearchVisibilityItems();
}

if (command_name == "share")
{
if(mSingleFolderMode && isGalleryViewMode())
Expand Down Expand Up @@ -2800,6 +2805,11 @@ bool LLPanelMainInventory::isActionChecked(const LLSD& userdata)
return sort_order_mask & LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP;
}

if (command_name == "toggle_include_items")
{
return (getCurrentFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_ITEMS) != 0;
}

if (command_name == "toggle_search_outfits")
{
return (getCurrentFilter().getSearchVisibilityTypes() & LLInventoryFilter::VISIBILITY_OUTFITS) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,18 @@
<on_check
function="Inventory.GearDefault.Check"
parameter="include_links" />
</menu_item_check>
</menu_item_check>
<menu_item_separator
layout="topleft" />
<menu_item_check
label="Include Items"
layout="topleft"
name="include_items">
<on_click
function="Inventory.GearDefault.Custom.Action"
parameter="toggle_include_items" />
<on_check
function="Inventory.GearDefault.Check"
parameter="toggle_include_items" />
</menu_item_check>
</toggleable_menu>