diff options
| -rw-r--r-- | indra/newview/llconversationmodel.cpp | 12 | ||||
| -rw-r--r-- | indra/newview/llconversationmodel.h | 14 | ||||
| -rw-r--r-- | indra/newview/llconversationview.cpp | 38 | ||||
| -rw-r--r-- | indra/newview/llconversationview.h | 20 | ||||
| -rw-r--r-- | indra/newview/llimfloatercontainer.cpp | 75 | 
5 files changed, 128 insertions, 31 deletions
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index d7f9093a4a..aa21b08ec8 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -36,21 +36,24 @@  LLConversationItem::LLConversationItem(std::string display_name, const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) :  	LLFolderViewModelItemCommon(root_view_model),  	mName(display_name), -	mUUID(uuid) +	mUUID(uuid), +	mNeedsRefresh(true)  {  }  LLConversationItem::LLConversationItem(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) :  	LLFolderViewModelItemCommon(root_view_model),  	mName(""), -	mUUID(uuid) +	mUUID(uuid), +	mNeedsRefresh(true)  {  }  LLConversationItem::LLConversationItem(LLFolderViewModelInterface& root_view_model) :  	LLFolderViewModelItemCommon(root_view_model),  	mName(""), -	mUUID() +	mUUID(), +	mNeedsRefresh(true)  {  } @@ -102,11 +105,13 @@ void LLConversationItemSession::addParticipant(LLConversationItemParticipant* pa  {  	addChild(participant);  	mIsLoaded = true; +	mNeedsRefresh = true;  }  void LLConversationItemSession::removeParticipant(LLConversationItemParticipant* participant)  {  	removeChild(participant); +	mNeedsRefresh = true;  }  void LLConversationItemSession::removeParticipant(const LLUUID& participant_id) @@ -122,6 +127,7 @@ void LLConversationItemSession::clearParticipants()  {  	clearChildren();  	mIsLoaded = false; +	mNeedsRefresh = true;  }  LLConversationItemParticipant* LLConversationItemSession::findParticipant(const LLUUID& participant_id) diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index 1a2e09dfab..5947055e0f 100644 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -60,7 +60,7 @@ public:  	virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; }  	virtual std::string getLabelSuffix() const { return LLStringUtil::null; }  	virtual BOOL isItemRenameable() const { return TRUE; } -	virtual BOOL renameItem(const std::string& new_name) { mName = new_name; return TRUE; } +	virtual BOOL renameItem(const std::string& new_name) { mName = new_name; mNeedsRefresh = true; return TRUE; }  	virtual BOOL isItemMovable( void ) const { return FALSE; }  	virtual BOOL isItemRemovable( void ) const { return FALSE; }  	virtual BOOL isItemInTrash( void) const { return FALSE; } @@ -102,10 +102,14 @@ public:  //	bool hasSameValues(std::string name, const LLUUID& uuid) { return ((name == mName) && (uuid == mUUID)); }  	bool hasSameValue(const LLUUID& uuid) { return (uuid == mUUID); } - +	 +	void resetRefresh() { mNeedsRefresh = false; } +	bool needsRefresh() { return mNeedsRefresh; } +	  protected:  	std::string mName;	// Name of the session or the participant  	LLUUID mUUID;		// UUID of the session or the participant +	bool mNeedsRefresh;	// Flag signaling to the view that something changed for this item  };  class LLConversationItemSession : public LLConversationItem @@ -115,7 +119,7 @@ public:  	LLConversationItemSession(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model);  	virtual ~LLConversationItemSession() {} -	void setSessionID(const LLUUID& session_id) { mUUID = session_id; } +	void setSessionID(const LLUUID& session_id) { mUUID = session_id; mNeedsRefresh = true; }  	void addParticipant(LLConversationItemParticipant* participant);  	void removeParticipant(LLConversationItemParticipant* participant);  	void removeParticipant(const LLUUID& participant_id); @@ -142,8 +146,8 @@ public:  	bool isMuted() { return mIsMuted; }  	bool isModerator() {return mIsModerator; } -	void setIsMuted(bool is_muted) { mIsMuted = is_muted; } -	void setIsModerator(bool is_moderator) { mIsModerator = is_moderator; } +	void setIsMuted(bool is_muted) { mIsMuted = is_muted; mNeedsRefresh = true; } +	void setIsModerator(bool is_moderator) { mIsModerator = is_moderator; mNeedsRefresh = true; }  	void dumpDebugData(); diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp index fefb7e9cac..2f71e92a7d 100644 --- a/indra/newview/llconversationview.cpp +++ b/indra/newview/llconversationview.cpp @@ -79,12 +79,46 @@ void LLConversationViewSession::setVisibleIfDetached(BOOL visible)  	}  } +LLConversationViewParticipant* LLConversationViewSession::findParticipant(const LLUUID& participant_id) +{ +	// This is *not* a general tree parsing algorithm. We search only in the mItems list +	// assuming there is no mFolders which makes sense for sessions (sessions don't contain +	// sessions). +	LLConversationViewParticipant* participant = NULL; +	items_t::const_iterator iter; +	for (iter = getItemsBegin(); iter != getItemsEnd(); iter++) +	{ +		participant = dynamic_cast<LLConversationViewParticipant*>(*iter); +		if (participant->hasSameValue(participant_id)) +		{ +			break; +		} +	} +	return (iter == getItemsEnd() ? NULL : participant); +} + +void LLConversationViewSession::refresh() +{ +	// Refresh the session view from its model data +	// LLConversationItemSession* vmi = dynamic_cast<LLConversationItemSession*>(getViewModelItem()); +	 +	// Note: for the moment, all that needs to be done is done by LLFolderViewItem::refresh() +	 +	// Do the regular upstream refresh +	LLFolderViewFolder::refresh(); +} +  //  // Implementation of conversations list participant (avatar) widgets  // -LLConversationViewParticipant::LLConversationViewParticipant( const LLFolderViewItem::Params& p ): -	LLFolderViewItem(p) +LLConversationViewParticipant::Params::Params() :	 +	participant_id() +{} + +LLConversationViewParticipant::LLConversationViewParticipant( const LLConversationViewParticipant::Params& p ): +	LLFolderViewItem(p), +	mUUID(p.participant_id)  {  } diff --git a/indra/newview/llconversationview.h b/indra/newview/llconversationview.h index 5695925f43..27ceb2af3b 100644 --- a/indra/newview/llconversationview.h +++ b/indra/newview/llconversationview.h @@ -30,6 +30,8 @@  #include "llfolderviewitem.h"  class LLIMFloaterContainer; +class LLConversationViewSession; +class LLConversationViewParticipant;  // Implementation of conversations list session widgets @@ -53,18 +55,34 @@ public:  	virtual ~LLConversationViewSession( void ) { }  	virtual void selectItem();	  	void setVisibleIfDetached(BOOL visible); +	LLConversationViewParticipant* findParticipant(const LLUUID& participant_id); + +	virtual void refresh();  };  // Implementation of conversations list participant (avatar) widgets  class LLConversationViewParticipant : public LLFolderViewItem  { +public: +	struct Params : public LLInitParam::Block<Params, LLFolderViewItem::Params> +	{ +		Optional<LLUUID>	participant_id; +		 +		Params(); +	}; +	  protected:  	friend class LLUICtrlFactory; -	LLConversationViewParticipant( const LLFolderViewItem::Params& p ); +	LLConversationViewParticipant( const Params& p );  public:  	virtual ~LLConversationViewParticipant( void ) { } + +	bool hasSameValue(const LLUUID& uuid) { return (uuid == mUUID); } + +private: +	LLUUID mUUID;		// UUID of the participant  };  #endif // LL_LLCONVERSATIONVIEW_H diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index 5261d30cd9..1be0c5f075 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -292,6 +292,59 @@ void LLIMFloaterContainer::setMinimized(BOOL b)  void LLIMFloaterContainer::draw()  { +	// CHUI Notes +	// Currently, 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. +	 +	// On each session in mConversationsItems +	for (conversations_items_map::iterator it_session = mConversationsItems.begin(); it_session != mConversationsItems.end(); it_session++) +	{ +		// Get the current session descriptors +		LLConversationItem* session_model = it_session->second; +		LLUUID session_id = it_session->first; +		LLConversationViewSession* session_view = dynamic_cast<LLConversationViewSession*>(mConversationsWidgets[session_id]); +		// If the session model has been changed, refresh the corresponding view +		if (session_model->needsRefresh()) +		{ +			session_view->refresh(); +		} +		// Iterate through each model participant child +		LLFolderViewModelItemCommon::child_list_t::const_iterator current_participant_model = session_model->getChildrenBegin(); +		LLFolderViewModelItemCommon::child_list_t::const_iterator end_participant_model = session_model->getChildrenEnd(); +		while (current_participant_model != end_participant_model) +		{ +			LLConversationItem* participant_model = dynamic_cast<LLConversationItem*>(*current_participant_model); +			LLUUID participant_id = participant_model->getUUID(); +			LLConversationViewParticipant* participant_view = session_view->findParticipant(participant_id); +			// Is there a corresponding view? If not create it +			if (!participant_view) +			{ +				participant_view = createConversationViewParticipant(participant_model); +				participant_view->addToFolder(session_view); +				mConversationsListPanel->addChild(participant_view); +				participant_view->setVisible(TRUE); +			} +			else +			// Else, see if it needs refresh +			{ +				if (participant_model->needsRefresh()) +				{ +					participant_view->refresh(); +				} +			} +			// Reset the need for refresh +			session_model->resetRefresh(); +			// Next participant +			current_participant_model++; +		} +	} +	  	if (mTabContainer->getTabCount() == 0)  	{  		// Do not close the container when every conversation is torn off because the user @@ -560,24 +613,6 @@ void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid)  		participant_view->setVisible(TRUE);  		current_participant_model++;  	} -	// Debugging hack : uncomment to force the creation of a dummy participant  -	// This hack is to be eventually deleted -	if (item->getChildrenCount() == 0) -	{ -		llinfos << "Merov debug : create dummy participant" << llendl; -		// Create a dummy participant : we let that leak but that's just for debugging... -		std::string name("Debug Test : "); -		name += display_name; -		LLUUID test_id; -		test_id.generate(name); -		LLConversationItemParticipant* participant_model = new LLConversationItemParticipant(name, test_id, getRootViewModel()); -		// Create the dummy widget -		LLConversationViewParticipant* participant_view = createConversationViewParticipant(participant_model); -		participant_view->addToFolder(widget); -		mConversationsListPanel->addChild(participant_view); -		participant_view->setVisible(TRUE); -	} -	// End debugging hack  	repositioningWidgets(); @@ -634,7 +669,7 @@ LLConversationViewSession* LLIMFloaterContainer::createConversationItemWidget(LL  LLConversationViewParticipant* LLIMFloaterContainer::createConversationViewParticipant(LLConversationItem* item)  { -	LLConversationViewSession::Params params; +	LLConversationViewParticipant::Params params;  	params.name = item->getDisplayName();  	//params.icon = bridge->getIcon(); @@ -644,7 +679,7 @@ LLConversationViewParticipant* LLIMFloaterContainer::createConversationViewParti  	params.listener = item;  	params.rect = LLRect (0, 0, 0, 0);  	params.tool_tip = params.name; -	params.container = this; +	params.participant_id = item->getUUID();  	return LLUICtrlFactory::create<LLConversationViewParticipant>(params);  }  | 
