void LLInventoryItemsList::refresh() { LLFastTimer _(FTM_INVENTORY_ITEMS_REFRESH); static const unsigned ADD_LIMIT = 20; uuid_vec_t added_items; uuid_vec_t removed_items; computeDifference(getIDs(), added_items, removed_items); bool add_limit_exceeded = false; unsigned int nadded = 0; uuid_vec_t::const_iterator it = added_items.begin(); for( ; added_items.end() != it; ++it) { if(nadded >= ADD_LIMIT) { add_limit_exceeded = true; break; } LLViewerInventoryItem* item = gInventory.getItem(*it); // Do not rearrange items on each adding, let's do that on filter call llassert(item); if (item) { addNewItem(item, false); ++nadded; } } it = removed_items.begin(); for( ; removed_items.end() != it; ++it) { // don't filter items right away removeItemByUUID(*it, false); } // Filter, rearrange and notify parent about shape changes filterItems(); bool needs_refresh = add_limit_exceeded; setNeedsRefresh(needs_refresh); setForceRefresh(needs_refresh); }
////////////////////////////////////////////////////////////////////////// // PROTECTED SECTION ////////////////////////////////////////////////////////////////////////// void LLAvatarList::refresh() { bool have_names = TRUE; bool add_limit_exceeded = false; bool modified = false; bool have_filter = !mNameFilter.empty(); // Save selection. uuid_vec_t selected_ids; getSelectedUUIDs(selected_ids); LLUUID current_id = getSelectedUUID(); // Determine what to add and what to remove. uuid_vec_t added, removed; LLAvatarList::computeDifference(getIDs(), added, removed); // Handle added items. unsigned nadded = 0; const std::string waiting_str = LLTrans::getString("AvatarNameWaiting"); for (uuid_vec_t::const_iterator it=added.begin(); it != added.end(); it++) { const LLUUID& buddy_id = *it; LLAvatarName av_name; have_names &= LLAvatarNameCache::get(buddy_id, &av_name); if (!have_filter || findInsensitive(av_name.mDisplayName, mNameFilter)) { if (nadded >= ADD_LIMIT) { add_limit_exceeded = true; break; } else { // *NOTE: If you change the UI to show a different string, // be sure to change the filter code below. if (LLRecentPeople::instance().isAvalineCaller(buddy_id)) { const LLSD& call_data = LLRecentPeople::instance().getData(buddy_id); addAvalineItem(buddy_id, call_data["session_id"].asUUID(), call_data["call_number"].asString()); } else { addNewItem(buddy_id, av_name.mDisplayName.empty() ? waiting_str : av_name.mDisplayName, LLAvatarTracker::instance().isBuddyOnline(buddy_id)); } modified = true; nadded++; } } } // Handle removed items. for (uuid_vec_t::const_iterator it=removed.begin(); it != removed.end(); it++) { removeItemByUUID(*it); modified = true; } // Handle filter. if (have_filter) { std::vector<LLSD> cur_values; getValues(cur_values); for (std::vector<LLSD>::const_iterator it=cur_values.begin(); it != cur_values.end(); it++) { const LLUUID& buddy_id = it->asUUID(); LLAvatarName av_name; have_names &= LLAvatarNameCache::get(buddy_id, &av_name); if (!findInsensitive(av_name.mDisplayName, mNameFilter)) { removeItemByUUID(buddy_id); modified = true; } } } // 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 sort(); // re-select items // selectMultiple(selected_ids); // TODO: implement in LLFlatListView if need selectItemByUUID(current_id); // If the name filter is specified and the names are incomplete, // we need to re-update when the names are complete so that // the filter can be applied correctly. // // Otherwise, if we have no filter then no need to update again // because the items will update their names. bool dirty = add_limit_exceeded || (have_filter && !have_names); setDirty(dirty); // Refreshed all items. if(!dirty) { // Highlight items matching the filter. std::vector<LLPanel*> items; getItems(items); for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++) { static_cast<LLAvatarListItem*>(*it)->setHighlight(mNameFilter); } // Send refresh_complete signal. mRefreshCompleteSignal(this, LLSD((S32)size(false))); } // Commit if we've added/removed items. if (modified) onCommit(); }
void LLAvatarList::refresh() { bool have_names = TRUE; bool add_limit_exceeded = false; bool modified = false; bool have_filter = !mNameFilter.empty(); // Save selection. std::vector<LLUUID> selected_ids; getSelectedUUIDs(selected_ids); LLUUID current_id = getSelectedUUID(); // Determine what to add and what to remove. std::vector<LLUUID> added, removed; LLAvatarList::computeDifference(getIDs(), added, removed); // Handle added items. unsigned nadded = 0; for (std::vector<LLUUID>::const_iterator it=added.begin(); it != added.end(); it++) { std::string name; const LLUUID& buddy_id = *it; have_names &= (bool)gCacheName->getFullName(buddy_id, name); if (!have_filter || findInsensitive(name, mNameFilter)) { if (nadded >= ADD_LIMIT) { add_limit_exceeded = true; break; } else { addNewItem(buddy_id, name, LLAvatarTracker::instance().isBuddyOnline(buddy_id)); modified = true; nadded++; } } } // Handle removed items. for (std::vector<LLUUID>::const_iterator it=removed.begin(); it != removed.end(); it++) { removeItemByUUID(*it); modified = true; } // Handle filter. if (have_filter) { std::vector<LLSD> cur_values; getValues(cur_values); for (std::vector<LLSD>::const_iterator it=cur_values.begin(); it != cur_values.end(); it++) { std::string name; const LLUUID& buddy_id = it->asUUID(); have_names &= (bool)gCacheName->getFullName(buddy_id, name); if (!findInsensitive(name, mNameFilter)) { removeItemByUUID(buddy_id); modified = true; } } } // 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 sort(); // re-select items // selectMultiple(selected_ids); // TODO: implement in LLFlatListView if need selectItemByUUID(current_id); // If the name filter is specified and the names are incomplete, // we need to re-update when the names are complete so that // the filter can be applied correctly. // // Otherwise, if we have no filter then no need to update again // because the items will update their names. bool dirty = add_limit_exceeded || (have_filter && !have_names); setDirty(dirty); // Refreshed all items. if(!dirty) { // Highlight items matching the filter. std::vector<LLPanel*> items; getItems(items); for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++) { static_cast<LLAvatarListItem*>(*it)->setHighlight(mNameFilter); } // Send refresh_complete signal. std::vector<LLSD> cur_values; getValues(cur_values); mRefreshCompleteSignal(this, LLSD((S32)cur_values.size())); } // Commit if we've added/removed items. if (modified) onCommit(); }