diff options
author | Merov Linden <merov@lindenlab.com> | 2013-05-02 16:24:09 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2013-05-02 16:24:09 -0700 |
commit | a73305c41d058fc755b824e5a9243afe43b424e1 (patch) | |
tree | b7bc60c021461604d6e425366c56e88a9ac8ed6e /indra/newview/llpersonmodelcommon.cpp | |
parent | 8764e84041c48d0facd3a2860d90f78c88714f7c (diff) |
ACME-275 : WIP : Implemented filter(), still arrange() not done timely, tweaked test values to allow test of sort and filter
Diffstat (limited to 'indra/newview/llpersonmodelcommon.cpp')
-rw-r--r-- | indra/newview/llpersonmodelcommon.cpp | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/indra/newview/llpersonmodelcommon.cpp b/indra/newview/llpersonmodelcommon.cpp index 3e9ca9c3b9..9660432b80 100644 --- a/indra/newview/llpersonmodelcommon.cpp +++ b/indra/newview/llpersonmodelcommon.cpp @@ -31,21 +31,23 @@ #include "llevents.h" #include "llsdutil.h" +#include "llstring.h" // // LLPersonModelCommon // LLPersonModelCommon::LLPersonModelCommon(std::string display_name, LLFolderViewModelInterface& root_view_model) : -LLFolderViewModelItemCommon(root_view_model), - mName(display_name), + LLFolderViewModelItemCommon(root_view_model), mID(LLUUID().generateNewID()) { + renameItem(display_name); } LLPersonModelCommon::LLPersonModelCommon(LLFolderViewModelInterface& root_view_model) : -LLFolderViewModelItemCommon(root_view_model), + LLFolderViewModelItemCommon(root_view_model), mName(""), + mSearchableName(""), mID(LLUUID().generateNewID()) { } @@ -55,6 +57,14 @@ LLPersonModelCommon::~LLPersonModelCommon() } +BOOL LLPersonModelCommon::renameItem(const std::string& new_name) +{ + mName = new_name; + mSearchableName = new_name; + LLStringUtil::toUpper(mSearchableName); + return TRUE; +} + void LLPersonModelCommon::postEvent(const std::string& event_type, LLPersonTabModel* folder, LLPersonModel* person) { LLUUID folder_id = folder->getID(); @@ -84,6 +94,39 @@ void LLPersonModelCommon::showProperties(void) { } +bool LLPersonModelCommon::filter( LLFolderViewFilter& filter) +{ + // See LLFolderViewModelItemInventory::filter() +/* + if (!filter.isModified()) + { + llinfos << "Merov : LLPersonModelCommon::filter, exit, no modif" << llendl; + return true; + } +*/ + if (!mChildren.empty()) + { + //llinfos << "Merov : LLPersonModelCommon::filter, filtering folder = " << getDisplayName() << llendl; + setPassedFilter(1, -1, filter.getStringMatchOffset(this), filter.getFilterStringSize()); + for (child_list_t::iterator iter = mChildren.begin(), end_iter = mChildren.end(); + iter != end_iter; + ++iter) + { + // LLFolderViewModelItem + LLPersonModelCommon* item = dynamic_cast<LLPersonModelCommon*>(*iter); + item->filter(filter); + } + } + else + { + const bool passed_filter = filter.check(this); + setPassedFilter(passed_filter, -1, filter.getStringMatchOffset(this), filter.getFilterStringSize()); + } + + filter.clearModified(); + return true; +} + // // LLPersonTabModel // @@ -186,7 +229,7 @@ void LLPersonViewFilter::setFilterSubString(const std::string& string) if (mFilterSubString != filter_sub_string_new) { // *TODO : Add logic to support more and less restrictive filtering - mFilterModified = FILTER_RESTART; + setModified(FILTER_RESTART); mFilterSubString = filter_sub_string_new; } } @@ -198,9 +241,7 @@ bool LLPersonViewFilter::showAllResults() const bool LLPersonViewFilter::check(const LLFolderViewModelItem* 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); + return (mFilterSubString.size() ? (item->getSearchableName().find(mFilterSubString) != std::string::npos) : true); } std::string::size_type LLPersonViewFilter::getStringMatchOffset(LLFolderViewModelItem* item) const |