void LLPanelFriends::refreshNames(U32 changed_mask)
{
	LLDynamicArray<LLUUID> selected_ids = getSelectedIDs();	
	S32 pos = mFriendsList->getScrollPos();	
	
	// get all buddies we know about
	LLAvatarTracker::buddy_map_t all_buddies;
	LLAvatarTracker::instance().copyBuddyList(all_buddies);

	BOOL have_names = TRUE;

	if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE))
	{
		have_names &= refreshNamesSync(all_buddies);
	}

	if(changed_mask & LLFriendObserver::ONLINE)
	{
		have_names &= refreshNamesPresence(all_buddies);
	}

	if (!have_names)
	{
		mEventTimer.start();
	}
	// Changed item in place, need to request sort and update columns
	// because we might have changed data in a column on which the user
	// has already sorted. JC
	mFriendsList->sortItems();

	// re-select items
	mFriendsList->selectMultiple(selected_ids);
	mFriendsList->setScrollPos(pos);
}
Ejemplo n.º 2
0
void LLPanelFriends::refreshNames(U32 changed_mask, const std::string& search_string)
{
    LLDynamicArray<LLUUID> selected_ids = getSelectedIDs();
    S32 pos = mFriendsList->getScrollPos();

    // get all buddies we know about
    LLAvatarTracker::buddy_map_t all_buddies;
    LLAvatarTracker::instance().copyBuddyList(all_buddies);

    BOOL have_names = TRUE;

    // I hate doing it this way. There's no need for it. I blame LL -- MC
    if (search_string.empty())
    {
        if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE))
        {
            have_names &= refreshNamesSync(all_buddies);
        }

        if(changed_mask & LLFriendObserver::ONLINE)
        {
            have_names &= refreshNamesPresence(all_buddies);
        }
    }
    else
    {
        std::string firstname;
        std::string lastname;
        std::string filter = search_string;
        LLStringUtil::toLower(filter);
        LLAvatarTracker::buddy_map_t temp_buddies;

        for (LLAvatarTracker::buddy_map_t::reverse_iterator bIt = all_buddies.rbegin();
                bIt != all_buddies.rend(); ++bIt)
        {
            if (gCacheName->getName((*bIt).first, firstname, lastname))
            {
                std::string l_name(firstname);
                LLStringUtil::toLower(l_name);
                std::string l_sname(lastname);
                LLStringUtil::toLower(l_sname);
                if (l_name.find(filter) == 0 || l_sname.find(filter) == 0)
                {
                    temp_buddies.insert(temp_buddies.begin(), std::pair<LLUUID, LLRelationship*>((*bIt).first, (*bIt).second));
                }
            }
        }
        if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE))
        {
            have_names &= refreshNamesSync(temp_buddies);
        }

        if(changed_mask & LLFriendObserver::ONLINE)
        {
            have_names &= refreshNamesPresence(temp_buddies);
        }
    }

    if (!have_names)
    {
        mEventTimer.start();
    }
    // Changed item in place, need to request sort and update columns
    // because we might have changed data in a column on which the user
    // has already sorted. JC
    mFriendsList->sortItems();

    // re-select items
    mFriendsList->selectMultiple(selected_ids);
    mFriendsList->setScrollPos(pos);
}