diff options
Diffstat (limited to 'indra/newview/llparticipantlist.cpp')
-rw-r--r-- | indra/newview/llparticipantlist.cpp | 110 |
1 files changed, 81 insertions, 29 deletions
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp index e97eb1df2b..9450bee315 100644 --- a/indra/newview/llparticipantlist.cpp +++ b/indra/newview/llparticipantlist.cpp @@ -32,6 +32,11 @@ #include "llviewerprecompiledheaders.h" +// common includes +#include "lltrans.h" +#include "llavataractions.h" +#include "llagent.h" + #include "llparticipantlist.h" #include "llavatarlist.h" #include "llspeakers.h" @@ -39,15 +44,18 @@ //LLParticipantList retrieves add, clear and remove events and updates view accordingly LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* avatar_list): mSpeakerMgr(data_source), - mAvatarList(avatar_list) + mAvatarList(avatar_list), + mSpeakerAddListener(*this), + mSpeakerRemoveListener(*this), + mSpeakerClearListener(*this), + mSortOrder(E_SORT_BY_NAME) { - mSpeakerAddListener = new SpeakerAddListener(mAvatarList); - mSpeakerRemoveListener = new SpeakerRemoveListener(mAvatarList); - mSpeakerClearListener = new SpeakerClearListener(mAvatarList); + mSpeakerMgr->addListener(&mSpeakerAddListener, "add"); + mSpeakerMgr->addListener(&mSpeakerRemoveListener, "remove"); + mSpeakerMgr->addListener(&mSpeakerClearListener, "clear"); - mSpeakerMgr->addListener(mSpeakerAddListener, "add"); - mSpeakerMgr->addListener(mSpeakerRemoveListener, "remove"); - mSpeakerMgr->addListener(mSpeakerClearListener, "clear"); + mAvatarList->setNoItemsCommentText(LLTrans::getString("LoadingData")); + mAvatarList->setDoubleClickCallback(boost::bind(&LLParticipantList::onAvatarListDoubleClicked, this, mAvatarList)); //Lets fill avatarList with existing speakers LLAvatarList::uuid_vector_t& group_members = mAvatarList->getIDs(); @@ -58,24 +66,33 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* av { group_members.push_back((*it)->mID); } - mAvatarList->setDirty(); - mAvatarList->sortByName(); + sort(); } LLParticipantList::~LLParticipantList() { - delete mSpeakerAddListener; - delete mSpeakerRemoveListener; - delete mSpeakerClearListener; - mSpeakerAddListener = NULL; - mSpeakerRemoveListener = NULL; - mSpeakerClearListener = NULL; } -// -// LLParticipantList::SpeakerAddListener -// -bool LLParticipantList::SpeakerAddListener::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) +void LLParticipantList::onAvatarListDoubleClicked(LLAvatarList* list) +{ + LLUUID clicked_id = list->getSelectedUUID(); + + if (clicked_id.isNull() || clicked_id == gAgent.getID()) + return; + + LLAvatarActions::startIM(clicked_id); +} + +void LLParticipantList::setSortOrder(EParticipantSortOrder order) +{ + if ( mSortOrder != order ) + { + mSortOrder = order; + sort(); + } +} + +bool LLParticipantList::onAddItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) { LLAvatarList::uuid_vector_t& group_members = mAvatarList->getIDs(); LLUUID uu_id = event->getValue().asUUID(); @@ -88,15 +105,11 @@ bool LLParticipantList::SpeakerAddListener::handleEvent(LLPointer<LLOldEvents::L } group_members.push_back(uu_id); - mAvatarList->setDirty(); - mAvatarList->sortByName(); + sort(); return true; } -// -// LLParticipantList::SpeakerRemoveListener -// -bool LLParticipantList::SpeakerRemoveListener::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) +bool LLParticipantList::onRemoveItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) { LLAvatarList::uuid_vector_t& group_members = mAvatarList->getIDs(); LLAvatarList::uuid_vector_t::iterator pos = std::find(group_members.begin(), group_members.end(), event->getValue().asUUID()); @@ -108,10 +121,7 @@ bool LLParticipantList::SpeakerRemoveListener::handleEvent(LLPointer<LLOldEvents return true; } -// -// LLParticipantList::SpeakerClearListener -// -bool LLParticipantList::SpeakerClearListener::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) +bool LLParticipantList::onClearListEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) { LLAvatarList::uuid_vector_t& group_members = mAvatarList->getIDs(); group_members.clear(); @@ -119,3 +129,45 @@ bool LLParticipantList::SpeakerClearListener::handleEvent(LLPointer<LLOldEvents: 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 : + mAvatarList->sortByName(); + break; + default : + llwarns << "Unrecognized sort order for " << mAvatarList->getName() << llendl; + return; + } +} + +// +// LLParticipantList::SpeakerAddListener +// +bool LLParticipantList::SpeakerAddListener::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) +{ + return mParent.onAddItemEvent(event, userdata); +} + +// +// LLParticipantList::SpeakerRemoveListener +// +bool LLParticipantList::SpeakerRemoveListener::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) +{ + return mParent.onRemoveItemEvent(event, userdata); +} + +// +// LLParticipantList::SpeakerClearListener +// +bool LLParticipantList::SpeakerClearListener::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) +{ + return mParent.onClearListEvent(event, userdata); +} |