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.cpp105
1 files changed, 79 insertions, 26 deletions
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index e97eb1df2b..edff706fee 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,16 +44,20 @@
//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),
+ mSortOrder(E_SORT_BY_NAME)
{
- mSpeakerAddListener = new SpeakerAddListener(mAvatarList);
- mSpeakerRemoveListener = new SpeakerRemoveListener(mAvatarList);
- mSpeakerClearListener = new SpeakerClearListener(mAvatarList);
+ mSpeakerAddListener = new SpeakerAddListener(*this);
+ mSpeakerRemoveListener = new SpeakerRemoveListener(*this);
+ mSpeakerClearListener = new SpeakerClearListener(*this);
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 +67,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 +106,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 +122,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 +130,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);
+}