summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2010-07-01 11:10:26 -0400
committerLoren Shih <seraph@lindenlab.com>2010-07-01 11:10:26 -0400
commit1cdf3146f284eb5a2c9effc6b44f060b5345f58b (patch)
treeb91633f913b5a5f8363edd8a2b4eb8b31b2466b7
parent5436253e53da366fd81c12bd03fdb5565615b850 (diff)
EXT-8191 FIXED Find All Links shouldn't include original item
EXT-7721 FIXED Find All Links shouldn't appear when it can't be used This required adding some minor infrastructure to support including/excluding links in search.
-rw-r--r--indra/newview/llinventoryfilter.cpp45
-rw-r--r--indra/newview/llinventoryfilter.h18
-rw-r--r--indra/newview/llinventorypanel.cpp4
-rw-r--r--indra/newview/llinventorypanel.h2
-rw-r--r--indra/newview/llpanelmaininventory.cpp7
5 files changed, 57 insertions, 19 deletions
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index 6e829f2dc2..f8241320cf 100644
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -57,7 +57,7 @@ LLInventoryFilter::FilterOps::FilterOps() :
mPermissions(PERM_NONE),
mFilterTypes(FILTERTYPE_OBJECT),
mFilterUUID(LLUUID::null),
- mIncludeLinks(TRUE)
+ mFilterLinks(FILTERLINK_INCLUDE_LINKS)
{
}
@@ -104,8 +104,10 @@ BOOL LLInventoryFilter::check(const LLFolderViewItem* item)
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_permissions &&
+ passed_filterlink &&
(mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos));
return passed;
@@ -229,6 +231,21 @@ BOOL LLInventoryFilter::checkAgainstPermissions(const LLFolderViewItem* item) co
return (perm & mFilterOps.mPermissions) == mFilterOps.mPermissions;
}
+BOOL LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewItem* item) const
+{
+ const LLFolderViewEventListener* listener = item->getListener();
+ if (!listener) return FALSE;
+
+ const LLUUID object_id = listener->getUUID();
+ const LLInventoryObject *object = gInventory.getObject(object_id);
+ 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
{
return mFilterSubString;
@@ -246,6 +263,7 @@ BOOL LLInventoryFilter::isNotDefault() const
|| 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
@@ -259,6 +277,7 @@ BOOL LLInventoryFilter::isActive() const
|| 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()
@@ -410,6 +429,11 @@ 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;
+ }
}
}
@@ -508,16 +532,17 @@ void LLInventoryFilter::setHoursAgo(U32 hours)
mFilterOps.mFilterTypes |= FILTERTYPE_DATE;
}
-void LLInventoryFilter::setIncludeLinks(BOOL include_links)
+void LLInventoryFilter::setFilterLinks(U64 filter_links)
{
- if (mFilterOps.mIncludeLinks != include_links)
+ if (mFilterOps.mFilterLinks != filter_links)
{
- if (!mFilterOps.mIncludeLinks)
- setModified(FILTER_LESS_RESTRICTIVE);
- else
+ if (mFilterOps.mFilterLinks == FILTERLINK_EXCLUDE_LINKS ||
+ mFilterOps.mFilterLinks == FILTERLINK_ONLY_LINKS)
setModified(FILTER_MORE_RESTRICTIVE);
+ else
+ setModified(FILTER_LESS_RESTRICTIVE);
}
- mFilterOps.mIncludeLinks = include_links;
+ mFilterOps.mFilterLinks = filter_links;
}
void LLInventoryFilter::setShowFolderState(EFolderShow state)
@@ -895,9 +920,9 @@ U32 LLInventoryFilter::getHoursAgo() const
{
return mFilterOps.mHoursAgo;
}
-BOOL LLInventoryFilter::getIncludeLinks() const
+U64 LLInventoryFilter::getFilterLinks() const
{
- return mFilterOps.mIncludeLinks;
+ return mFilterOps.mFilterLinks;
}
LLInventoryFilter::EFolderShow LLInventoryFilter::getShowFolderState() const
{
diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h
index f740a6b333..3d476e4795 100644
--- a/indra/newview/llinventoryfilter.h
+++ b/indra/newview/llinventoryfilter.h
@@ -56,8 +56,7 @@ public:
FILTER_MORE_RESTRICTIVE // if you didn't pass the previous filter, you definitely won't pass this one
};
- enum EFilterType
- {
+ enum EFilterType {
FILTERTYPE_NONE = 0,
FILTERTYPE_OBJECT = 0x1 << 0, // normal default search-by-object-type
FILTERTYPE_CATEGORY = 0x1 << 1, // search by folder type
@@ -66,6 +65,13 @@ public:
FILTERTYPE_WEARABLE = 0x1 << 4 // search by wearable type
};
+ enum EFilterLink
+ {
+ FILTERLINK_INCLUDE_LINKS, // show links too
+ FILTERLINK_EXCLUDE_LINKS, // don't show links
+ FILTERLINK_ONLY_LINKS // only show links
+ };
+
// REFACTOR: Change this to an enum.
static const U32 SO_DATE = 1;
static const U32 SO_FOLDERS_BY_NAME = 2;
@@ -100,8 +106,8 @@ public:
void setHoursAgo(U32 hours);
U32 getHoursAgo() const;
- void setIncludeLinks(BOOL include_links);
- BOOL getIncludeLinks() const;
+ void setFilterLinks(U64 filter_link);
+ U64 getFilterLinks() const;
// +-------------------------------------------------------------------+
// + Execution And Results
@@ -109,6 +115,8 @@ public:
BOOL check(const LLFolderViewItem* item);
BOOL checkAgainstFilterType(const LLFolderViewItem* item) const;
BOOL checkAgainstPermissions(const LLFolderViewItem* item) const;
+ BOOL checkAgainstFilterLinks(const LLFolderViewItem* item) const;
+
std::string::size_type getStringMatchOffset() const;
// +-------------------------------------------------------------------+
@@ -179,7 +187,7 @@ private:
U32 mHoursAgo;
EFolderShow mShowFolderState;
PermissionMask mPermissions;
- BOOL mIncludeLinks;
+ U64 mFilterLinks;
};
U32 mOrder;
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 72d35af3b7..5af99f3c8f 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -256,9 +256,9 @@ void LLInventoryPanel::setHoursAgo(U32 hours)
getFilter()->setHoursAgo(hours);
}
-void LLInventoryPanel::setIncludeLinks(BOOL include_links)
+void LLInventoryPanel::setFilterLinks(U64 filter_links)
{
- getFilter()->setIncludeLinks(include_links);
+ getFilter()->setFilterLinks(filter_links);
}
void LLInventoryPanel::setShowFolderState(LLInventoryFilter::EFolderShow show)
diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h
index 84603e8b4f..c9e317f816 100644
--- a/indra/newview/llinventorypanel.h
+++ b/indra/newview/llinventorypanel.h
@@ -145,7 +145,7 @@ public:
void setSinceLogoff(BOOL sl);
void setHoursAgo(U32 hours);
BOOL getSinceLogoff();
- void setIncludeLinks(BOOL include_links);
+ void setFilterLinks(U64 filter_links);
void setShowFolderState(LLInventoryFilter::EFolderShow show);
LLInventoryFilter::EFolderShow getShowFolderState();
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index 9eece81861..fa7e06d323 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -392,6 +392,7 @@ void LLPanelMainInventory::onClearSearch()
{
mActivePanel->setFilterSubString(LLStringUtil::null);
mActivePanel->setFilterTypes(0xffffffff);
+ mActivePanel->setFilterLinks(LLInventoryFilter::FILTERLINK_INCLUDE_LINKS);
}
if (finder)
@@ -1068,6 +1069,7 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata)
mFilterEditor->setFocus(TRUE);
filter->setFilterUUID(item_id);
filter->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
+ filter->setFilterLinks(LLInventoryFilter::FILTERLINK_ONLY_LINKS);
}
}
@@ -1134,7 +1136,10 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata)
if (command_name == "find_links")
{
- LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
+ LLFolderView* root = getActivePanel()->getRootFolder();
+ std::set<LLUUID> selection_set = root->getSelectionList();
+ if (selection_set.size() != 1) return FALSE;
+ LLFolderViewItem* current_item = root->getCurSelectedItem();
if (!current_item) return FALSE;
const LLUUID& item_id = current_item->getListener()->getUUID();
const LLInventoryObject *obj = gInventory.getObject(item_id);