From 12db7a97395fb58a62efb224c2f017d3d7d8e51c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 10 Feb 2014 11:18:30 +0100 Subject: [PATCH] FIRE-5283: Add option to sort friendlist in people panel by username --- indra/newview/llavatarlist.cpp | 23 +++++++++++++++++++ indra/newview/llavatarlist.h | 16 +++++++++++++ indra/newview/llpanelpeople.cpp | 15 ++++++++++++ indra/newview/llpanelpeople.h | 2 ++ .../xui/de/menu_people_friends_view.xml | 1 + .../xui/en/menu_people_friends_view.xml | 10 ++++++++ 6 files changed, 67 insertions(+) diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index 3e7686efa5..dacb84ad6d 100755 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -224,6 +224,8 @@ static bool findInsensitive(std::string haystack, const std::string& needle_uppe //comparators static const LLAvatarItemNameComparator NAME_COMPARATOR; static const LLFlatListView::ItemReverseComparator REVERSE_NAME_COMPARATOR(NAME_COMPARATOR); +// FIRE-5283: Sort by username +static const LLAvatarItemUserNameComparator USERNAME_COMPARATOR; LLAvatarList::Params::Params() : ignore_online_status("ignore_online_status", false) @@ -431,6 +433,14 @@ void LLAvatarList::sortByName() sort(); } +// FIRE-5283: Sort by username +void LLAvatarList::sortByUserName() +{ + setComparator(&USERNAME_COMPARATOR); + sort(); +} +// + void LLAvatarList::setDirty(bool val /*= true*/, bool force_refresh /*= false*/) { mDirty = val; @@ -909,6 +919,19 @@ bool LLAvatarItemAgentOnTopComparator::doCompare(const LLAvatarListItem* avatar_ return LLAvatarItemNameComparator::doCompare(avatar_item1,avatar_item2); } +// FIRE-5283: Sort by username +bool LLAvatarItemUserNameComparator::doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const +{ + std::string name1 = avatar_item1->getUserName(); + std::string name2 = avatar_item2->getUserName(); + + LLStringUtil::toUpper(name1); + LLStringUtil::toUpper(name2); + + return name1 < name2; +} +// + /************************************************************************/ /* class LLAvalineListItem */ /************************************************************************/ diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h index 699f9b896f..a5f55f6362 100755 --- a/indra/newview/llavatarlist.h +++ b/indra/newview/llavatarlist.h @@ -93,6 +93,8 @@ public: void showUsername(bool visible); void showVoiceVolume(bool visible); void sortByName(); + // FIRE-5283: Sort by username + void sortByUserName(); void setShowIcons(std::string param_name); bool getIconsVisible() const { return mShowIcons; } const std::string getIconParamName() const{return mIconParamName;} @@ -233,6 +235,20 @@ protected: virtual bool doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const; }; +// FIRE-5283: Sort by username +class LLAvatarItemUserNameComparator : public LLAvatarItemComparator +{ + LOG_CLASS(LLAvatarItemUserNameComparator); + +public: + LLAvatarItemUserNameComparator() {}; + virtual ~LLAvatarItemUserNameComparator() {}; + +protected: + virtual bool doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const; +}; +// + /** * Represents Avaline caller in Avatar list in Voice Control Panel and group chats. */ diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index d94fc5cb5d..35d5bbef59 100755 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -1148,6 +1148,11 @@ void LLPanelPeople::setSortOrder(LLAvatarList* list, ESortOrder order, bool save list->setComparator(&DISTANCE_COMPARATOR); list->sort(); break; + // FIRE-5283: Sort by username + case E_SORT_BY_USERNAME: + list->sortByUserName(); + break; + // default: llwarns << "Unrecognized people sort order for " << list->getName() << llendl; return; @@ -1435,6 +1440,12 @@ void LLPanelPeople::onFriendsViewSortMenuItemClicked(const LLSD& userdata) { setSortOrder(mAllFriendList, E_SORT_BY_NAME); } + // FIRE-5283: Sort by username + if (chosen_item == "sort_username") + { + setSortOrder(mAllFriendList, E_SORT_BY_USERNAME); + } + // else if (chosen_item == "sort_status") { setSortOrder(mAllFriendList, E_SORT_BY_STATUS); @@ -1528,6 +1539,10 @@ bool LLPanelPeople::onFriendsViewSortMenuItemCheck(const LLSD& userdata) return sort_order == E_SORT_BY_NAME; if (item == "sort_status") return sort_order == E_SORT_BY_STATUS; + // FIRE-5283: Sort by username + if (item == "sort_username") + return sort_order == E_SORT_BY_USERNAME; + // return false; } diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index 518a35b221..5610b21466 100755 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -79,6 +79,8 @@ private: E_SORT_BY_MOST_RECENT = 2, E_SORT_BY_DISTANCE = 3, E_SORT_BY_RECENT_SPEAKERS = 4, + // FIRE-5283: Sort by username + E_SORT_BY_USERNAME = 5, } ESortOrder; void removePicker(); diff --git a/indra/newview/skins/default/xui/de/menu_people_friends_view.xml b/indra/newview/skins/default/xui/de/menu_people_friends_view.xml index da4890fe96..6023474f03 100644 --- a/indra/newview/skins/default/xui/de/menu_people_friends_view.xml +++ b/indra/newview/skins/default/xui/de/menu_people_friends_view.xml @@ -1,6 +1,7 @@ + diff --git a/indra/newview/skins/default/xui/en/menu_people_friends_view.xml b/indra/newview/skins/default/xui/en/menu_people_friends_view.xml index 8790fde7c5..3295c88609 100755 --- a/indra/newview/skins/default/xui/en/menu_people_friends_view.xml +++ b/indra/newview/skins/default/xui/en/menu_people_friends_view.xml @@ -13,6 +13,16 @@ function="People.Friends.ViewSort.CheckItem" parameter="sort_name" /> + + + +