diff options
| author | Merov Linden <merov@lindenlab.com> | 2012-10-02 22:34:44 -0700 | 
|---|---|---|
| committer | Merov Linden <merov@lindenlab.com> | 2012-10-02 22:34:44 -0700 | 
| commit | 4a25ce8b9d5d56b160d0d13c4681cd916c4ea4e0 (patch) | |
| tree | 30714cbf6fa1c02a11900daaea732c4496175ea4 | |
| parent | d54eded93ba270402349f5f337bbe12339255ece (diff) | |
CHUI-341 : Implement the use of LLEventStream and LLEventPump to signal conversation model changes, picked by LLIMFloaterContainer. Suppress pooling on draw().
| -rw-r--r-- | indra/newview/llconversationmodel.cpp | 16 | ||||
| -rwxr-xr-x | indra/newview/llconversationmodel.h | 2 | ||||
| -rw-r--r-- | indra/newview/llimfloatercontainer.cpp | 41 | ||||
| -rw-r--r-- | indra/newview/llimfloatercontainer.h | 3 | 
4 files changed, 52 insertions, 10 deletions
| diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index 9fa8758d11..1057dbaf31 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -27,6 +27,7 @@  #include "llviewerprecompiledheaders.h" +#include "llevents.h"  #include "llconversationmodel.h"  // @@ -63,6 +64,18 @@ LLConversationItem::LLConversationItem(LLFolderViewModelInterface& root_view_mod  {  } +void LLConversationItem::postEvent(const std::string& event_type) +{ +	LLSD event; +	event["pump"] = "ConversationModelEvent"; +	LLSD payload; +	payload["type"] = event_type; +	payload["name"] = getName(); +	payload["uuid"] = getUUID(); +	event["payload"] = payload; +	LLEventPumps::instance().obtain("ConversationsEvents").post(event); +} +  // Virtual action callbacks  void LLConversationItem::performAction(LLInventoryModel* model, std::string action)  { @@ -111,12 +124,14 @@ void LLConversationItemSession::addParticipant(LLConversationItemParticipant* pa  	addChild(participant);  	mIsLoaded = true;  	mNeedsRefresh = true; +	postEvent("add_participant");  }  void LLConversationItemSession::removeParticipant(LLConversationItemParticipant* participant)  {  	removeChild(participant);  	mNeedsRefresh = true; +	postEvent("remove_participant");  }  void LLConversationItemSession::removeParticipant(const LLUUID& participant_id) @@ -254,6 +269,7 @@ void LLConversationItemParticipant::onAvatarNameCache(const LLAvatarName& av_nam  	mName = (av_name.mUsername.empty() ? av_name.mDisplayName : av_name.mUsername);  	mDisplayName = (av_name.mDisplayName.empty() ? av_name.mUsername : av_name.mDisplayName);  	mNeedsRefresh = true; +	postEvent("update_participant");  	if (mParent)  	{  		mParent->requestSort(); diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index 30f94d51ae..97e5b0fc31 100755 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -124,6 +124,8 @@ public:  	void resetRefresh() { mNeedsRefresh = false; }  	bool needsRefresh() { return mNeedsRefresh; } +	void postEvent(const std::string& event_type); +	  protected:  	std::string mName;	// Name of the session or the participant  	LLUUID mUUID;		// UUID of the session or the participant diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index 6f7eb7822a..8642eaf5e1 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -49,6 +49,7 @@  #include "llcallbacklist.h"  #include "llworld.h" +#include "llsdserialize.h"  //  // LLIMFloaterContainer  // @@ -56,6 +57,7 @@ LLIMFloaterContainer::LLIMFloaterContainer(const LLSD& seed)  :	LLMultiFloater(seed),  	mExpandCollapseBtn(NULL),  	mConversationsRoot(NULL), +	mStream("ConversationsEvents"),  	mInitialized(false)  {  	mCommitCallbackRegistrar.add("IMFloaterContainer.Action", boost::bind(&LLIMFloaterContainer::onCustomAction,  this, _2)); @@ -136,6 +138,9 @@ BOOL LLIMFloaterContainer::postBuild()      p.use_ellipses = true;  	mConversationsRoot = LLUICtrlFactory::create<LLFolderView>(p); +	// Add listener to conversation model events +	mStream.listen("ConversationsRefresh", boost::bind(&LLIMFloaterContainer::onConversationModelEvent, this, _1)); +  	// a scroller for folder view  	LLRect scroller_view_rect = mConversationsListPanel->getRect();  	scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); @@ -378,18 +383,29 @@ void LLIMFloaterContainer::idle(void* user_data)  	self->mConversationsRoot->update();  } -void LLIMFloaterContainer::draw() +bool LLIMFloaterContainer::onConversationModelEvent(const LLSD& event)  { -	// CHUI Notes -	// Currently, the model is not responsible for creating the view which is a good thing. This means that +	// For debug only +	//std::ostringstream llsd_value; +	//llsd_value << LLSDOStreamer<LLSDNotationFormatter>(event) << std::endl; +	//llinfos << "Merov debug : onConversationModelEvent, event = " << llsd_value.str() << llendl; +	// end debug +	 +	// Note: In conversations, the model is not responsible for creating the view which is a good thing. This means that  	// the model could change substantially and the view could decide to echo only a portion of this model.  	// Consequently, the participant views need to be created either by the session view or by the container panel. -	// For the moment, we create them here (which makes for complicated code...) to conform to the pattern -	// implemented in llinventorypanel.cpp (see LLInventoryPanel::buildNewViews()). -	// The best however would be to have an observer on the model so that we would not pool on each draw to know -	// if the view needs refresh. The current implementation (testing for change on draw) is less -	// efficient perf wise than a listener/observer scheme. We will implement that shortly. -	 +	// For the moment, we create them here to conform to the pattern implemented in llinventorypanel.cpp  +	// (see LLInventoryPanel::buildNewViews()). + +	// Note: For the moment, we're not very smart about the event paramter and we just refresh the whole set of views/widgets +	// according to the current state of the whole model. +	// We should at least analyze the event payload and do things differently for a handful of useful cases: +	// - add session or participant +	// - remove session or participant +	// - update session or participant (e.g. rename, change sort order, etc...) +	// see LLConversationItem::postEvent() for the payload formatting. +	// *TODO: Add handling for various event signatures (add, remove, update, resort) +  	// On each session in mConversationsItems  	for (conversations_items_map::iterator it_session = mConversationsItems.begin(); it_session != mConversationsItems.end(); it_session++)  	{ @@ -418,7 +434,7 @@ void LLIMFloaterContainer::draw()  				participant_view->setVisible(TRUE);  			}  			else -			// Else, see if it needs refresh +				// Else, see if it needs refresh  			{  				if (participant_model->needsRefresh())  				{ @@ -434,6 +450,11 @@ void LLIMFloaterContainer::draw()  		}  	} +	return false; +} + +void LLIMFloaterContainer::draw() +{  	if (mTabContainer->getTabCount() == 0)  	{  		// Do not close the container when every conversation is torn off because the user diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h index 2debc2455b..8e953025bc 100644 --- a/indra/newview/llimfloatercontainer.h +++ b/indra/newview/llimfloatercontainer.h @@ -31,6 +31,7 @@  #include <vector>  #include "llimview.h" +#include "llevents.h"  #include "llfloater.h"  #include "llmultifloater.h"  #include "llavatarpropertiesprocessor.h" @@ -130,6 +131,7 @@ public:  private:  	LLConversationViewSession* createConversationItemWidget(LLConversationItem* item);  	LLConversationViewParticipant* createConversationViewParticipant(LLConversationItem* item); +	bool onConversationModelEvent(const LLSD& event);  	// Conversation list data  	LLPanel* mConversationsListPanel;	// This is the main widget we add conversation widget to @@ -137,6 +139,7 @@ private:  	conversations_widgets_map mConversationsWidgets;  	LLConversationViewModel mConversationViewModel;  	LLFolderView* mConversationsRoot; +	LLEventStream mStream;   };  #endif // LL_LLIMFLOATERCONTAINER_H | 
