diff options
Diffstat (limited to 'indra/newview/llnamelistctrl.cpp')
-rw-r--r-- | indra/newview/llnamelistctrl.cpp | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp index 6521ae3b1e..38100aa6c5 100644 --- a/indra/newview/llnamelistctrl.cpp +++ b/indra/newview/llnamelistctrl.cpp @@ -30,6 +30,7 @@ #include <boost/tokenizer.hpp> +#include "llavatarnamecache.h" #include "llcachename.h" #include "llfloaterreg.h" #include "llinventory.h" @@ -38,6 +39,7 @@ #include "llscrolllistcolumn.h" #include "llsdparam.h" #include "lltooltip.h" +#include "lltrans.h" static LLDefaultChildRegistry::Register<LLNameListCtrl> r("name_list"); @@ -52,7 +54,8 @@ void LLNameListCtrl::NameTypeNames::declareValues() LLNameListCtrl::Params::Params() : name_column(""), - allow_calling_card_drop("allow_calling_card_drop", false) + allow_calling_card_drop("allow_calling_card_drop", false), + short_names("short_names", false) { name = "name_list"; } @@ -61,7 +64,8 @@ LLNameListCtrl::LLNameListCtrl(const LLNameListCtrl::Params& p) : LLScrollListCtrl(p), mNameColumnIndex(p.name_column.column_index), mNameColumn(p.name_column.column_name), - mAllowCallingCardDrop(p.allow_calling_card_drop) + mAllowCallingCardDrop(p.allow_calling_card_drop), + mShortNames(p.short_names) {} // public @@ -292,10 +296,24 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow( break; case INDIVIDUAL: { - std::string name; - if (gCacheName->getFullName(id, name)) + LLAvatarName av_name; + if (id.isNull()) { - fullname = name; + fullname = LLTrans::getString("AvatarNameNobody"); + } + else if (LLAvatarNameCache::get(id, &av_name)) + { + if (mShortNames) + fullname = av_name.mDisplayName; + else + fullname = av_name.getCompleteName(); + } + else + { + // ...schedule a callback + LLAvatarNameCache::get(id, + boost::bind(&LLNameListCtrl::onAvatarNameCache, + this, _1, _2)); } break; } @@ -350,34 +368,25 @@ void LLNameListCtrl::removeNameItem(const LLUUID& agent_id) } } -// public -void LLNameListCtrl::refresh(const LLUUID& id, const std::string& first, - const std::string& last, BOOL is_group) +void LLNameListCtrl::onAvatarNameCache(const LLUUID& agent_id, + const LLAvatarName& av_name) { - //llinfos << "LLNameListCtrl::refresh " << id << " '" << first << " " - // << last << "'" << llendl; - - std::string fullname; - if (!is_group) - { - fullname = first + " " + last; - } + std::string name; + if (mShortNames) + name = av_name.mDisplayName; else - { - fullname = first; - } + name = av_name.getCompleteName(); - // TODO: scan items for that ID, fix if necessary item_list::iterator iter; for (iter = getItemList().begin(); iter != getItemList().end(); iter++) { LLScrollListItem* item = *iter; - if (item->getUUID() == id) + if (item->getUUID() == agent_id) { LLScrollListCell* cell = item->getColumn(mNameColumnIndex); if (cell) { - cell->setValue(fullname); + cell->setValue(name); } } } @@ -386,19 +395,6 @@ void LLNameListCtrl::refresh(const LLUUID& id, const std::string& first, } -// static -void LLNameListCtrl::refreshAll(const LLUUID& id, const std::string& first, - const std::string& last, BOOL is_group) -{ - LLInstanceTrackerScopedGuard guard; - LLInstanceTracker<LLNameListCtrl>::instance_iter it; - for (it = guard.beginInstances(); it != guard.endInstances(); ++it) - { - LLNameListCtrl& ctrl = *it; - ctrl.refresh(id, first, last, is_group); - } -} - void LLNameListCtrl::updateColumns() { LLScrollListCtrl::updateColumns(); |