summaryrefslogtreecommitdiff
path: root/indra/newview/llblocklist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llblocklist.cpp')
-rwxr-xr-xindra/newview/llblocklist.cpp110
1 files changed, 94 insertions, 16 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();