diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2024-07-23 10:45:57 +0200 |
---|---|---|
committer | Guru <alexandrgproductengine@lindenlab.com> | 2024-07-24 16:58:25 +0200 |
commit | aaa5caeca89cb08f785fec1785d8edeca6eda0ae (patch) | |
tree | 34563ca873300f07f8a3533e64a8a58a386fc116 | |
parent | 57e78ed43b61864a6b8a54df95d8823daaeb5fe8 (diff) |
#1318 Pagination in the Group Interface
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 41 | ||||
-rw-r--r-- | indra/newview/llgroupmgr.cpp | 248 | ||||
-rw-r--r-- | indra/newview/llgroupmgr.h | 16 | ||||
-rw-r--r-- | indra/newview/llpanelgroupbulk.cpp | 213 | ||||
-rw-r--r-- | indra/newview/llpanelgroupbulkimpl.h | 5 | ||||
-rw-r--r-- | indra/newview/llpanelgrouproles.cpp | 259 |
6 files changed, 367 insertions, 415 deletions
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 1d9564d107..8512555b49 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1479,10 +1479,9 @@ const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const item = getFirstSelected(); if (item) { - auto col = item->getColumn(column); - if(col) + if (LLScrollListCell* cell = item->getColumn(column)) { - return col->getValue().asString(); + return cell->getValue().asString(); } } @@ -2720,7 +2719,8 @@ struct SameSortColumn bool LLScrollListCtrl::setSort(S32 column_idx, bool ascending) { LLScrollListColumn* sort_column = getColumn(column_idx); - if (!sort_column) return false; + if (!sort_column) + return false; sort_column->mSortDirection = ascending ? LLScrollListColumn::ASCENDING : LLScrollListColumn::DESCENDING; @@ -2733,32 +2733,28 @@ bool LLScrollListCtrl::setSort(S32 column_idx, bool ascending) mSortColumns.push_back(new_sort_column); return true; } - else - { - // grab current sort column - sort_column_t cur_sort_column = mSortColumns.back(); - // remove any existing sort criterion referencing this column - // and add the new one - mSortColumns.erase(remove_if(mSortColumns.begin(), mSortColumns.end(), SameSortColumn(column_idx)), mSortColumns.end()); - mSortColumns.push_back(new_sort_column); + // grab current sort column + sort_column_t cur_sort_column = mSortColumns.back(); - // did the sort criteria change? - return (cur_sort_column != new_sort_column); - } + // remove any existing sort criterion referencing this column + // and add the new one + mSortColumns.erase(remove_if(mSortColumns.begin(), mSortColumns.end(), SameSortColumn(column_idx)), mSortColumns.end()); + mSortColumns.push_back(new_sort_column); + + // did the sort criteria change? + return cur_sort_column != new_sort_column; } S32 LLScrollListCtrl::getLinesPerPage() { - //if mPageLines is NOT provided display all item if (mPageLines) { return mPageLines; } - else - { - return mLineHeight ? mItemListRect.getHeight() / mLineHeight : getItemCount(); - } + + // If mPageLines is NOT provided then display all items + return mLineHeight ? mItemListRect.getHeight() / mLineHeight : getItemCount(); } @@ -2774,7 +2770,7 @@ void LLScrollListCtrl::sortByColumn(const std::string& name, bool ascending) column_map_t::iterator itor = mColumns.find(name); if (itor != mColumns.end()) { - sortByColumnIndex((*itor).second->mIndex, ascending); + sortByColumnIndex(itor->second->mIndex, ascending); } } @@ -3093,8 +3089,7 @@ std::string LLScrollListCtrl::getSortColumnName() { LLScrollListColumn* column = mSortColumns.empty() ? NULL : mColumnsIndexed[mSortColumns.back().first]; - if (column) return column->mName; - else return ""; + return column ? column->mName : LLStringUtil::null; } bool LLScrollListCtrl::hasSortOrder() const diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 1057bc25e0..090ed7b0e2 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -806,7 +806,7 @@ void LLGroupMgrGroupData::banMemberById(const LLUUID& participant_uuid) mPendingBanRequest = false; - LLGroupMemberData* member_data = (*mi).second; + LLGroupMemberData* member_data = mi->second; if (member_data && member_data->isInRole(mOwnerRole)) { return; // can't ban group owner @@ -832,8 +832,7 @@ void LLGroupMgrGroupData::banMemberById(const LLUUID& participant_uuid) // LLGroupMgr // -LLGroupMgr::LLGroupMgr(): - mMemberRequestInFlight(false) +LLGroupMgr::LLGroupMgr() { } @@ -968,11 +967,11 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id); if (!group_datap || (group_datap->mMemberRequestID != request_id)) { - LL_WARNS() << "processGroupMembersReply: Received incorrect (stale?) group or request id" << LL_ENDL; + LL_WARNS() << "Received incorrect (stale?) group or request id" << LL_ENDL; return; } - msg->getS32(_PREHASH_GroupData, "MemberCount", group_datap->mMemberCount ); + msg->getS32Fast(_PREHASH_GroupData, _PREHASH_MemberCount, group_datap->mMemberCount); if (group_datap->mMemberCount > 0) { @@ -987,12 +986,12 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) { LLUUID member_id; - msg->getUUIDFast(_PREHASH_MemberData, _PREHASH_AgentID, member_id, i ); - msg->getS32(_PREHASH_MemberData, _PREHASH_Contribution, contribution, i); - msg->getU64(_PREHASH_MemberData, "AgentPowers", agent_powers, i); + msg->getUUIDFast(_PREHASH_MemberData, _PREHASH_AgentID, member_id, i); + msg->getS32Fast(_PREHASH_MemberData, _PREHASH_Contribution, contribution, i); + msg->getU64Fast(_PREHASH_MemberData, _PREHASH_AgentPowers, agent_powers, i); msg->getStringFast(_PREHASH_MemberData, _PREHASH_OnlineStatus, online_status, i); - msg->getString(_PREHASH_MemberData, "Title", title, i); - msg->getBOOL(_PREHASH_MemberData,"IsOwner",is_owner,i); + msg->getStringFast(_PREHASH_MemberData, _PREHASH_Title, title, i); + msg->getBOOLFast(_PREHASH_MemberData, _PREHASH_IsOwner, is_owner, i); if (member_id.notNull()) { @@ -1037,7 +1036,7 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) group_datap->mMemberVersion.generate(); - if (group_datap->mMembers.size() == (U32)group_datap->mMemberCount) + if (group_datap->mMembers.size() == (U32)group_datap->mMemberCount) { group_datap->mMemberDataComplete = true; group_datap->mMemberRequestID.setNull(); @@ -1678,13 +1677,12 @@ void LLGroupMgr::sendGroupRoleMembersRequest(const LLUUID& group_id) if (group_datap->mRoleMembersRequestID.isNull()) { // Don't send the request if we don't have all the member or role data - if (!group_datap->isMemberDataComplete() - || !group_datap->isRoleDataComplete()) + if (!group_datap->isMemberDataComplete() || !group_datap->isRoleDataComplete()) { // *TODO: KLW FIXME: Should we start a member or role data request? LL_INFOS("GrpMgr") << " Pending: " << (group_datap->mPendingRoleMemberRequest ? "Y" : "N") - << " MemberDataComplete: " << (group_datap->mMemberDataComplete ? "Y" : "N") - << " RoleDataComplete: " << (group_datap->mRoleDataComplete ? "Y" : "N") << LL_ENDL; + << ", MemberDataComplete: " << (group_datap->mMemberDataComplete ? "Y" : "N") + << ", RoleDataComplete: " << (group_datap->mRoleDataComplete ? "Y" : "N") << LL_ENDL; group_datap->mPendingRoleMemberRequest = true; return; } @@ -1984,14 +1982,14 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, group_datap->mMemberVersion.generate(); } -void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) +void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID group_id) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - std::string finalUrl = url + "?group_id=" + groupId.asString(); + std::string finalUrl = url + "?group_id=" + group_id.asString(); LLSD result = httpAdapter->getAndSuspend(httpRequest, finalUrl); @@ -2012,8 +2010,8 @@ void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) } } -void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, - U32 action, uuid_vec_t banList, bool update) +void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID group_id, + U32 action, uuid_vec_t ban_list, bool update) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2026,20 +2024,16 @@ void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); - - std::string finalUrl = url + "?group_id=" + groupId.asString(); + std::string finalUrl = url + "?group_id=" + group_id.asString(); LLSD postData = LLSD::emptyMap(); postData["ban_action"] = (LLSD::Integer)action; // Add our list of potential banned residents to the list postData["ban_ids"] = LLSD::emptyArray(); - LLSD banEntry; - uuid_vec_t::const_iterator it = banList.begin(); - for (; it != banList.end(); ++it) + for (const LLUUID& ban_id : ban_list) { - banEntry = (*it); - postData["ban_ids"].append(banEntry); + postData["ban_ids"].append(ban_id); } LL_WARNS() << "post: " << ll_pretty_print_sd(postData) << LL_ENDL; @@ -2064,7 +2058,7 @@ void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, if (update) { - getGroupBanRequestCoro(url, groupId); + getGroupBanRequestCoro(url, group_id); } } @@ -2151,55 +2145,66 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } -void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID groupId) +void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, std::string sort_column) { + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "', sort_column: '" << sort_column << "', page_size: " << page_size << ", page_start: " << page_start << LL_ENDL; LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); - - mMemberRequestInFlight = true; + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); LLSD postData = LLSD::emptyMap(); - postData["group_id"] = groupId; + postData["group_id"] = group_id; + if (page_size) + { + postData["page_size"] = LLSD::Integer(page_size); + if (page_start) + { + postData["page_start"] = LLSD::Integer(page_start); + } + if (!sort_column.empty()) + { + postData["sort_column"] = sort_column; + } + } - LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData, httpOpts); + LLSD response = httpAdapter->postAndSuspend(httpRequest, url, postData, httpOpts); - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + mMemberRequestInFlight = false; + + LLSD httpResults = response.get(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { LL_WARNS("GrpMgr") << "Error receiving group member data " << LL_ENDL; - mMemberRequestInFlight = false; return; } - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - LLGroupMgr::processCapGroupMembersRequest(result); - mMemberRequestInFlight = false; + response.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + processCapGroupMembersResponse(response, page_size, page_start, sort_column); } -void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) +void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_size, U32 page_start, const std::string& sort_column) { static U32 lastGroupMemberRequestFrame = 0; // Have we requested the information already this frame? // Todo: make this per group, we can invite to one group and simultaneously be checking another one - if ((lastGroupMemberRequestFrame == gFrameCount) || (mMemberRequestInFlight)) + if ((lastGroupMemberRequestFrame == gFrameCount) || mMemberRequestInFlight) return; LLViewerRegion* currentRegion = gAgent.getRegion(); // Thank you FS:Ansariel! - if(!currentRegion) + if (!currentRegion) { LL_WARNS("GrpMgr") << "Agent does not have a current region. Uh-oh!" << LL_ENDL; return; } // Check to make sure we have our capabilities - if(!currentRegion->capabilitiesReceived()) + if (!currentRegion->capabilitiesReceived()) { LL_WARNS("GrpMgr") << " Capabilities not received!" << LL_ENDL; return; @@ -2209,9 +2214,9 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) std::string cap_url = currentRegion->getCapability("GroupMemberData"); // Thank you FS:Ansariel! - if(cap_url.empty()) + if (cap_url.empty()) { - LL_INFOS("GrpMgr") << "Region has no GroupMemberData capability. Falling back to UDP fetch." << LL_ENDL; + LL_INFOS("GrpMgr") << "Region has no GroupMemberData capability. Falling back to UDP fetch." << LL_ENDL; sendGroupMembersRequest(group_id); return; } @@ -2221,120 +2226,121 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) lastGroupMemberRequestFrame = gFrameCount; - LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", - boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, cap_url, group_id)); -} + mMemberRequestInFlight = true; + LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", [&]() + { + groupMembersRequestCoro(cap_url, group_id, page_size, page_start, sort_column); + }); +} -void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) +void LLGroupMgr::processCapGroupMembersResponse(const LLSD& response, U32 page_size, U32 page_start, const std::string& sort_column) { + LLUUID group_id = response["group_id"].asUUID(); + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "', sort_column: '" << sort_column << "', page_size: " << page_size << ", page_start: " << page_start << LL_ENDL; + // Did we get anything in content? - if(!content.size()) + if (!response.size()) { - LL_DEBUGS("GrpMgr") << "No group member data received." << LL_ENDL; + LL_INFOS("GrpMgr") << "No group member data received." << LL_ENDL; return; } - LLUUID group_id = content["group_id"].asUUID(); - LLGroupMgrGroupData* group_datap = getGroupData(group_id); - if(!group_datap) + if (!group_datap) { LL_WARNS("GrpMgr") << "Received incorrect, possibly stale, group or request id" << LL_ENDL; return; } - // If we have no members, there's no reason to do anything else - S32 num_members = content["member_count"]; - if (num_members < 1) - { - LL_INFOS("GrpMgr") << "Received empty group members list for group id: " << group_id.asString() << LL_ENDL; - // Set mMemberDataComplete for correct handling of empty responses. See MAINT-5237 - group_datap->mMemberDataComplete = true; - group_datap->mChanged = true; - LLGroupMgr::getInstance()->notifyObservers(GC_MEMBER_DATA); - return; - } - - group_datap->mMemberCount = num_members; + LLSD members = response["members"]; + LLSD titles = response["titles"]; + LLSD defaults = response["defaults"]; - LLSD member_list = content["members"]; - LLSD titles = content["titles"]; - LLSD defaults = content["defaults"]; - - std::string online_status; - std::string title; - S32 contribution; - U64 member_powers; - // If this is changed to a bool, make sure to change the LLGroupMemberData constructor - bool is_owner; + size_t members_before = group_datap->mMembers.size(); + size_t members_loaded = members.size(); // Compute this once, rather than every time. - U64 default_powers = llstrtou64(defaults["default_powers"].asString().c_str(), NULL, 16); + std::string default_title = titles.size() ? titles[0].asString() : LLStringUtil::null; + U64 default_powers = llstrtou64(defaults["default_powers"].asString().c_str(), NULL, 16); - LLSD::map_const_iterator member_iter_start = member_list.beginMap(); - LLSD::map_const_iterator member_iter_end = member_list.endMap(); - for( ; member_iter_start != member_iter_end; ++member_iter_start) + auto members_end = members.endMap(); + for (auto it = members.beginMap(); it != members_end; ++it) { // Reset defaults - online_status = "unknown"; - title = titles[0].asString(); - contribution = 0; - member_powers = default_powers; - is_owner = false; + std::string online_status = "unknown"; + std::string title = default_title; + U64 member_powers = default_powers; + S32 donated_square_meters = 0; + bool is_owner = false; - const LLUUID member_id(member_iter_start->first); - LLSD member_info = member_iter_start->second; + const LLUUID member_id(it->first); + LLSD member_info = it->second; - if(member_info.has("last_login")) + if (member_info.has("last_login")) { online_status = member_info["last_login"].asString(); - if(online_status == "Online") + if (online_status == "Online") + { online_status = LLTrans::getString("group_member_status_online"); + } else + { formatDateString(online_status); + } } - if(member_info.has("title")) + if (member_info.has("title")) + { title = titles[member_info["title"].asInteger()].asString(); + } - if(member_info.has("powers")) + if (member_info.has("powers")) + { member_powers = llstrtou64(member_info["powers"].asString().c_str(), NULL, 16); + } - if(member_info.has("donated_square_meters")) - contribution = member_info["donated_square_meters"]; + if (member_info.has("donated_square_meters")) + { + donated_square_meters = member_info["donated_square_meters"]; + } - if(member_info.has("owner")) + if (member_info.has("owner")) + { is_owner = true; + } LLGroupMemberData* data = new LLGroupMemberData(member_id, - contribution, - member_powers, - title, - online_status, - is_owner); - - LLGroupMemberData* member_old = group_datap->mMembers[member_id]; - if (member_old && group_datap->mRoleMemberDataComplete) - { - LLGroupMemberData::role_list_t::iterator rit = member_old->roleBegin(); - LLGroupMemberData::role_list_t::iterator end = member_old->roleEnd(); + donated_square_meters, member_powers, title, online_status, is_owner); - for ( ; rit != end; ++rit) + if (group_datap->mRoleMemberDataComplete) + { + if (LLGroupMemberData* member_old = group_datap->mMembers[member_id]) { - data->addRole((*rit).first,(*rit).second); + auto role_end = member_old->roleEnd(); + for (auto role_it = member_old->roleBegin(); role_it != role_end; ++role_it) + { + data->addRole(role_it->first, role_it->second); + } + } + else + { + group_datap->mRoleMemberDataComplete = false; } - } - else - { - group_datap->mRoleMemberDataComplete = false; } group_datap->mMembers[member_id] = data; } + group_datap->mMemberCount = (S32)group_datap->mMembers.size(); + group_datap->mMemberDataComplete = true; + group_datap->mMemberRequestID.setNull(); group_datap->mMemberVersion.generate(); + LL_INFOS("GrpMgr") << "members before: " << members_before + << ", members loaded: " << members_loaded + << ", members now: " << group_datap->mMemberCount << LL_ENDL; + // Technically, we have this data, but to prevent completely overhauling // this entire system (it would be nice, but I don't have the time), // I'm going to be dumb and just call services I most likely don't need @@ -2342,12 +2348,16 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) // // TODO: // Refactor to reduce multiple calls for data we already have. - if(group_datap->mTitles.size() < 1) + if (group_datap->mTitles.size() < 1) + { sendGroupTitlesRequest(group_id); + } + if (page_size && members_loaded >= page_size) + { + sendCapGroupMembersRequest(group_id, page_size, (U32)group_datap->mMemberCount, sort_column); + } - group_datap->mMemberDataComplete = true; - group_datap->mMemberRequestID.setNull(); // Make the role-member data request if (group_datap->mPendingRoleMemberRequest || !group_datap->mRoleMemberDataComplete) { @@ -2357,10 +2367,8 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) group_datap->mChanged = true; notifyObservers(GC_MEMBER_DATA); - } - void LLGroupMgr::sendGroupRoleChanges(const LLUUID& group_id) { LL_DEBUGS("GrpMgr") << "LLGroupMgr::sendGroupRoleChanges" << LL_ENDL; @@ -2379,9 +2387,11 @@ void LLGroupMgr::sendGroupRoleChanges(const LLUUID& group_id) void LLGroupMgr::cancelGroupRoleChanges(const LLUUID& group_id) { LL_DEBUGS("GrpMgr") << "LLGroupMgr::cancelGroupRoleChanges" << LL_ENDL; - LLGroupMgrGroupData* group_datap = getGroupData(group_id); - if (group_datap) group_datap->cancelRoleChanges(); + if (LLGroupMgrGroupData* group_datap = getGroupData(group_id)) + { + group_datap->cancelRoleChanges(); + } } //static @@ -2503,5 +2513,3 @@ void LLGroupMgr::debugClearAllGroups(void*) LLGroupMgr::getInstance()->clearGroups(); LLGroupMgr::parseRoleActions("role_actions.xml"); } - - diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 18efae7654..f96c5ccc14 100644 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -403,7 +403,7 @@ public: bool mature_publish); static void sendGroupMemberJoin(const LLUUID& group_id); - static void sendGroupMemberInvites(const LLUUID& group_id, std::map<LLUUID,LLUUID>& role_member_pairs); + static void sendGroupMemberInvites(const LLUUID& group_id, std::map<LLUUID, LLUUID>& role_member_pairs); static void sendGroupMemberEjects(const LLUUID& group_id, uuid_vec_t& member_ids); @@ -413,7 +413,8 @@ public: const uuid_vec_t &ban_list = uuid_vec_t()); - void sendCapGroupMembersRequest(const LLUUID& group_id); + void sendCapGroupMembersRequest(const LLUUID& group_id, + U32 page_size = 0, U32 page_start = 0, const std::string& sort_column = LLStringUtil::null); void cancelGroupRoleChanges(const LLUUID& group_id); @@ -436,16 +437,15 @@ public: void clearGroupData(const LLUUID& group_id); private: - void groupMembersRequestCoro(std::string url, LLUUID groupId); - void processCapGroupMembersRequest(const LLSD& content); + void groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, std::string sort_column); + void processCapGroupMembersResponse(const LLSD& response, U32 page_size, U32 page_start, const std::string& sort_column); - void getGroupBanRequestCoro(std::string url, LLUUID groupId); - void postGroupBanRequestCoro(std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); + void getGroupBanRequestCoro(std::string url, LLUUID group_id); + void postGroupBanRequestCoro(std::string url, LLUUID group_id, U32 action, uuid_vec_t ban_list, bool update); static void processGroupBanRequest(const LLSD& content); void notifyObservers(LLGroupChange gc); - void notifyObserver(const LLUUID& group_id, LLGroupChange gc); void addGroup(LLGroupMgrGroupData* group_datap); LLGroupMgrGroupData* createGroupData(const LLUUID &id); bool hasPendingPropertyRequest(const LLUUID& id); @@ -465,7 +465,7 @@ private: typedef std::map<LLUUID,observer_set_t> observer_map_t; observer_map_t mParticularObservers; - bool mMemberRequestInFlight; + bool mMemberRequestInFlight { false }; }; diff --git a/indra/newview/llpanelgroupbulk.cpp b/indra/newview/llpanelgroupbulk.cpp index f54ec45a3c..433db74cda 100644 --- a/indra/newview/llpanelgroupbulk.cpp +++ b/indra/newview/llpanelgroupbulk.cpp @@ -68,33 +68,36 @@ LLPanelGroupBulkImpl::LLPanelGroupBulkImpl(const LLUUID& group_id) : mAlreadyInGroup(), mConfirmedOwnerInvite(false), mListFullNotificationSent(false) -{} +{ +} LLPanelGroupBulkImpl::~LLPanelGroupBulkImpl() { - if(mAvatarNameCacheConnection.connected()) + if (mAvatarNameCacheConnection.connected()) { mAvatarNameCacheConnection.disconnect(); } } +// static void LLPanelGroupBulkImpl::callbackClickAdd(void* userdata) { - LLPanelGroupBulk* panelp = (LLPanelGroupBulk*)userdata; - - if(panelp) + if (LLPanelGroupBulk* panelp = (LLPanelGroupBulk*)userdata) { - //Right now this is hard coded with some knowledge that it is part - //of a floater since the avatar picker needs to be added as a dependent - //floater to the parent floater. - //Soon the avatar picker will be embedded into this panel - //instead of being it's own separate floater. But that is next week. - //This will do for now. -jwolk May 10, 2006 + // Right now this is hard coded with some knowledge that it is part + // of a floater since the avatar picker needs to be added as a dependent + // floater to the parent floater. + // Soon the avatar picker will be embedded into this panel + // instead of being it's own separate floater. But that is next week. + // This will do for now. -jwolk May 10, 2006 LLView* button = panelp->findChild<LLButton>("add_button"); LLFloater* root_floater = gFloaterView->getParentFloater(panelp); LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show( - boost::bind(callbackAddUsers, _1, panelp->mImplementation), true, false, false, root_floater->getName(), button); - if(picker) + [&](const uuid_vec_t& agent_ids, const std::vector<LLAvatarName>&) + { + panelp->mImplementation->addUsers(agent_ids); + }, true, false, false, root_floater->getName(), button); + if (picker) { root_floater->addDependentFloater(picker); LLGroupMgr::getInstance()->sendCapGroupMembersRequest(panelp->mImplementation->mGroupID); @@ -102,70 +105,72 @@ void LLPanelGroupBulkImpl::callbackClickAdd(void* userdata) } } +// static void LLPanelGroupBulkImpl::callbackClickRemove(void* userdata) { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata; - if (selfp) + if (LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata) + { selfp->handleRemove(); + } } +// static void LLPanelGroupBulkImpl::callbackClickCancel(void* userdata) { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata; - if(selfp) + if (LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata) + { (*(selfp->mCloseCallback))(selfp->mCloseCallbackUserData); + } } +// static void LLPanelGroupBulkImpl::callbackSelect(LLUICtrl* ctrl, void* userdata) { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata; - if (selfp) + if (LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata) + { selfp->handleSelection(); + } } -void LLPanelGroupBulkImpl::callbackAddUsers(const uuid_vec_t& agent_ids, void* user_data) +void LLPanelGroupBulkImpl::addUsers(const uuid_vec_t& agent_ids) { std::vector<std::string> names; - for (S32 i = 0; i < (S32)agent_ids.size(); i++) + for (const LLUUID& agent_id : agent_ids) { LLAvatarName av_name; - if (LLAvatarNameCache::get(agent_ids[i], &av_name)) + if (LLAvatarNameCache::get(agent_id, &av_name)) { - onAvatarNameCache(agent_ids[i], av_name, user_data); + onAvatarNameCache(agent_id, av_name); } else { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*) user_data; - if (selfp) + if (mAvatarNameCacheConnection.connected()) { - if (selfp->mAvatarNameCacheConnection.connected()) - { - selfp->mAvatarNameCacheConnection.disconnect(); - } - // *TODO : Add a callback per avatar name being fetched. - selfp->mAvatarNameCacheConnection = LLAvatarNameCache::get(agent_ids[i],boost::bind(onAvatarNameCache, _1, _2, user_data)); + mAvatarNameCacheConnection.disconnect(); } + // *TODO : Add a callback per avatar name being fetched. + mAvatarNameCacheConnection = LLAvatarNameCache::get(agent_id, + [&](const LLUUID& agent_id, const LLAvatarName& av_name) + { + onAvatarNameCache(agent_id, av_name); + }); } } } -void LLPanelGroupBulkImpl::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name, void* user_data) +void LLPanelGroupBulkImpl::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*) user_data; - - if (selfp) + if (mAvatarNameCacheConnection.connected()) { - if (selfp->mAvatarNameCacheConnection.connected()) - { - selfp->mAvatarNameCacheConnection.disconnect(); - } - std::vector<std::string> names; - uuid_vec_t agent_ids; - agent_ids.push_back(agent_id); - names.push_back(av_name.getCompleteName()); - - selfp->addUsers(names, agent_ids); + mAvatarNameCacheConnection.disconnect(); } + + std::vector<std::string> names; + uuid_vec_t agent_ids; + agent_ids.push_back(agent_id); + names.push_back(av_name.getCompleteName()); + + addUsers(names, agent_ids); } void LLPanelGroupBulkImpl::handleRemove() @@ -174,17 +179,15 @@ void LLPanelGroupBulkImpl::handleRemove() if (selection.empty()) return; - std::vector<LLScrollListItem*>::iterator iter; - for(iter = selection.begin(); iter != selection.end(); ++iter) + for (const LLScrollListItem* item : selection) { - mInviteeIDs.erase((*iter)->getUUID()); + mInviteeIDs.erase(item->getUUID()); } mBulkAgentList->deleteSelectedItems(); mRemoveButton->setEnabled(false); - if( mOKButton && mOKButton->getEnabled() && - mBulkAgentList->isEmpty()) + if (mOKButton && mOKButton->getEnabled() && mBulkAgentList->isEmpty()) { mOKButton->setEnabled(false); } @@ -192,24 +195,17 @@ void LLPanelGroupBulkImpl::handleRemove() void LLPanelGroupBulkImpl::handleSelection() { - std::vector<LLScrollListItem*> selection = mBulkAgentList->getAllSelected(); - if (selection.empty()) - mRemoveButton->setEnabled(false); - else - mRemoveButton->setEnabled(true); + mRemoveButton->setEnabled(mBulkAgentList->getFirstSelected()); } void LLPanelGroupBulkImpl::addUsers(const std::vector<std::string>& names, const uuid_vec_t& agent_ids) { - std::string name; - LLUUID id; - - if(mListFullNotificationSent) + if (mListFullNotificationSent) { return; } - if( !mListFullNotificationSent && + if (!mListFullNotificationSent && (names.size() + mInviteeIDs.size() > MAX_GROUP_INVITES)) { mListFullNotificationSent = true; @@ -223,32 +219,35 @@ void LLPanelGroupBulkImpl::addUsers(const std::vector<std::string>& names, const for (S32 i = 0; i < (S32)names.size(); ++i) { - name = names[i]; - id = agent_ids[i]; + const LLUUID& id = agent_ids[i]; - if(mInviteeIDs.find(id) != mInviteeIDs.end()) + if (mInviteeIDs.find(id) != mInviteeIDs.end()) { continue; } - //add the name to the names list + // Add the name to the name list LLSD row; row["id"] = id; - row["columns"][0]["value"] = name; + row["columns"][0]["value"] = names[i]; mBulkAgentList->addElement(row); mInviteeIDs.insert(id); // We've successfully added someone to the list. - if(mOKButton && !mOKButton->getEnabled()) + if (mOKButton && !mOKButton->getEnabled()) + { mOKButton->setEnabled(true); + } } } void LLPanelGroupBulkImpl::setGroupName(std::string name) { - if(mGroupName) + if (mGroupName) + { mGroupName->setText(name); + } } @@ -258,7 +257,8 @@ LLPanelGroupBulk::LLPanelGroupBulk(const LLUUID& group_id) : mPendingGroupPropertiesUpdate(false), mPendingRoleDataUpdate(false), mPendingMemberDataUpdate(false) -{} +{ +} LLPanelGroupBulk::~LLPanelGroupBulk() { @@ -269,11 +269,15 @@ void LLPanelGroupBulk::clear() { mImplementation->mInviteeIDs.clear(); - if(mImplementation->mBulkAgentList) + if (mImplementation->mBulkAgentList) + { mImplementation->mBulkAgentList->deleteAllItems(); + } - if(mImplementation->mOKButton) + if (mImplementation->mOKButton) + { mImplementation->mOKButton->setEnabled(false); + } } void LLPanelGroupBulk::update() @@ -292,12 +296,14 @@ void LLPanelGroupBulk::updateGroupName() { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); - if( gdatap && + if (gdatap && gdatap->isGroupPropertiesDataComplete()) { // Only do work if the current group name differs - if(mImplementation->mGroupName->getText().compare(gdatap->mName) != 0) + if (mImplementation->mGroupName->getText().compare(gdatap->mName) != 0) + { mImplementation->setGroupName(gdatap->mName); + } } else { @@ -308,43 +314,34 @@ void LLPanelGroupBulk::updateGroupName() void LLPanelGroupBulk::updateGroupData() { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); - if(gdatap && gdatap->isGroupPropertiesDataComplete()) + if (gdatap && gdatap->isGroupPropertiesDataComplete()) { mPendingGroupPropertiesUpdate = false; } - else + else if (!mPendingGroupPropertiesUpdate) { - if(!mPendingGroupPropertiesUpdate) - { - mPendingGroupPropertiesUpdate = true; - LLGroupMgr::getInstance()->sendGroupPropertiesRequest(mImplementation->mGroupID); - } + mPendingGroupPropertiesUpdate = true; + LLGroupMgr::getInstance()->sendGroupPropertiesRequest(mImplementation->mGroupID); } - if(gdatap && gdatap->isRoleDataComplete()) + if (gdatap && gdatap->isRoleDataComplete()) { mPendingRoleDataUpdate = false; } - else + else if (!mPendingRoleDataUpdate) { - if(!mPendingRoleDataUpdate) - { - mPendingRoleDataUpdate = true; - LLGroupMgr::getInstance()->sendGroupRoleDataRequest(mImplementation->mGroupID); - } + mPendingRoleDataUpdate = true; + LLGroupMgr::getInstance()->sendGroupRoleDataRequest(mImplementation->mGroupID); } - if(gdatap && gdatap->isMemberDataComplete()) + if (gdatap && gdatap->isMemberDataComplete()) { mPendingMemberDataUpdate = false; } - else + else if (!mPendingMemberDataUpdate) { - if(!mPendingMemberDataUpdate) - { - mPendingMemberDataUpdate = true; - LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mImplementation->mGroupID); - } + mPendingMemberDataUpdate = true; + LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mImplementation->mGroupID); } } @@ -367,21 +364,20 @@ void LLPanelGroupBulk::setCloseCallback(void (*close_callback)(void*), void* dat void LLPanelGroupBulk::addUsers(uuid_vec_t& agent_ids) { std::vector<std::string> names; - for (S32 i = 0; i < (S32)agent_ids.size(); i++) + for (size_t i = 0; i < agent_ids.size(); i++) { std::string fullname; - LLUUID agent_id = agent_ids[i]; + const LLUUID& agent_id = agent_ids[i]; LLViewerObject* dest = gObjectList.findObject(agent_id); - if(dest && dest->isAvatar()) + if (dest && dest->isAvatar()) { LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); - if(nvfirst && nvlast) + if (nvfirst && nvlast) { - fullname = LLCacheName::buildFullName( - nvfirst->getString(), nvlast->getString()); - + fullname = LLCacheName::buildFullName(nvfirst->getString(), nvlast->getString()); } + if (!fullname.empty()) { names.push_back(fullname); @@ -394,20 +390,25 @@ void LLPanelGroupBulk::addUsers(uuid_vec_t& agent_ids) } else { - //looks like user try to invite offline friend - //for offline avatar_id gObjectList.findObject() will return null - //so we need to do this additional search in avatar tracker, see EXT-4732 + // Looks like the user tries to invite a friend which is offline. + // For offline avatar_id gObjectList.findObject() will return null + // so we need to do this additional search in avatar tracker, see EXT-4732 if (LLAvatarTracker::instance().isBuddy(agent_id)) { LLAvatarName av_name; if (!LLAvatarNameCache::get(agent_id, &av_name)) { - // actually it should happen, just in case - LLAvatarNameCache::get(LLUUID(agent_id), boost::bind(&LLPanelGroupBulk::addUserCallback, this, _1, _2)); + // Actually it shouldn't happen, just in case + LLAvatarNameCache::get(LLUUID(agent_id), + [&](const LLUUID& agent_id, const LLAvatarName& av_name) + { + addUserCallback(agent_id, av_name); + }); // for this special case! - //when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence + // when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence // removed id will be added in callback agent_ids.erase(agent_ids.begin() + i); + i--; // To process the next agent_id with the same index } else { diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 963780200a..5a479f8117 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -50,9 +50,10 @@ public: static void callbackClickCancel(void* userdata); static void callbackSelect(LLUICtrl* ctrl, void* userdata); - static void callbackAddUsers(const uuid_vec_t& agent_ids, void* user_data); - static void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name, void* user_data); + void addUsers(const uuid_vec_t& agent_ids); + + void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); void handleRemove(); void handleSelection(); diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index bc56b49e5d..864d73683e 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -812,20 +812,14 @@ bool LLPanelGroupMembersSubTab::postBuildSubTab(LLView* root) { LLPanelGroupSubTab::postBuildSubTab(root); - // Upcast parent so we can ask it for sibling controls. - LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root; - // Look recursively from the parent to find all our widgets. - bool recurse = true; - mHeader = parent->findChild<LLPanel>("members_header", recurse); - mFooter = parent->findChild<LLPanel>("members_footer", recurse); - - mMembersList = parent->getChild<LLNameListCtrl>("member_list", recurse); - mAssignedRolesList = parent->getChild<LLScrollListCtrl>("member_assigned_roles", recurse); - mAllowedActionsList = parent->getChild<LLScrollListCtrl>("member_allowed_actions", recurse); - mActionDescription = parent->getChild<LLTextEditor>("member_action_description", recurse); + mHeader = root->findChild<LLPanel>("members_header"); + mFooter = root->findChild<LLPanel>("members_footer"); - if (!mMembersList || !mAssignedRolesList || !mAllowedActionsList || !mActionDescription) return false; + mMembersList = root->getChild<LLNameListCtrl>("member_list"); + mAssignedRolesList = root->getChild<LLScrollListCtrl>("member_assigned_roles"); + mAllowedActionsList = root->getChild<LLScrollListCtrl>("member_allowed_actions"); + mActionDescription = root->getChild<LLTextEditor>("member_action_description"); mAllowedActionsList->setCommitOnSelectionChange(true); mAllowedActionsList->setCommitCallback(boost::bind(&LLPanelGroupMembersSubTab::updateActionDescription, this)); @@ -844,31 +838,22 @@ bool LLPanelGroupMembersSubTab::postBuildSubTab(LLView* root) row["columns"][2]["column"] = "online"; mMembersList->addElement(row); std::string order_by = gSavedSettings.getString("GroupMembersSortOrder"); - if(!order_by.empty()) + if (!order_by.empty()) { mMembersList->sortByColumn(order_by, true); } - LLButton* button = parent->getChild<LLButton>("member_invite", recurse); - if ( button ) - { - button->setClickedCallback(onInviteMember, this); - button->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_MEMBER_INVITE)); - } + LLButton* button = root->getChild<LLButton>("member_invite"); + button->setClickedCallback(onInviteMember, this); + button->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_MEMBER_INVITE)); - mEjectBtn = parent->getChild<LLButton>("member_eject", recurse); - if ( mEjectBtn ) - { - mEjectBtn->setClickedCallback(onEjectMembers, this); - mEjectBtn->setEnabled(false); - } + mEjectBtn = root->getChild<LLButton>("member_eject"); + mEjectBtn->setClickedCallback(onEjectMembers, this); + mEjectBtn->setEnabled(false); - mBanBtn = parent->getChild<LLButton>("member_ban", recurse); - if(mBanBtn) - { - mBanBtn->setClickedCallback(onBanMember, this); - mBanBtn->setEnabled(false); - } + mBanBtn = root->getChild<LLButton>("member_ban"); + mBanBtn->setClickedCallback(onBanMember, this); + mBanBtn->setEnabled(false); return true; } @@ -1371,11 +1356,13 @@ void LLPanelGroupMembersSubTab::activate() LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); LLPanelGroupSubTab::activate(); - if(!mActivated) + if (!mActivated) { if (!gdatap || !gdatap->isMemberDataComplete()) { - LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID); + const U32 page_size = 50; + std::string sort_column = mMembersList->getSortColumnName(); + LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID, page_size, 0, sort_column); } if (!gdatap || !gdatap->isRoleMemberDataComplete()) @@ -1483,8 +1470,7 @@ bool LLPanelGroupMembersSubTab::addOwnerCB(const LLSD& notification, const LLSD& void LLPanelGroupMembersSubTab::applyMemberChanges() { - //sucks to do a find again here, but it is in constant time, so, could - //be worse + // Sucks to do a find again here, but it is in constant time, so, could be worse LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); if (!gdatap) { @@ -1492,8 +1478,7 @@ void LLPanelGroupMembersSubTab::applyMemberChanges() return; } - //we need to add all of the changed roles data - //for each member whose role changed + // We need to add all of the changed roles data for each member whose role changed for (member_role_changes_map_t::iterator member = mMemberRoleChangeData.begin(); member != mMemberRoleChangeData.end(); ++member) { @@ -1511,7 +1496,7 @@ void LLPanelGroupMembersSubTab::applyMemberChanges() mMemberRoleChangeData.clear(); LLGroupMgr::getInstance()->sendGroupRoleMemberChanges(mGroupID); - //force a UI update + // Force an UI update handleMemberSelect(); mChanged = false; @@ -1522,32 +1507,23 @@ void LLPanelGroupMembersSubTab::applyMemberChanges() bool LLPanelGroupMembersSubTab::matchesSearchFilter(const std::string& fullname) { // If the search filter is empty, everything passes. - if (mSearchFilter.empty()) return true; + if (mSearchFilter.empty()) + return true; // Create a full name, and compare it to the search filter. std::string fullname_lc(fullname); LLStringUtil::toLower(fullname_lc); std::string::size_type match = fullname_lc.find(mSearchFilter); - - if (std::string::npos == match) - { - // not found - return false; - } - else - { - return true; - } + return match != std::string::npos; } U64 LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges(const LLUUID& agent_id) { - //we loop over all of the changes - //if we are adding a role, then we simply add the role's powers - //if we are removing a role, we store that role id away - //and then we have to build the powers up bases on the roles the agent - //is in + // We loop over all of the changes + // If we are adding a role, then we simply add the role's powers + // If we are removing a role, we store that role id away + // and then we have to build the powers up bases on the roles the agent is in LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); if (!gdatap) @@ -1557,7 +1533,7 @@ U64 LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges(const LLUUID& ag } LLGroupMgrGroupData::member_list_t::iterator iter = gdatap->mMembers.find(agent_id); - if ( iter == gdatap->mMembers.end() ) + if (iter == gdatap->mMembers.end()) { LL_WARNS() << "LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges() -- No member data for member with UUID " << agent_id << LL_ENDL; return GP_NO_POWERS; @@ -1570,37 +1546,36 @@ U64 LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges(const LLUUID& ag return GP_NO_POWERS; } - //see if there are unsaved role changes for this agent + // See if there are unsaved role changes for this agent role_change_data_map_t* role_change_datap = NULL; member_role_changes_map_t::iterator member = mMemberRoleChangeData.find(agent_id); - if ( member != mMemberRoleChangeData.end() ) + if (member != mMemberRoleChangeData.end()) { - //this member has unsaved role changes - //so grab them - role_change_datap = (*member).second; + // This member has unsaved role changes + // so grab them + role_change_datap = member->second; } U64 new_powers = GP_NO_POWERS; - if ( role_change_datap ) + if (role_change_datap) { uuid_vec_t roles_to_be_removed; - for (role_change_data_map_t::iterator role = role_change_datap->begin(); - role != role_change_datap->end(); ++ role) + for (const auto& role : *role_change_datap) { - if ( role->second == RMC_ADD ) + if (role.second == RMC_ADD) { - new_powers |= gdatap->getRolePowers(role->first); + new_powers |= gdatap->getRolePowers(role.first); } else { - roles_to_be_removed.push_back(role->first); + roles_to_be_removed.push_back(role.first); } } - //loop over the member's current roles, summing up - //the powers (not including the role we are removing) + // loop over the member's current roles, summing up + // the powers (not including the role we are removing) for (LLGroupMemberData::role_list_t::iterator current_role = member_data->roleBegin(); current_role != member_data->roleEnd(); ++current_role) { @@ -1661,9 +1636,10 @@ void LLPanelGroupMembersSubTab::draw() void LLPanelGroupMembersSubTab::update(LLGroupChange gc) { - if (mGroupID.isNull()) return; + if (mGroupID.isNull()) + return; - if ( GC_TITLES == gc || GC_PROPERTIES == gc ) + if (GC_TITLES == gc || GC_PROPERTIES == gc) { // Don't care about title or general group properties updates. return; @@ -1677,9 +1653,9 @@ void LLPanelGroupMembersSubTab::update(LLGroupChange gc) } // Wait for both all data to be retrieved before displaying anything. - if ( gdatap->isMemberDataComplete() - && gdatap->isRoleDataComplete() - && gdatap->isRoleMemberDataComplete()) + if (gdatap->isMemberDataComplete() && + gdatap->isRoleDataComplete() && + gdatap->isRoleMemberDataComplete()) { mMemberProgress = gdatap->mMembers.begin(); mPendingMemberUpdate = true; @@ -1690,18 +1666,18 @@ void LLPanelGroupMembersSubTab::update(LLGroupChange gc) // Build a string with info on retrieval progress. std::ostringstream retrieved; - if ( gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete() && !gdatap->mMembers.size() ) + if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete() && !gdatap->mMembers.size()) { // MAINT-5237 retrieved << "Member list not available."; } - else if ( !gdatap->isMemberDataComplete() ) + else if (!gdatap->isMemberDataComplete()) { // Still busy retreiving member list. retrieved << "Retrieving member list (" << gdatap->mMembers.size() << " / " << gdatap->mMemberCount << ")..."; } - else if( !gdatap->isRoleDataComplete() ) + else if (!gdatap->isRoleDataComplete()) { // Still busy retreiving role list. retrieved << "Retrieving role list (" << gdatap->mRoles.size() @@ -1719,7 +1695,9 @@ void LLPanelGroupMembersSubTab::update(LLGroupChange gc) void LLPanelGroupMembersSubTab::addMemberToList(LLGroupMemberData* data) { - if (!data) return; + if (!data) + return; + LLUIString donated = getString("donation_area"); donated.setArg("[AREA]", llformat("%d", data->getContribution())); @@ -1765,7 +1743,7 @@ void LLPanelGroupMembersSubTab::onNameCache(const LLUUID& update_id, LLGroupMemb if (matchesSearchFilter(av_name.getAccountName())) { addMemberToList(member); - if(!mMembersList->getEnabled()) + if (!mMembersList->getEnabled()) { mMembersList->setEnabled(true); } @@ -1788,15 +1766,15 @@ void LLPanelGroupMembersSubTab::updateMembers() // Make sure all data is still complete. Incomplete data // may occur if we refresh. - if ( !gdatap->isMemberDataComplete() - || !gdatap->isRoleDataComplete() - || !gdatap->isRoleMemberDataComplete()) + if (!gdatap->isMemberDataComplete() || + !gdatap->isRoleDataComplete() || + !gdatap->isRoleMemberDataComplete()) { return; } - //cleanup list only for first iteration - if(mMemberProgress == gdatap->mMembers.begin()) + // Cleanup list only for first iteration + if (mMemberProgress == gdatap->mMembers.begin()) { mMembersList->deleteAllItems(); } @@ -1806,7 +1784,7 @@ void LLPanelGroupMembersSubTab::updateMembers() LLTimer update_time; update_time.setTimerExpirySec(UPDATE_MEMBERS_SECONDS_PER_FRAME); - for( ; mMemberProgress != end && !update_time.hasExpired(); ++mMemberProgress) + for (; mMemberProgress != end && !update_time.hasExpired(); ++mMemberProgress) { if (!mMemberProgress->second) continue; @@ -1866,7 +1844,8 @@ void LLPanelGroupMembersSubTab::onBanMember(void* user_data) void LLPanelGroupMembersSubTab::confirmBanMembers() { std::vector<LLScrollListItem*> selection = mMembersList->getAllSelected(); - if (selection.empty()) return; + if (selection.empty()) + return; auto selection_count = selection.size(); if (selection_count == 1) @@ -1912,8 +1891,7 @@ void LLPanelGroupMembersSubTab::updateActionDescription() return; } - LLRoleAction* rap = (LLRoleAction*)action_item->getUserdata(); - if (rap) + if (LLRoleAction* rap = (LLRoleAction*)action_item->getUserdata()) { std::string desc = rap->mLongDescription.empty() ? rap->mDescription : rap->mLongDescription; mActionDescription->setText(desc); @@ -1923,23 +1901,22 @@ void LLPanelGroupMembersSubTab::updateActionDescription() void LLPanelGroupMembersSubTab::handleBanMember() { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); - if(!gdatap) + if (!gdatap) { LL_WARNS("Groups") << "Unable to get group data for group " << mGroupID << LL_ENDL; return; } std::vector<LLScrollListItem*> selection = mMembersList->getAllSelected(); - if(selection.empty()) + if (selection.empty()) { return; } uuid_vec_t ban_ids; - std::vector<LLScrollListItem*>::iterator itor; - for(itor = selection.begin(); itor != selection.end(); ++itor) + for (const LLScrollListItem* item : selection) { - LLUUID ban_id = (*itor)->getUUID(); + LLUUID ban_id = item->getUUID(); ban_ids.push_back(ban_id); LLGroupBanData ban_data; @@ -1983,54 +1960,33 @@ bool LLPanelGroupRolesSubTab::postBuildSubTab(LLView* root) LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root; // Look recursively from the parent to find all our widgets. - bool recurse = true; - mHeader = parent->findChild<LLPanel>("roles_header", recurse); - mFooter = parent->findChild<LLPanel>("roles_footer", recurse); - - - mRolesList = parent->getChild<LLScrollListCtrl>("role_list", recurse); - mAssignedMembersList = parent->getChild<LLNameListCtrl>("role_assigned_members", recurse); - mAllowedActionsList = parent->getChild<LLScrollListCtrl>("role_allowed_actions", recurse); - mActionDescription = parent->getChild<LLTextEditor>("role_action_description", recurse); + mHeader = parent->findChild<LLPanel>("roles_header"); + mFooter = parent->findChild<LLPanel>("roles_footer"); - mRoleName = parent->getChild<LLLineEditor>("role_name", recurse); - mRoleTitle = parent->getChild<LLLineEditor>("role_title", recurse); - mRoleDescription = parent->getChild<LLTextEditor>("role_description", recurse); + mRolesList = parent->getChild<LLScrollListCtrl>("role_list"); + mAssignedMembersList = parent->getChild<LLNameListCtrl>("role_assigned_members"); + mAllowedActionsList = parent->getChild<LLScrollListCtrl>("role_allowed_actions"); + mActionDescription = parent->getChild<LLTextEditor>("role_action_description"); - mMemberVisibleCheck = parent->getChild<LLCheckBoxCtrl>("role_visible_in_list", recurse); + mRoleName = parent->getChild<LLLineEditor>("role_name"); + mRoleTitle = parent->getChild<LLLineEditor>("role_title"); + mRoleDescription = parent->getChild<LLTextEditor>("role_description"); - if (!mRolesList || !mAssignedMembersList || !mAllowedActionsList || !mActionDescription - || !mRoleName || !mRoleTitle || !mRoleDescription || !mMemberVisibleCheck) - { - LL_WARNS() << "ARG! element not found." << LL_ENDL; - return false; - } + mMemberVisibleCheck = parent->getChild<LLCheckBoxCtrl>("role_visible_in_list"); mRemoveEveryoneTxt = getString("cant_delete_role"); - mCreateRoleButton = - parent->getChild<LLButton>("role_create", recurse); - if ( mCreateRoleButton ) - { - mCreateRoleButton->setClickedCallback(onCreateRole, this); - mCreateRoleButton->setEnabled(false); - } + mCreateRoleButton = parent->getChild<LLButton>("role_create"); + mCreateRoleButton->setClickedCallback(onCreateRole, this); + mCreateRoleButton->setEnabled(false); - mCopyRoleButton = - parent->getChild<LLButton>("role_copy", recurse); - if ( mCopyRoleButton ) - { - mCopyRoleButton->setClickedCallback(onCopyRole, this); - mCopyRoleButton->setEnabled(false); - } + mCopyRoleButton = parent->getChild<LLButton>("role_copy"); + mCopyRoleButton->setClickedCallback(onCopyRole, this); + mCopyRoleButton->setEnabled(false); - mDeleteRoleButton = - parent->getChild<LLButton>("role_delete", recurse); - if ( mDeleteRoleButton ) - { - mDeleteRoleButton->setClickedCallback(onDeleteRole, this); - mDeleteRoleButton->setEnabled(false); - } + mDeleteRoleButton = parent->getChild<LLButton>("role_delete"); + mDeleteRoleButton->setClickedCallback(onDeleteRole, this); + mDeleteRoleButton->setEnabled(false); mRolesList->setCommitOnSelectionChange(true); mRolesList->setCommitCallback(onRoleSelect, this); @@ -2949,26 +2905,19 @@ void LLPanelGroupActionsSubTab::handleActionSelect() mActionMembers->deleteAllItems(); mActionRoles->deleteAllItems(); - U64 power_mask = GP_NO_POWERS; - std::vector<LLScrollListItem*> selection = - mActionList->getAllSelected(); - if (selection.empty()) return; - - LLRoleAction* rap; + std::vector<LLScrollListItem*> selection = mActionList->getAllSelected(); + if (selection.empty()) + return; - std::vector<LLScrollListItem*>::iterator itor; - for (itor = selection.begin() ; - itor != selection.end(); ++itor) + U64 power_mask = GP_NO_POWERS; + for (const LLScrollListItem* item : selection) { - rap = (LLRoleAction*)( (*itor)->getUserdata() ); - power_mask |= rap->mPowerBit; + power_mask |= ((LLRoleAction*)item->getUserdata())->mPowerBit; } if (selection.size() == 1) { - LLScrollListItem* item = selection[0]; - rap = (LLRoleAction*)(item->getUserdata()); - + LLRoleAction* rap = (LLRoleAction*)selection.front()->getUserdata(); if (rap->mLongDescription.empty()) { mActionDescription->setText(rap->mDescription); @@ -2985,21 +2934,19 @@ void LLPanelGroupActionsSubTab::handleActionSelect() LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); - if (!gdatap) return; + if (!gdatap) + return; if (gdatap->isMemberDataComplete()) { - LLGroupMgrGroupData::member_list_t::iterator it = gdatap->mMembers.begin(); - LLGroupMgrGroupData::member_list_t::iterator end = gdatap->mMembers.end(); - LLGroupMemberData* gmd; - - for ( ; it != end; ++it) + for (const auto& it : gdatap->mMembers) { - gmd = (*it).second; - if (!gmd) continue; - if ((gmd->getAgentPowers() & power_mask) == power_mask) + if (LLGroupMemberData* gmd = it.second) { - mActionMembers->addNameItem(gmd->getID()); + if ((gmd->getAgentPowers() & power_mask) == power_mask) + { + mActionMembers->addNameItem(gmd->getID()); + } } } } |