diff options
| author | dmitrykproductengine <none@none> | 2013-09-11 11:21:27 +0300 | 
|---|---|---|
| committer | dmitrykproductengine <none@none> | 2013-09-11 11:21:27 +0300 | 
| commit | 9e451513d95691d073519bea12b3899807784d21 (patch) | |
| tree | 688b9301c8399f9724a7ff9ca828c4e02fe9e173 /indra | |
| parent | 60b20e3bd899198771b3c1b255be042864618cad (diff) | |
MAINT-3069 FIXED Adding/removing item from blocklist blocks viewer up to a disconnect
Diffstat (limited to 'indra')
| -rwxr-xr-x | indra/newview/llblocklist.cpp | 110 | ||||
| -rwxr-xr-x | indra/newview/llblocklist.h | 21 | ||||
| -rwxr-xr-x | indra/newview/llmutelist.cpp | 17 | ||||
| -rwxr-xr-x | indra/newview/llmutelist.h | 2 | 
4 files changed, 132 insertions, 18 deletions
| diff --git a/indra/newview/llblocklist.cpp b/indra/newview/llblocklist.cpp index 066cb71677..ac41b26a34 100755 --- a/indra/newview/llblocklist.cpp +++ b/indra/newview/llblocklist.cpp @@ -41,10 +41,14 @@ static const LLBlockListNameTypeComparator	NAME_TYPE_COMPARATOR;  LLBlockList::LLBlockList(const Params& p)  :	LLFlatListViewEx(p),   	mSelectedItem(NULL), - 	mDirty(true) + 	mDirty(true), +	mShouldAddAll(true), +	mActionType(NONE), +	mMuteListSize(0)  {  	LLMuteList::getInstance()->addObserver(this); +	mMuteListSize = LLMuteList::getInstance()->getMutes().size();  	// Set up context menu.  	LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; @@ -73,6 +77,41 @@ LLBlockList::~LLBlockList()  	LLMuteList::getInstance()->removeObserver(this);  } +void LLBlockList::createList() +{ +	std::vector<LLMute> mutes = LLMuteList::instance().getMutes(); +	std::vector<LLMute>::const_iterator mute_it = mutes.begin(); + +	for (; mute_it != mutes.end(); ++mute_it) +	{ +		addNewItem(&*mute_it); +	} +} + +BlockListActionType LLBlockList::getCurrentMuteListActionType() +{ +	BlockListActionType type = NONE; +	U32 curSize = LLMuteList::getInstance()->getMutes().size(); +	if( curSize > mMuteListSize) +		type = ADD; +	else if(curSize < mMuteListSize) +		type = REMOVE; + +	return type; +} + +void LLBlockList::onChangeDetailed(const LLMute &mute) +{ +	mActionType = getCurrentMuteListActionType(); + +	mCurItemId = mute.mID; +	mCurItemName = mute.mName; +	mCurItemType = mute.mType; +	mCurItemFlags = mute.mFlags; + +	refresh(); +} +  BOOL LLBlockList::handleRightMouseDown(S32 x, S32 y, MASK mask)  {  	BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask); @@ -88,6 +127,16 @@ BOOL LLBlockList::handleRightMouseDown(S32 x, S32 y, MASK mask)  	return handled;  } +void LLBlockList::removeListItem(const LLMute* mute) +{ +	removeItemByUUID(mute->mID); +} + +void LLBlockList::hideListItem(LLBlockedListItem* item, bool show) +{ +	item->setVisible(show); +} +  void LLBlockList::setNameFilter(const std::string& filter)  {  	std::string filter_upper = filter; @@ -136,28 +185,56 @@ void LLBlockList::refresh()  	bool have_filter = !mNameFilter.empty();  	// save selection to restore it after list rebuilt -	LLUUID selected = getSelectedUUID(); +	LLUUID selected = getSelectedUUID(), next_selected; -	// calling refresh may be initiated by removing currently selected item -	// so select next item and save the selection to restore it after list rebuilt -	if (!selectNextItemPair(false, true)) +	if(mShouldAddAll)	// creating list of blockers  	{ -		selectNextItemPair(true, true); +		clear(); +		createList(); +		mShouldAddAll = false; +	} +	else +	{ +		// handle remove/add functionality +		LLMute mute(mCurItemId, mCurItemName, mCurItemType, mCurItemFlags); +		if(mActionType == ADD) +		{ +			addNewItem(&mute); +		} +		else if(mActionType == REMOVE) +		{ +			if(selected == mute.mID) +			{ +				// we are going to remove currently selected item, so select next item and save the selection to restore it +				if (!selectNextItemPair(false, true)) +				{ +					selectNextItemPair(true, true); +				} +				next_selected = getSelectedUUID(); +			} +			removeListItem(&mute); +		} +		mActionType = NONE;  	} -	LLUUID next_selected = getSelectedUUID(); - -	clear(); - -	std::vector<LLMute> mutes = LLMuteList::instance().getMutes(); -	std::vector<LLMute>::const_iterator mute_it = mutes.begin(); -	for (; mute_it != mutes.end(); ++mute_it) +	// handle filter functionality +	if(have_filter || (!have_filter && !mPrevNameFilter.empty()))  	{ -		if (have_filter && !findInsensitive(mute_it->mName, mNameFilter)) -			continue; +		// we should update visibility of our items if previous filter was not empty +		std::vector < LLPanel* > allItems; +		getItems(allItems); +		std::vector < LLPanel* >::iterator it = allItems.begin(); -		addNewItem(&*mute_it); +		for(; it != allItems.end() ; ++it) +		{ +			LLBlockedListItem * curItem = dynamic_cast<LLBlockedListItem *> (*it); +			if(curItem) +			{ +				hideListItem(curItem, findInsensitive(curItem->getName(), mNameFilter)); +			} +		}  	} +	mPrevNameFilter = mNameFilter;  	if (getItemPair(selected))  	{ @@ -169,6 +246,7 @@ void LLBlockList::refresh()  		// previously selected item was removed, so select next item  		selectItemPair(getItemPair(next_selected), true);  	} +	mMuteListSize = LLMuteList::getInstance()->getMutes().size();  	// Sort the list.  	sort(); diff --git a/indra/newview/llblocklist.h b/indra/newview/llblocklist.h index 1a215710f4..b1ea7e98e5 100755 --- a/indra/newview/llblocklist.h +++ b/indra/newview/llblocklist.h @@ -34,6 +34,8 @@  class LLBlockedListItem;  class LLMute; +enum BlockListActionType {NONE, ADD, REMOVE}; +  /**   * List of blocked avatars and objects.   * This list represents contents of the LLMuteList. @@ -56,7 +58,8 @@ public:  	LLToggleableMenu*	getContextMenu() const { return mContextMenu.get(); }  	LLBlockedListItem*	getBlockedItem() const; -	virtual void onChange() { refresh(); } +	virtual void onChange() { } +	virtual void onChangeDetailed(const LLMute& );  	virtual void draw();  	void setNameFilter(const std::string& filter); @@ -67,18 +70,32 @@ public:  private:  	void addNewItem(const LLMute* mute); +	void removeListItem(const LLMute* mute); +	void hideListItem(LLBlockedListItem* item, bool show);  	void setDirty(bool dirty = true) { mDirty = dirty; }  	bool findInsensitive(std::string haystack, const std::string& needle_upper);  	bool isActionEnabled(const LLSD& userdata);  	void onCustomAction (const LLSD& userdata); +	void createList(); - +	BlockListActionType getCurrentMuteListActionType(); +	  	LLHandle<LLToggleableMenu>	mContextMenu;  	LLBlockedListItem*			mSelectedItem;  	std::string 				mNameFilter;  	bool 						mDirty; +	bool						mShouldAddAll; +	BlockListActionType			mActionType; +	U32							mMuteListSize; + +	// This data is used to save information about item that currently changed(added or removed)  +	LLUUID						mCurItemId; +	std::string					mCurItemName; +	LLMute::EType 				mCurItemType; +	U32							mCurItemFlags; +	std::string					mPrevNameFilter;  }; diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index 54522bb7f6..0720d443f8 100755 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -251,6 +251,7 @@ BOOL LLMuteList::add(const LLMute& mute, U32 flags)  			llinfos << "Muting by name " << mute.mName << llendl;  			updateAdd(mute);  			notifyObservers(); +			notifyObserversDetailed(mute);  			return TRUE;  		}  		else @@ -299,6 +300,7 @@ BOOL LLMuteList::add(const LLMute& mute, U32 flags)  				llinfos << "Muting " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl;  				updateAdd(localmute);  				notifyObservers(); +				notifyObserversDetailed(localmute);  				if(!(localmute.mFlags & LLMute::flagParticles))  				{  					//Kill all particle systems owned by muted task @@ -396,6 +398,7 @@ BOOL LLMuteList::remove(const LLMute& mute, U32 flags)  		}  		// Must be after erase. +		notifyObserversDetailed(localmute);  		setLoaded();  // why is this here? -MG  	}  	else @@ -409,6 +412,7 @@ BOOL LLMuteList::remove(const LLMute& mute, U32 flags)  			updateRemove(mute);  			mLegacyMutes.erase(legacy_it);  			// Must be after erase. +			notifyObserversDetailed(mute);  			setLoaded(); // why is this here? -MG  		}  	} @@ -762,3 +766,16 @@ void LLMuteList::notifyObservers()  		it = mObservers.upper_bound(observer);  	}  } + +void LLMuteList::notifyObserversDetailed(const LLMute& mute) +{ +	for (observer_set_t::iterator it = mObservers.begin(); +		it != mObservers.end(); +		) +	{ +		LLMuteListObserver* observer = *it; +		observer->onChangeDetailed(mute); +		// In case onChange() deleted an entry. +		it = mObservers.upper_bound(observer); +	} +} diff --git a/indra/newview/llmutelist.h b/indra/newview/llmutelist.h index 7a70370fe3..3e998b4f0e 100755 --- a/indra/newview/llmutelist.h +++ b/indra/newview/llmutelist.h @@ -123,6 +123,7 @@ private:  	void setLoaded();  	void notifyObservers(); +	void notifyObserversDetailed(const LLMute &mute);  	void updateAdd(const LLMute& mute);  	void updateRemove(const LLMute& mute); @@ -173,6 +174,7 @@ class LLMuteListObserver  public:  	virtual ~LLMuteListObserver() { }  	virtual void onChange() = 0; +	virtual void onChangeDetailed(const LLMute& ) { }  }; | 
