summaryrefslogtreecommitdiff
path: root/indra/newview/llavatarlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llavatarlist.cpp')
-rw-r--r--indra/newview/llavatarlist.cpp66
1 files changed, 52 insertions, 14 deletions
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 09083dcb98..ff7dfccc0a 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -38,6 +38,7 @@
// newview
#include "llagentdata.h" // for comparator
#include "llavatariconctrl.h"
+#include "llavatarnamecache.h"
#include "llcallingcard.h" // for LLAvatarTracker
#include "llcachename.h"
#include "lllistcontextmenu.h"
@@ -131,6 +132,7 @@ LLAvatarList::LLAvatarList(const Params& p)
, mShowLastInteractionTime(p.show_last_interaction_time)
, mContextMenu(NULL)
, mDirty(true) // to force initial update
+, mNeedUpdateNames(false)
, mLITUpdateTimer(NULL)
, mShowIcons(true)
, mShowInfoBtn(p.show_info_btn)
@@ -149,8 +151,17 @@ LLAvatarList::LLAvatarList(const Params& p)
mLITUpdateTimer->setTimerExpirySec(0); // zero to force initial update
mLITUpdateTimer->start();
}
+
+ LLAvatarNameCache::addUseDisplayNamesCallback(boost::bind(&LLAvatarList::handleDisplayNamesOptionChanged, this));
+}
+
+
+void LLAvatarList::handleDisplayNamesOptionChanged()
+{
+ mNeedUpdateNames = true;
}
+
LLAvatarList::~LLAvatarList()
{
delete mLITUpdateTimer;
@@ -170,6 +181,11 @@ void LLAvatarList::draw()
LLFlatListViewEx::draw();
+ if (mNeedUpdateNames)
+ {
+ updateAvatarNames();
+ }
+
if (mDirty)
refresh();
@@ -233,7 +249,6 @@ void LLAvatarList::addAvalineItem(const LLUUID& item_id, const LLUUID& session_i
//////////////////////////////////////////////////////////////////////////
// PROTECTED SECTION
//////////////////////////////////////////////////////////////////////////
-
void LLAvatarList::refresh()
{
bool have_names = TRUE;
@@ -252,12 +267,15 @@ void LLAvatarList::refresh()
// 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++)
{
- std::string name;
const LLUUID& buddy_id = *it;
- have_names &= (bool)gCacheName->getFullName(buddy_id, name);
- if (!have_filter || findInsensitive(name, mNameFilter))
+ LLAvatarName av_name;
+ have_names &= LLAvatarNameCache::get(buddy_id, &av_name);
+
+ if (!have_filter || findInsensitive(av_name.mDisplayName, mNameFilter))
{
if (nadded >= ADD_LIMIT)
{
@@ -266,7 +284,11 @@ void LLAvatarList::refresh()
}
else
{
- addNewItem(buddy_id, name, LLAvatarTracker::instance().isBuddyOnline(buddy_id));
+ // *NOTE: If you change the UI to show a different string,
+ // be sure to change the filter code below.
+ addNewItem(buddy_id,
+ av_name.mDisplayName.empty() ? waiting_str : av_name.mDisplayName,
+ LLAvatarTracker::instance().isBuddyOnline(buddy_id));
modified = true;
nadded++;
}
@@ -288,10 +310,10 @@ void LLAvatarList::refresh()
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))
+ LLAvatarName av_name;
+ have_names &= LLAvatarNameCache::get(buddy_id, &av_name);
+ if (!findInsensitive(av_name.mDisplayName, mNameFilter))
{
removeItemByUUID(buddy_id);
modified = true;
@@ -337,20 +359,34 @@ void LLAvatarList::refresh()
onCommit();
}
+void LLAvatarList::updateAvatarNames()
+{
+ std::vector<LLPanel*> items;
+ getItems(items);
+
+ for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++)
+ {
+ LLAvatarListItem* item = static_cast<LLAvatarListItem*>(*it);
+ item->updateAvatarName();
+ }
+ mNeedUpdateNames = false;
+}
+
+
bool LLAvatarList::filterHasMatches()
{
uuid_vec_t values = getIDs();
for (uuid_vec_t::const_iterator it=values.begin(); it != values.end(); it++)
{
- std::string name;
const LLUUID& buddy_id = *it;
- BOOL have_name = gCacheName->getFullName(buddy_id, name);
+ LLAvatarName av_name;
+ bool have_name = LLAvatarNameCache::get(buddy_id, &av_name);
// If name has not been loaded yet we consider it as a match.
// When the name will be loaded the filter will be applied again(in refresh()).
- if (have_name && !findInsensitive(name, mNameFilter))
+ if (have_name && !findInsensitive(av_name.mDisplayName, mNameFilter))
{
continue;
}
@@ -384,7 +420,7 @@ S32 LLAvatarList::notifyParent(const LLSD& info)
void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos)
{
LLAvatarListItem* item = new LLAvatarListItem();
- item->setName(name);
+ // This sets the name as a side effect
item->setAvatarId(id, mSessionID, mIgnoreOnlineStatus);
item->setOnline(mIgnoreOnlineStatus ? true : is_online);
item->showLastInteractionTime(mShowLastInteractionTime);
@@ -551,11 +587,13 @@ void LLAvalineListItem::setName(const std::string& name)
std::string hidden_name = LLTrans::getString("AvalineCaller", args);
LL_DEBUGS("Avaline") << "Avaline caller: " << uuid << ", name: " << hidden_name << LL_ENDL;
- LLAvatarListItem::setName(hidden_name);
+ LLAvatarListItem::setAvatarName(hidden_name);
+ LLAvatarListItem::setAvatarToolTip(hidden_name);
}
else
{
const std::string& formatted_phone = LLTextUtil::formatPhoneNumber(name);
- LLAvatarListItem::setName(formatted_phone);
+ LLAvatarListItem::setAvatarName(formatted_phone);
+ LLAvatarListItem::setAvatarToolTip(formatted_phone);
}
}