summaryrefslogtreecommitdiff
path: root/indra/newview/llparticipantlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llparticipantlist.cpp')
-rw-r--r--indra/newview/llparticipantlist.cpp98
1 files changed, 94 insertions, 4 deletions
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index edff706fee..94e47318de 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -50,13 +50,16 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* av
mSpeakerAddListener = new SpeakerAddListener(*this);
mSpeakerRemoveListener = new SpeakerRemoveListener(*this);
mSpeakerClearListener = new SpeakerClearListener(*this);
+ mSpeakerModeratorListener = new SpeakerModeratorUpdateListener(*this);
mSpeakerMgr->addListener(mSpeakerAddListener, "add");
mSpeakerMgr->addListener(mSpeakerRemoveListener, "remove");
mSpeakerMgr->addListener(mSpeakerClearListener, "clear");
+ mSpeakerMgr->addListener(mSpeakerModeratorListener, "update_moderator");
mAvatarList->setNoItemsCommentText(LLTrans::getString("LoadingData"));
mAvatarList->setDoubleClickCallback(boost::bind(&LLParticipantList::onAvatarListDoubleClicked, this, mAvatarList));
+ mAvatarList->setRefreshCompleteCallback(boost::bind(&LLParticipantList::onAvatarListRefreshed, this, _1, _2));
//Lets fill avatarList with existing speakers
LLAvatarList::uuid_vector_t& group_members = mAvatarList->getIDs();
@@ -65,7 +68,12 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* av
mSpeakerMgr->getSpeakerList(&speaker_list, true);
for(LLSpeakerMgr::speaker_list_t::iterator it = speaker_list.begin(); it != speaker_list.end(); it++)
{
- group_members.push_back((*it)->mID);
+ const LLPointer<LLSpeaker>& speakerp = *it;
+ group_members.push_back(speakerp->mID);
+ if ( speakerp->mIsModerator )
+ {
+ mModeratorList.insert(speakerp->mID);
+ }
}
sort();
}
@@ -84,6 +92,56 @@ void LLParticipantList::onAvatarListDoubleClicked(LLAvatarList* list)
LLAvatarActions::startIM(clicked_id);
}
+void LLParticipantList::onAvatarListRefreshed(LLUICtrl* ctrl, const LLSD& param)
+{
+ LLAvatarList* list = dynamic_cast<LLAvatarList*>(ctrl);
+ if (list)
+ {
+ const std::string moderator_indicator(LLTrans::getString("IM_moderator_label"));
+ const std::size_t moderator_indicator_len = moderator_indicator.length();
+
+ // Firstly remove moderators indicator
+ std::set<LLUUID>::const_iterator
+ moderator_list_it = mModeratorToRemoveList.begin(),
+ moderator_list_end = mModeratorToRemoveList.end();
+ for (;moderator_list_it != moderator_list_end; ++moderator_list_it)
+ {
+ LLAvatarListItem* item = dynamic_cast<LLAvatarListItem*> (list->getItemByValue(*moderator_list_it));
+ if ( item )
+ {
+ std::string name = item->getAvatarName();
+ size_t found = name.find(moderator_indicator);
+ if (found == std::string::npos)
+ {
+ name.erase(found, moderator_indicator_len);
+ item->setName(name);
+ }
+ }
+ }
+
+ mModeratorToRemoveList.clear();
+
+ // Add moderators indicator
+ moderator_list_it = mModeratorList.begin();
+ moderator_list_end = mModeratorList.end();
+ for (;moderator_list_it != moderator_list_end; ++moderator_list_it)
+ {
+ LLAvatarListItem* item = dynamic_cast<LLAvatarListItem*> (list->getItemByValue(*moderator_list_it));
+ if ( item )
+ {
+ std::string name = item->getAvatarName();
+ size_t found = name.find(moderator_indicator);
+ if (found == std::string::npos)
+ {
+ name += " ";
+ name += moderator_indicator;
+ item->setName(name);
+ }
+ }
+ }
+ }
+}
+
void LLParticipantList::setSortOrder(EParticipantSortOrder order)
{
if ( mSortOrder != order )
@@ -106,6 +164,8 @@ bool LLParticipantList::onAddItemEvent(LLPointer<LLOldEvents::LLEvent> event, co
}
group_members.push_back(uu_id);
+ // Mark AvatarList as dirty one
+ mAvatarList->setDirty();
sort();
return true;
}
@@ -130,14 +190,36 @@ bool LLParticipantList::onClearListEvent(LLPointer<LLOldEvents::LLEvent> event,
return true;
}
+bool LLParticipantList::onModeratorUpdateEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata)
+{
+ const LLSD& evt_data = event->getValue();
+ if ( evt_data.has("id") && evt_data.has("is_moderator") )
+ {
+ LLUUID id = evt_data["id"];
+ bool is_moderator = evt_data["is_moderator"];
+ if ( id.notNull() )
+ {
+ if ( is_moderator )
+ mModeratorList.insert(id);
+ else
+ {
+ std::set<LLUUID>::iterator it = mModeratorList.find (id);
+ if ( it != mModeratorList.end () )
+ {
+ mModeratorToRemoveList.insert(id);
+ mModeratorList.erase(id);
+ }
+ }
+ }
+ }
+ return true;
+}
+
void LLParticipantList::sort()
{
if ( !mAvatarList )
return;
- // Mark AvatarList as dirty one
- mAvatarList->setDirty();
-
// TODO: Implement more sorting orders after specs updating (EM)
switch ( mSortOrder ) {
case E_SORT_BY_NAME :
@@ -172,3 +254,11 @@ bool LLParticipantList::SpeakerClearListener::handleEvent(LLPointer<LLOldEvents:
{
return mParent.onClearListEvent(event, userdata);
}
+
+//
+// LLParticipantList::SpeakerModeratorListener
+//
+bool LLParticipantList::SpeakerModeratorUpdateListener::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata)
+{
+ return mParent.onModeratorUpdateEvent(event, userdata);
+}