FIRE-3690, inventory filter accepts multiple terms with '+', by Dawa Gurbux
parent
8092fcf434
commit
3eb16193b4
|
|
@ -472,6 +472,17 @@ void LLFolderViewItem::filter( LLInventoryFilter& filter)
|
|||
|
||||
setFiltered(passed_filter, filter.getCurrentGeneration());
|
||||
mStringMatchOffset = filter.getStringMatchOffset();
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
mStringMatchOffsets.clear();
|
||||
mStringMatchSizes.clear();
|
||||
for (U32 index = 0, max = filter.getFilterSubStringCount(); index < max; index++)
|
||||
{
|
||||
mStringMatchOffsets.push_back(filter.getFilterSubStringPos(index));
|
||||
mStringMatchSizes.push_back(filter.getFilterSubStringLen(index));
|
||||
}
|
||||
// End Multi-substring inventory search
|
||||
|
||||
filter.decrementFilterCount();
|
||||
|
||||
if (getRoot()->getDebugFilters())
|
||||
|
|
@ -1116,28 +1127,43 @@ void LLFolderViewItem::draw()
|
|||
//--------------------------------------------------------------------------------//
|
||||
// Highlight string match
|
||||
//
|
||||
if (mStringMatchOffset != std::string::npos)
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
if (mStringMatchOffsets.size())
|
||||
{
|
||||
// don't draw backgrounds for zero-length strings
|
||||
S32 filter_string_length = getRoot()->getFilterSubString().size();
|
||||
if (filter_string_length > 0)
|
||||
{
|
||||
std::string combined_string = mLabel + mLabelSuffix;
|
||||
S32 left = llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1;
|
||||
S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2;
|
||||
S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD);
|
||||
S32 top = getRect().getHeight() - TOP_PAD;
|
||||
//std::vector<std::string::size_type> mStringMatchOffsets;
|
||||
//std::vector<std::string::size_type> mStringMatchSizes;
|
||||
std::vector<std::string::size_type>::iterator offset_iter = mStringMatchOffsets.begin();
|
||||
std::vector<std::string::size_type>::iterator size_iter = mStringMatchSizes.begin();
|
||||
|
||||
LLUIImage* box_image = default_params.selection_image;
|
||||
LLRect box_rect(left, top, right, bottom);
|
||||
box_image->draw(box_rect, sFilterBGColor);
|
||||
F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mStringMatchOffset);
|
||||
F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD;
|
||||
font->renderUTF8( combined_string, mStringMatchOffset, match_string_left, yy,
|
||||
sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
|
||||
filter_string_length, S32_MAX, &right_x, FALSE );
|
||||
LLUIImage* box_image = default_params.selection_image;
|
||||
|
||||
while (offset_iter < mStringMatchOffsets.end() && size_iter < mStringMatchSizes.end())
|
||||
{
|
||||
// don't draw backgrounds for zero-length strings
|
||||
S32 filter_string_length = *size_iter;
|
||||
S32 filter_string_offset = *offset_iter;
|
||||
if (filter_string_length > 0 && filter_string_offset != std::string::npos)
|
||||
{
|
||||
std::string combined_string = mLabel + mLabelSuffix;
|
||||
S32 left = llround(text_left) + font->getWidth(combined_string, 0, filter_string_offset) - 1;
|
||||
S32 right = left + font->getWidth(combined_string, filter_string_offset, filter_string_length) + 2;
|
||||
S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD);
|
||||
S32 top = getRect().getHeight() - TOP_PAD;
|
||||
|
||||
LLRect box_rect(left, top, right, bottom);
|
||||
box_image->draw(box_rect, sFilterBGColor);
|
||||
F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, filter_string_offset);
|
||||
F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD;
|
||||
font->renderUTF8( combined_string, filter_string_offset, match_string_left, yy,
|
||||
sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
|
||||
filter_string_length, S32_MAX, &right_x, FALSE );
|
||||
}
|
||||
offset_iter++;
|
||||
size_iter++;
|
||||
}
|
||||
}
|
||||
// End Multi-substring inventory search
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,12 @@ protected:
|
|||
BOOL mPassedFilter;
|
||||
S32 mLastFilterGeneration;
|
||||
std::string::size_type mStringMatchOffset;
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
std::vector<std::string::size_type> mStringMatchOffsets;
|
||||
std::vector<std::string::size_type> mStringMatchSizes;
|
||||
// End Multi-substring inventory search
|
||||
|
||||
F32 mControlLabelRotation;
|
||||
LLFolderView* mRoot;
|
||||
BOOL mDragAndDropTarget;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,12 @@ LLInventoryFilter::LLInventoryFilter(const std::string& name)
|
|||
|
||||
mSubStringMatchOffset = 0;
|
||||
mFilterSubString.clear();
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
mSubStringMatchOffsets.clear();
|
||||
mFilterSubStrings.clear();
|
||||
// End Multi-substring inventory search
|
||||
|
||||
mFilterGeneration = 0;
|
||||
mMustPassGeneration = S32_MAX;
|
||||
mMinRequiredGeneration = 0;
|
||||
|
|
@ -95,8 +101,38 @@ BOOL LLInventoryFilter::check(const LLFolderViewItem* item)
|
|||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
mSubStringMatchOffset = std::string::npos;
|
||||
if (mFilterSubStrings.size())
|
||||
{
|
||||
const std::string& searchLabel = item->getSearchableLabel();
|
||||
|
||||
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);
|
||||
|
||||
mSubStringMatchOffset = mFilterSubString.size() ? item->getSearchableLabel().find(mFilterSubString) : std::string::npos;
|
||||
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);
|
||||
|
|
@ -377,14 +413,34 @@ void LLInventoryFilter::setFilterSubString(const std::string& string)
|
|||
mFilterSubStringOrig = string;
|
||||
LLStringUtil::trimHead(filter_sub_string_new);
|
||||
LLStringUtil::toUpper(filter_sub_string_new);
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
// Cut filter string into several substrings, separated by +
|
||||
{
|
||||
mFilterSubStrings.clear();
|
||||
mSubStringMatchOffsets.clear();
|
||||
std::string::size_type frm = 0;
|
||||
std::string::size_type to;
|
||||
do
|
||||
{
|
||||
to = filter_sub_string_new.find_first_of('+',frm);
|
||||
|
||||
std::string subSubString = (to == std::string::npos) ? filter_sub_string_new.substr(frm, to) : filter_sub_string_new.substr(frm, to-frm);
|
||||
|
||||
if (subSubString.size())
|
||||
{
|
||||
mFilterSubStrings.push_back(subSubString);
|
||||
mSubStringMatchOffsets.push_back(std::string::npos);
|
||||
}
|
||||
|
||||
frm = to+1;
|
||||
}
|
||||
while (to != std::string::npos);
|
||||
}
|
||||
|
||||
|
||||
if (mFilterSubString != filter_sub_string_new)
|
||||
{
|
||||
std::string filterSubStringNew = string;
|
||||
LLStringUtil::trimHead(filterSubStringNew);
|
||||
mFilterSubStringOrig = filterSubStringNew;
|
||||
LLStringUtil::toUpper(filterSubStringNew);
|
||||
|
||||
// hitting BACKSPACE, for example
|
||||
const BOOL less_restrictive = mFilterSubString.size() >= filter_sub_string_new.size()
|
||||
&& !mFilterSubString.substr(0, filter_sub_string_new.size()).compare(filter_sub_string_new);
|
||||
|
|
@ -394,6 +450,7 @@ void LLInventoryFilter::setFilterSubString(const std::string& string)
|
|||
&& !filter_sub_string_new.substr(0, mFilterSubString.size()).compare(mFilterSubString);
|
||||
|
||||
mFilterSubString = filter_sub_string_new;
|
||||
|
||||
if (less_restrictive)
|
||||
{
|
||||
setModified(FILTER_LESS_RESTRICTIVE);
|
||||
|
|
@ -420,6 +477,7 @@ void LLInventoryFilter::setFilterSubString(const std::string& string)
|
|||
mFilterOps.mFilterLinks = FILTERLINK_INCLUDE_LINKS;
|
||||
}
|
||||
}
|
||||
// End Multi-substring inventory search
|
||||
}
|
||||
|
||||
void LLInventoryFilter::setFilterPermissions(PermissionMask perms)
|
||||
|
|
@ -978,3 +1036,25 @@ const std::string& LLInventoryFilter::getEmptyLookupMessage() const
|
|||
return mEmptyLookupMessage;
|
||||
|
||||
}
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
|
||||
// For use by LLFolderViewItem for highlighting
|
||||
|
||||
U32 LLInventoryFilter::getFilterSubStringCount() const
|
||||
{
|
||||
return mFilterSubStrings.size();
|
||||
}
|
||||
|
||||
std::string::size_type LLInventoryFilter::getFilterSubStringPos(U32 index) const
|
||||
{
|
||||
if (index < 0 || index >= mSubStringMatchOffsets.size()) return std::string::npos;
|
||||
return mSubStringMatchOffsets[index];
|
||||
}
|
||||
|
||||
std::string::size_type LLInventoryFilter::getFilterSubStringLen(U32 index) const
|
||||
{
|
||||
if (index < 0 || index >= mFilterSubStrings.size()) return 0;
|
||||
return mFilterSubStrings[index].size();
|
||||
}
|
||||
// End Multi-substring inventory search
|
||||
|
|
@ -30,6 +30,10 @@
|
|||
#include "llinventorytype.h"
|
||||
#include "llpermissionsflags.h"
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
#include <vector>
|
||||
// End Multi-substring inventory search
|
||||
|
||||
class LLFolderViewItem;
|
||||
class LLFolderViewFolder;
|
||||
|
||||
|
|
@ -95,6 +99,13 @@ public:
|
|||
const std::string& getFilterSubString(BOOL trim = FALSE) const;
|
||||
const std::string& getFilterSubStringOrig() const { return mFilterSubStringOrig; }
|
||||
BOOL hasFilterString() const;
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
// For use by LLFolderViewItem for highlighting
|
||||
U32 getFilterSubStringCount() const;
|
||||
std::string::size_type getFilterSubStringPos(U32 index) const;
|
||||
std::string::size_type getFilterSubStringLen(U32 index) const;
|
||||
// End Multi-substring inventory search
|
||||
|
||||
void setFilterPermissions(PermissionMask perms);
|
||||
PermissionMask getFilterPermissions() const;
|
||||
|
|
@ -203,6 +214,12 @@ private:
|
|||
|
||||
std::string::size_type mSubStringMatchOffset;
|
||||
std::string mFilterSubString;
|
||||
|
||||
// Begin Multi-substring inventory search
|
||||
std::vector<std::string::size_type> mSubStringMatchOffsets;
|
||||
std::vector<std::string> mFilterSubStrings;
|
||||
// End Multi-substring inventory search
|
||||
|
||||
std::string mFilterSubStringOrig;
|
||||
const std::string mName;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
left="10"
|
||||
max_length_chars="300"
|
||||
name="inventory search editor"
|
||||
tool_tip="Type in one or more words to search for, separated by '+' "
|
||||
top_pad="4"
|
||||
width="322" />
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue