diff options
author | Merov Linden <merov@lindenlab.com> | 2013-04-29 18:57:26 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2013-04-29 18:57:26 -0700 |
commit | 343ad70696349f4b30b7f2f9a6242cdd1035cd21 (patch) | |
tree | 58a17d18625617de33f7c3c23e64ab576c242712 | |
parent | 59880225108ef807ef58ed98357f0706c045ff61 (diff) |
ACME-275 : WIP : Starting to write the LLPersonViewerFilter code
-rw-r--r-- | indra/newview/llpanelpeople.cpp | 24 | ||||
-rw-r--r-- | indra/newview/llpersonmodelcommon.cpp | 62 | ||||
-rw-r--r-- | indra/newview/llpersonmodelcommon.h | 26 |
3 files changed, 92 insertions, 20 deletions
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index ef45cc44f7..ce31c735e3 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -1200,23 +1200,23 @@ void LLPanelPeople::onFilterEdit(const std::string& search_string) { // store accordion tabs opened/closed state before any manipulation with accordion tabs if (!saved_filter.empty()) - { - notifyChildren(LLSD().with("action","store_state")); - } + { + notifyChildren(LLSD().with("action","store_state")); + } mOnlineFriendList->setNameFilter(filter); mAllFriendList->setNameFilter(filter); - setAccordionCollapsedByUser("tab_online", false); - setAccordionCollapsedByUser("tab_all", false); - showFriendsAccordionsIfNeeded(); + setAccordionCollapsedByUser("tab_online", false); + setAccordionCollapsedByUser("tab_all", false); + showFriendsAccordionsIfNeeded(); // restore accordion tabs state _after_ all manipulations if(saved_filter.empty()) - { - notifyChildren(LLSD().with("action","restore_state")); - } -} + { + notifyChildren(LLSD().with("action","restore_state")); + } + } else if (cur_tab == GROUP_TAB_NAME) { mGroupList->setNameFilter(filter); @@ -1225,6 +1225,10 @@ void LLPanelPeople::onFilterEdit(const std::string& search_string) { mRecentList->setNameFilter(filter); } + else if (cur_tab == FBCTESTTWO_TAB_NAME) + { + mPersonFolderViewModel.getFilter().setFilterSubString(filter); + } } void LLPanelPeople::onTabSelected(const LLSD& param) 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(""); +} diff --git a/indra/newview/llpersonmodelcommon.h b/indra/newview/llpersonmodelcommon.h index f3454df53f..bdbee002e6 100644 --- a/indra/newview/llpersonmodelcommon.h +++ b/indra/newview/llpersonmodelcommon.h @@ -127,7 +127,7 @@ private: }; -//Below code is just copied and adjusted from llconversationmodel.h, will need to investigate further +// Filtering functional object class LLPersonViewFilter : public LLFolderViewFilter { @@ -143,20 +143,23 @@ public: // Default sort order is by type for sessions and by date for participants static const U32 SO_DEFAULT = (SO_SESSION_TYPE << 16) | (SO_DATE); - LLPersonViewFilter() { mEmpty = ""; } + LLPersonViewFilter(); ~LLPersonViewFilter() {} - bool check(const LLFolderViewModelItem* item) { return true; } + void setFilterSubString(const std::string& string); + std::string::size_type getFilterStringSize() const; + bool check(const LLFolderViewModelItem* item); + bool showAllResults() const; + std::string::size_type getStringMatchOffset(LLFolderViewModelItem* item) const; + bool isActive() const; + bool isModified() const; + void clearModified(); + bool checkFolder(const LLFolderViewModelItem* folder) const { return true; } + void setEmptyLookupMessage(const std::string& message) { } std::string getEmptyLookupMessage() const { return mEmpty; } - bool showAllResults() const { return true; } - std::string::size_type getStringMatchOffset(LLFolderViewModelItem* item) const { return std::string::npos; } - std::string::size_type getFilterStringSize() const { return 0; } - bool isActive() const { return false; } - bool isModified() const { return false; } - void clearModified() { } const std::string& getName() const { return mEmpty; } const std::string& getFilterText() { return mEmpty; } void setModified(EFilterModified behavior = FILTER_RESTART) { } @@ -173,8 +176,11 @@ public: S32 getCurrentGeneration() const { return 0; } S32 getFirstSuccessGeneration() const { return 0; } S32 getFirstRequiredGeneration() const { return 0; } + private: - std::string mEmpty; + std::string mEmpty; + std::string mFilterSubString; + EFilterModified mFilterModified; }; class LLPersonViewSort |