diff options
Diffstat (limited to 'indra/newview/llpanelpeople.cpp')
-rw-r--r-- | indra/newview/llpanelpeople.cpp | 188 |
1 files changed, 135 insertions, 53 deletions
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 309a97a9f2..6a41b6feb9 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -42,15 +42,18 @@ #include "llpanelpeople.h" // newview +#include "llaccordionctrltab.h" #include "llagent.h" #include "llavataractions.h" #include "llavatarlist.h" +#include "llavatarlistitem.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llfloateravatarpicker.h" //#include "llfloaterminiinspector.h" #include "llfriendcard.h" #include "llgroupactions.h" #include "llgrouplist.h" +#include "llpanelpeoplemenus.h" #include "llrecentpeople.h" #include "llviewercontrol.h" // for gSavedSettings #include "llviewermenu.h" // for gMenuHolder @@ -68,6 +71,27 @@ static const std::string FRIENDS_TAB_NAME = "friends_panel"; static const std::string GROUP_TAB_NAME = "groups_panel"; static const std::string RECENT_TAB_NAME = "recent_panel"; +/** Comparator for comparing avatar items by last interaction date */ +class LLAvatarItemRecentComparator : public LLAvatarItemComparator +{ +public: + LLAvatarItemRecentComparator() {}; + virtual ~LLAvatarItemRecentComparator() {}; + +protected: + virtual bool doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const + { + LLRecentPeople& people = LLRecentPeople::instance(); + const LLDate& date1 = people.getDate(avatar_item1->getAvatarId()); + const LLDate& date2 = people.getDate(avatar_item2->getAvatarId()); + + //older comes first + return date1 > date2; + } +}; + +static const LLAvatarItemRecentComparator RECENT_COMPARATOR; + static LLRegisterPanelClassWrapper<LLPanelPeople> t_people("panel_people"); //============================================================================= @@ -299,7 +323,7 @@ private: /** * Updates the recent people list (those the agent has recently interacted with). */ -class LLRecentListUpdater : public LLAvatarListUpdater +class LLRecentListUpdater : public LLAvatarListUpdater, public boost::signals2::trackable { LOG_CLASS(LLRecentListUpdater); @@ -398,21 +422,25 @@ LLPanelPeople::~LLPanelPeople() LLView::deleteViewByHandle(mGroupPlusMenuHandle); LLView::deleteViewByHandle(mNearbyViewSortMenuHandle); LLView::deleteViewByHandle(mFriendsViewSortMenuHandle); + LLView::deleteViewByHandle(mGroupsViewSortMenuHandle); LLView::deleteViewByHandle(mRecentViewSortMenuHandle); } -void onAvatarListTmpDoubleClicked(LLAvatarListTmp* list) -{ - LLUUID clicked_id = list->getCurrentID(); - if (clicked_id.isNull()) +void LLPanelPeople::onFriendsAccordionExpandedCollapsed(const LLSD& param, LLAvatarList* avatar_list) +{ + if(!avatar_list) + { + llerrs << "Bad parameter" << llendl; return; + } -#if 0 // SJB: Useful for testing, but not currently functional or to spec - LLAvatarActions::showProfile(clicked_id); -#else // spec says open IM window - LLAvatarActions::startIM(clicked_id); -#endif + bool expanded = param.asBoolean(); + + if(!expanded) + { + avatar_list->resetSelection(); + } } BOOL LLPanelPeople::postBuild() @@ -427,11 +455,22 @@ BOOL LLPanelPeople::postBuild() mOnlineFriendList = getChild<LLPanel>(FRIENDS_TAB_NAME)->getChild<LLAvatarList>("avatars_online"); mAllFriendList = getChild<LLPanel>(FRIENDS_TAB_NAME)->getChild<LLAvatarList>("avatars_all"); + mOnlineFriendList->setNoItemsCommentText(getString("no_friends_online")); + mAllFriendList->setNoItemsCommentText(getString("no_friends")); mNearbyList = getChild<LLPanel>(NEARBY_TAB_NAME)->getChild<LLAvatarList>("avatar_list"); + mNearbyList->setNoItemsCommentText(getString("no_one_near")); + + mRecentList = getChild<LLPanel>(RECENT_TAB_NAME)->getChild<LLAvatarList>("avatar_list"); + mRecentList->setNoItemsCommentText(getString("no_people")); - mRecentList = getChild<LLPanel>(RECENT_TAB_NAME)->getChild<LLAvatarListTmp>("avatar_list"); mGroupList = getChild<LLGroupList>("group_list"); + mGroupList->setNoItemsCommentText(getString("no_groups")); + + mNearbyList->setContextMenu(&LLPanelPeopleMenus::gNearbyMenu); + mRecentList->setContextMenu(&LLPanelPeopleMenus::gNearbyMenu); + + mRecentList->setComparator(&RECENT_COMPARATOR); LLPanel* groups_panel = getChild<LLPanel>(GROUP_TAB_NAME); groups_panel->childSetAction("activate_btn", boost::bind(&LLPanelPeople::onActivateButtonClicked, this)); @@ -445,15 +484,24 @@ BOOL LLPanelPeople::postBuild() mOnlineFriendList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, mOnlineFriendList)); mAllFriendList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, mAllFriendList)); mNearbyList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, mNearbyList)); - mRecentList->setDoubleClickCallback(boost::bind(onAvatarListTmpDoubleClicked, mRecentList)); + mRecentList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, mRecentList)); + mOnlineFriendList->setCommitCallback(boost::bind(&LLPanelPeople::onAvatarListCommitted, this, mOnlineFriendList)); mAllFriendList->setCommitCallback(boost::bind(&LLPanelPeople::onAvatarListCommitted, this, mAllFriendList)); mNearbyList->setCommitCallback(boost::bind(&LLPanelPeople::onAvatarListCommitted, this, mNearbyList)); - mRecentList->setCommitCallback(boost::bind(&LLPanelPeople::updateButtons, this)); + mRecentList->setCommitCallback(boost::bind(&LLPanelPeople::onAvatarListCommitted, this, mRecentList)); mGroupList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onGroupInfoButtonClicked, this)); mGroupList->setCommitCallback(boost::bind(&LLPanelPeople::updateButtons, this)); + LLAccordionCtrlTab* accordion_tab = getChild<LLAccordionCtrlTab>("tab_all"); + accordion_tab->setDropDownStateChangedCallback( + boost::bind(&LLPanelPeople::onFriendsAccordionExpandedCollapsed, this, _2, mAllFriendList)); + + accordion_tab = getChild<LLAccordionCtrlTab>("tab_online"); + accordion_tab->setDropDownStateChangedCallback( + boost::bind(&LLPanelPeople::onFriendsAccordionExpandedCollapsed, this, _2, mOnlineFriendList)); + buttonSetAction("view_profile_btn", boost::bind(&LLPanelPeople::onViewProfileButtonClicked, this)); buttonSetAction("add_friend_btn", boost::bind(&LLPanelPeople::onAddFriendButtonClicked, this)); buttonSetAction("group_info_btn", boost::bind(&LLPanelPeople::onGroupInfoButtonClicked, this)); @@ -466,6 +514,7 @@ BOOL LLPanelPeople::postBuild() getChild<LLPanel>(NEARBY_TAB_NAME)->childSetAction("nearby_view_sort_btn",boost::bind(&LLPanelPeople::onNearbyViewSortButtonClicked, this)); getChild<LLPanel>(RECENT_TAB_NAME)->childSetAction("recent_viewsort_btn",boost::bind(&LLPanelPeople::onRecentViewSortButtonClicked, this)); getChild<LLPanel>(FRIENDS_TAB_NAME)->childSetAction("friends_viewsort_btn",boost::bind(&LLPanelPeople::onFriendsViewSortButtonClicked, this)); + getChild<LLPanel>(GROUP_TAB_NAME)->childSetAction("groups_viewsort_btn",boost::bind(&LLPanelPeople::onGroupsViewSortButtonClicked, this)); // Must go after setting commit callback and initializing all pointers to children. mTabContainer->selectTabByName(FRIENDS_TAB_NAME); @@ -476,6 +525,7 @@ BOOL LLPanelPeople::postBuild() registrar.add("People.Group.Plus.Action", boost::bind(&LLPanelPeople::onGroupPlusMenuItemClicked, this, _2)); registrar.add("People.Friends.ViewSort.Action", boost::bind(&LLPanelPeople::onFriendsViewSortMenuItemClicked, this, _2)); registrar.add("People.Nearby.ViewSort.Action", boost::bind(&LLPanelPeople::onNearbyViewSortMenuItemClicked, this, _2)); + registrar.add("People.Groups.ViewSort.Action", boost::bind(&LLPanelPeople::onGroupsViewSortMenuItemClicked, this, _2)); registrar.add("People.Recent.ViewSort.Action", boost::bind(&LLPanelPeople::onRecentViewSortMenuItemClicked, this, _2)); LLMenuGL* plus_menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_group_plus.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); @@ -489,6 +539,10 @@ BOOL LLPanelPeople::postBuild() if(friend_view_sort) mFriendsViewSortMenuHandle = friend_view_sort->getHandle(); + LLMenuGL* group_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_people_groups_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + if(group_view_sort) + mGroupsViewSortMenuHandle = group_view_sort->getHandle(); + LLMenuGL* recent_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_people_recent_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); if(recent_view_sort) mRecentViewSortMenuHandle = recent_view_sort->getHandle(); @@ -497,13 +551,28 @@ BOOL LLPanelPeople::postBuild() // Perform initial update. mFriendListUpdater->forceUpdate(); - mRecentListUpdater->forceUpdate(); + mNearbyListUpdater->forceUpdate(); mGroupListUpdater->forceUpdate(); mRecentListUpdater->forceUpdate(); + // call this method in case some list is empty and buttons can be in inconsistent state + updateButtons(); + return TRUE; } +void LLPanelPeople::applyFilterToTab(const std::string& tab_name) +{ + if (tab_name == FRIENDS_TAB_NAME) // this tab has two lists + filterFriendList(); + else if (tab_name == NEARBY_TAB_NAME) + filterNearbyList(); + else if (tab_name == RECENT_TAB_NAME) + filterRecentList(); + else if (tab_name == GROUP_TAB_NAME) + updateGroupList(); +} + bool LLPanelPeople::updateFriendList(U32 changed_mask) { // Refresh names. @@ -570,10 +639,7 @@ bool LLPanelPeople::updateGroupList() return true; // there's no point in further updates bool have_names = mGroupList->update(mFilterSubString); - - if (mGroupList->isEmpty()) - mGroupList->setCommentText(getString("no_groups")); - + updateButtons(); return have_names; } @@ -587,22 +653,15 @@ bool LLPanelPeople::filterFriendList() mOnlineFriendList->update(mOnlineFriendVec, mFilterSubString) & mAllFriendList->update(mAllFriendVec, mFilterSubString); - if (mOnlineFriendVec.size() == 0) - mOnlineFriendList->setCommentText(getString("no_friends_online")); - - if (mAllFriendVec.size() == 0) - mAllFriendList->setCommentText(getString("no_friends")); + updateButtons(); return have_names; } bool LLPanelPeople::filterNearbyList() { bool have_names = mNearbyList->update(mNearbyVec, mFilterSubString); - - if (mNearbyVec.size() == 0) - mNearbyList->setCommentText(getString("no_one_near")); - + updateButtons(); return have_names; } @@ -612,9 +671,11 @@ bool LLPanelPeople::filterRecentList() return true; if (mRecentVec.size() > 0) - return mRecentList->update(mRecentVec, mFilterSubString); - - mRecentList->setCommentText(getString("no_people")); + { + bool updated = mRecentList->update(mRecentVec, mFilterSubString); + updateButtons(); + return updated; + } return true; } @@ -664,12 +725,12 @@ void LLPanelPeople::updateButtons() if (group_tab_active) { - bool item_selected = mGroupList->getFirstSelected() != NULL; + bool item_selected = mGroupList->getSelectedItem() != NULL; bool cur_group_active = true; if (item_selected) { - selected_id = mGroupList->getCurrentID(); + selected_id = mGroupList->getSelectedUUID(); cur_group_active = (gAgent.getGroupID() == selected_id); } @@ -714,20 +775,20 @@ LLUUID LLPanelPeople::getCurrentItemID() const { LLUUID cur_online_friend; - if ((cur_online_friend = mOnlineFriendList->getCurrentID()).notNull()) + if ((cur_online_friend = mOnlineFriendList->getSelectedUUID()).notNull()) return cur_online_friend; - return mAllFriendList->getCurrentID(); + return mAllFriendList->getSelectedUUID(); } if (cur_tab == NEARBY_TAB_NAME) - return mNearbyList->getCurrentID(); + return mNearbyList->getSelectedUUID(); if (cur_tab == RECENT_TAB_NAME) - return mRecentList->getCurrentID(); + return mRecentList->getSelectedUUID(); if (cur_tab == GROUP_TAB_NAME) - return mGroupList->getCurrentID(); + return mGroupList->getSelectedUUID(); llassert(0 && "unknown tab selected"); return LLUUID::null; @@ -785,20 +846,16 @@ void LLPanelPeople::onFilterEdit(const std::string& search_string) LLStringUtil::toUpper(mFilterSubString); LLStringUtil::trimHead(mFilterSubString); - // Apply new filter to all tabs. - filterNearbyList(); - filterFriendList(); - filterRecentList(); - updateGroupList(); - - updateButtons(); + // Apply new filter to current tab. + applyFilterToTab(getActiveTabName()); } void LLPanelPeople::onTabSelected(const LLSD& param) { std::string tab_name = getChild<LLPanel>(param.asString())->getName(); mNearbyListUpdater->setActive(tab_name == NEARBY_TAB_NAME); - updateButtons(); + applyFilterToTab(tab_name); + // No need to call updateButtons() because applyFilterToTab() does that. if (GROUP_TAB_NAME == tab_name) mFilterEditor->setLabel(getString("groups_filter_label")); @@ -808,7 +865,7 @@ void LLPanelPeople::onTabSelected(const LLSD& param) void LLPanelPeople::onAvatarListDoubleClicked(LLAvatarList* list) { - LLUUID clicked_id = list->getCurrentID(); + LLUUID clicked_id = list->getSelectedUUID(); if (clicked_id.isNull()) return; @@ -826,9 +883,9 @@ void LLPanelPeople::onAvatarListCommitted(LLAvatarList* list) if (getActiveTabName() == FRIENDS_TAB_NAME) { if (list == mOnlineFriendList) - mAllFriendList->deselectAllItems(TRUE); + mAllFriendList->resetSelection(true); else if (list == mAllFriendList) - mOnlineFriendList->deselectAllItems(TRUE); + mOnlineFriendList->resetSelection(true); else llassert(0 && "commit on unknown friends list"); } @@ -890,7 +947,7 @@ void LLPanelPeople::onImButtonClicked() void LLPanelPeople::onActivateButtonClicked() { - LLGroupActions::activate(mGroupList->getCurrentID()); + LLGroupActions::activate(mGroupList->getSelectedUUID()); } // static @@ -909,7 +966,7 @@ bool LLPanelPeople::onFriendListUpdate(U32 changed_mask) // Update online status in the Recent tab. // *TODO: isn't it too much to update the whole list? - updateRecentList(); +// updateRecentList(); // mantipov: seems online status should be supported by LLAvatarListItem itself. return have_names; } @@ -957,6 +1014,17 @@ void LLPanelPeople::onFriendsViewSortMenuItemClicked(const LLSD& userdata) { } } + +void LLPanelPeople::onGroupsViewSortMenuItemClicked(const LLSD& userdata) +{ + std::string chosen_item = userdata.asString(); + + if (chosen_item == "show_icons") + { + mGroupList->toggleIcons(); + } +} + void LLPanelPeople::onNearbyViewSortMenuItemClicked(const LLSD& userdata) { std::string chosen_item = userdata.asString(); @@ -966,6 +1034,7 @@ void LLPanelPeople::onNearbyViewSortMenuItemClicked(const LLSD& userdata) } else if (chosen_item == "sort_name") { + mNearbyList->sortByName(); } else if (chosen_item == "view_icons") { @@ -978,11 +1047,14 @@ void LLPanelPeople::onRecentViewSortMenuItemClicked(const LLSD& userdata) { std::string chosen_item = userdata.asString(); - if (chosen_item == "sort_most") + if (chosen_item == "sort_recent") { - } + mRecentList->setComparator(&RECENT_COMPARATOR); + mRecentList->sort(); + } else if (chosen_item == "sort_name") { + mRecentList->sortByName(); } else if (chosen_item == "view_icons") { @@ -1008,6 +1080,7 @@ void LLPanelPeople::onMoreButtonClicked() { // *TODO: not implemented yet } + void LLPanelPeople::onFriendsViewSortButtonClicked() { LLMenuGL* menu = (LLMenuGL*)mFriendsViewSortMenuHandle.get(); @@ -1015,6 +1088,15 @@ void LLPanelPeople::onFriendsViewSortButtonClicked() return; showGroupMenu(menu); } + +void LLPanelPeople::onGroupsViewSortButtonClicked() +{ + LLMenuGL* menu = (LLMenuGL*)mGroupsViewSortMenuHandle.get(); + if (!menu) + return; + showGroupMenu(menu); +} + void LLPanelPeople::onRecentViewSortButtonClicked() { LLMenuGL* menu = (LLMenuGL*)mRecentViewSortMenuHandle.get(); @@ -1022,6 +1104,7 @@ void LLPanelPeople::onRecentViewSortButtonClicked() return; showGroupMenu(menu); } + void LLPanelPeople::onNearbyViewSortButtonClicked() { LLMenuGL* menu = (LLMenuGL*)mNearbyViewSortMenuHandle.get(); @@ -1041,4 +1124,3 @@ void LLPanelPeople::onOpen(const LLSD& key) else reSelectedCurrentTab(); } - |