summaryrefslogtreecommitdiff
path: root/indra/newview/llpersonmodelcommon.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2013-04-29 18:57:26 -0700
committerMerov Linden <merov@lindenlab.com>2013-04-29 18:57:26 -0700
commit343ad70696349f4b30b7f2f9a6242cdd1035cd21 (patch)
tree58a17d18625617de33f7c3c23e64ab576c242712 /indra/newview/llpersonmodelcommon.cpp
parent59880225108ef807ef58ed98357f0706c045ff61 (diff)
ACME-275 : WIP : Starting to write the LLPersonViewerFilter code
Diffstat (limited to 'indra/newview/llpersonmodelcommon.cpp')
-rw-r--r--indra/newview/llpersonmodelcommon.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/indra/newview/llpersonmodelcommon.cpp b/indra/newview/llpersonmodelcommon.cpp
index bea7f3d45e..4e54562f18 100644
--- a/indra/newview/llpersonmodelcommon.cpp
+++ b/indra/newview/llpersonmodelcommon.cpp
@@ -157,3 +157,65 @@ LLPersonModel::LLPersonModel(LLFolderViewModelInterface& root_view_model) :
LLPersonModelCommon(root_view_model)
{
}
+
+//
+// LLPersonViewFilter
+//
+
+LLPersonViewFilter::LLPersonViewFilter() :
+ mEmpty(""),
+ mFilterSubString(""),
+ mFilterModified(FILTER_NONE)
+{
+}
+
+void LLPersonViewFilter::setFilterSubString(const std::string& string)
+{
+ std::string filter_sub_string_new = string;
+ LLStringUtil::trimHead(filter_sub_string_new);
+ LLStringUtil::toUpper(filter_sub_string_new);
+
+ if (mFilterSubString != filter_sub_string_new)
+ {
+ mFilterSubString = filter_sub_string_new;
+ }
+}
+
+std::string::size_type LLPersonViewFilter::getFilterStringSize() const
+{
+ return mFilterSubString.size();
+}
+
+bool LLPersonViewFilter::check(const LLFolderViewModelItem* item)
+{
+ //const LLPersonModelCommon* person = dynamic_cast<const LLPersonModelCommon*>(item);
+ std::string::size_type string_offset = mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos;
+
+ return (mFilterSubString.size() == 0 || string_offset != std::string::npos);
+}
+
+bool LLPersonViewFilter::showAllResults() const
+{
+ return mFilterSubString.size() > 0;
+}
+
+std::string::size_type LLPersonViewFilter::getStringMatchOffset(LLFolderViewModelItem* item) const
+{
+ return mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos;
+}
+
+bool LLPersonViewFilter::isActive() const
+{
+ return mFilterSubString.size();
+}
+
+bool LLPersonViewFilter::isModified() const
+{
+ return isActive();
+}
+
+void LLPersonViewFilter::clearModified()
+{
+ mFilterModified = FILTER_NONE;
+ setFilterSubString("");
+}