diff options
author | Eugene Mutavchi <emutavchi@productengine.com> | 2009-11-03 17:47:20 +0200 |
---|---|---|
committer | Eugene Mutavchi <emutavchi@productengine.com> | 2009-11-03 17:47:20 +0200 |
commit | 5ea6474aebb7f81ce797de1449863bac1543fb03 (patch) | |
tree | 73db816b9836c29d152373720293f654276f2336 | |
parent | 3483f9e0d04f7a956921b9ac60e85b4371f97322 (diff) |
Implemented low task EXT-1787 (Implement sorting of participant list)
--HG--
branch : product-engine
-rw-r--r-- | indra/newview/llpanelimcontrolpanel.cpp | 14 | ||||
-rw-r--r-- | indra/newview/llpanelimcontrolpanel.h | 1 | ||||
-rw-r--r-- | indra/newview/llparticipantlist.cpp | 96 | ||||
-rw-r--r-- | indra/newview/llparticipantlist.h | 56 |
4 files changed, 121 insertions, 46 deletions
diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp index b5e0cdccc0..21e88b6d07 100644 --- a/indra/newview/llpanelimcontrolpanel.cpp +++ b/indra/newview/llpanelimcontrolpanel.cpp @@ -199,6 +199,20 @@ void LLPanelGroupControlPanel::onGroupInfoButtonClicked() LLGroupActions::show(mGroupID); } +void LLPanelGroupControlPanel::onSortMenuItemClicked(const LLSD& userdata) +{ + // TODO: Check this code when when sort order menu will be added. (EM) + if (false && !mParticipantList) + return; + + std::string chosen_item = userdata.asString(); + + if (chosen_item == "sort_name") + { + mParticipantList->setSortOrder(LLParticipantList::E_SORT_BY_NAME); + } + +} void LLPanelGroupControlPanel::setSessionId(const LLUUID& session_id) { diff --git a/indra/newview/llpanelimcontrolpanel.h b/indra/newview/llpanelimcontrolpanel.h index b60ddc1d8d..fa101f4280 100644 --- a/indra/newview/llpanelimcontrolpanel.h +++ b/indra/newview/llpanelimcontrolpanel.h @@ -99,6 +99,7 @@ protected: private: void onGroupInfoButtonClicked(); + void onSortMenuItemClicked(const LLSD& userdata); }; class LLPanelAdHocControlPanel : public LLPanelGroupControlPanel diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp index 133f13aab8..9450bee315 100644 --- a/indra/newview/llparticipantlist.cpp +++ b/indra/newview/llparticipantlist.cpp @@ -44,15 +44,15 @@ //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)); @@ -66,8 +66,11 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* av { group_members.push_back((*it)->mID); } - mAvatarList->setDirty(); - mAvatarList->sortByName(); + sort(); +} + +LLParticipantList::~LLParticipantList() +{ } void LLParticipantList::onAvatarListDoubleClicked(LLAvatarList* list) @@ -80,20 +83,16 @@ void LLParticipantList::onAvatarListDoubleClicked(LLAvatarList* list) LLAvatarActions::startIM(clicked_id); } -LLParticipantList::~LLParticipantList() +void LLParticipantList::setSortOrder(EParticipantSortOrder order) { - delete mSpeakerAddListener; - delete mSpeakerRemoveListener; - delete mSpeakerClearListener; - mSpeakerAddListener = NULL; - mSpeakerRemoveListener = NULL; - mSpeakerClearListener = NULL; + if ( mSortOrder != order ) + { + mSortOrder = order; + sort(); + } } -// -// LLParticipantList::SpeakerAddListener -// -bool LLParticipantList::SpeakerAddListener::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) +bool LLParticipantList::onAddItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata) { LLAvatarList::uuid_vector_t& group_members = mAvatarList->getIDs(); LLUUID uu_id = event->getValue().asUUID(); @@ -106,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()); @@ -126,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(); @@ -137,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); +} diff --git a/indra/newview/llparticipantlist.h b/indra/newview/llparticipantlist.h index a3a55303c0..04d9e29256 100644 --- a/indra/newview/llparticipantlist.h +++ b/indra/newview/llparticipantlist.h @@ -38,48 +38,74 @@ class LLAvatarList; class LLParticipantList { + LOG_CLASS(LLParticipantList); public: LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* avatar_list); ~LLParticipantList(); + typedef enum e_participant_sort_oder { + E_SORT_BY_NAME = 0, + } EParticipantSortOrder; + + /** + * Set and sort Avatarlist by given order + */ + void setSortOrder(EParticipantSortOrder order = E_SORT_BY_NAME); + protected: + /** + * LLSpeakerMgr event handlers + */ + bool onAddItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata); + bool onRemoveItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata); + bool onClearListEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata); + + /** + * Sorts the Avatarlist by stored order + */ + void sort(); //List of listeners implementing LLOldEvents::LLSimpleListener. //There is no way to handle all the events in one listener as LLSpeakerMgr registers listeners in such a way //that one listener can handle only one type of event - class SpeakerAddListener : public LLOldEvents::LLSimpleListener + class BaseSpeakerListner : public LLOldEvents::LLSimpleListener { public: - SpeakerAddListener(LLAvatarList* avatar_list) : mAvatarList(avatar_list) {} + BaseSpeakerListner(LLParticipantList& parent) : mParent(parent) {} + protected: + LLParticipantList& mParent; + }; + class SpeakerAddListener : public BaseSpeakerListner + { + public: + SpeakerAddListener(LLParticipantList& parent) : BaseSpeakerListner(parent) {} /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata); - LLAvatarList* mAvatarList; }; - class SpeakerRemoveListener : public LLOldEvents::LLSimpleListener + class SpeakerRemoveListener : public BaseSpeakerListner { public: - SpeakerRemoveListener(LLAvatarList* avatar_list) : mAvatarList(avatar_list) {} - + SpeakerRemoveListener(LLParticipantList& parent) : BaseSpeakerListner(parent) {} /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata); - LLAvatarList* mAvatarList; }; - class SpeakerClearListener : public LLOldEvents::LLSimpleListener + class SpeakerClearListener : public BaseSpeakerListner { public: - SpeakerClearListener(LLAvatarList* avatar_list) : mAvatarList(avatar_list) {} - + SpeakerClearListener(LLParticipantList& parent) : BaseSpeakerListner(parent) {} /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata); - LLAvatarList* mAvatarList; }; + private: void onAvatarListDoubleClicked(LLAvatarList* list); LLSpeakerMgr* mSpeakerMgr; - LLAvatarList* mAvatarList; + LLAvatarList* mAvatarList; + + SpeakerAddListener mSpeakerAddListener; + SpeakerRemoveListener mSpeakerRemoveListener; + SpeakerClearListener mSpeakerClearListener; - SpeakerAddListener* mSpeakerAddListener; - SpeakerRemoveListener* mSpeakerRemoveListener; - SpeakerClearListener* mSpeakerClearListener; + EParticipantSortOrder mSortOrder; }; |