diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-04-15 10:50:28 +0100 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-04-15 10:50:28 +0100 |
commit | 6690cd65c4e9bf6680f4f0b9ea2d38a80eb3d268 (patch) | |
tree | 41c7d5fbcbd875152db63e4fa1137e7d8dd67588 /indra/newview/llavatarlist.cpp | |
parent | 5c29fa93838b4904fb236190bfe621cdfd33503c (diff) | |
parent | 9f0f610682e0bcceb88eaddcb7a02acfcf3d05ce (diff) |
merge from viewer-trunk
Diffstat (limited to 'indra/newview/llavatarlist.cpp')
-rw-r--r-- | indra/newview/llavatarlist.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index 407c5b6153..c7a5691d70 100644 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -32,13 +32,18 @@ #include "llviewerprecompiledheaders.h" +// common +#include "lltrans.h" + #include "llavatarlist.h" #include "llagentdata.h" // for comparator // newview +#include "llavatariconctrl.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llcachename.h" #include "llrecentpeople.h" +#include "lltextutil.h" #include "lluuid.h" #include "llvoiceclient.h" #include "llviewercontrol.h" // for gSavedSettings @@ -193,6 +198,18 @@ void LLAvatarList::setDirty(bool val /*= true*/, bool force_refresh /*= false*/) } } +void LLAvatarList::addAvalineItem(const LLUUID& item_id, const LLUUID& session_id, const std::string& item_name) +{ + LL_DEBUGS("Avaline") << "Adding avaline item into the list: " << item_name << "|" << item_id << ", session: " << session_id << LL_ENDL; + LLAvalineListItem* item = new LLAvalineListItem; + item->setAvatarId(item_id, session_id, true, false); + item->setName(item_name); + + addItem(item, item_id); + mIDs.push_back(item_id); + sort(); +} + ////////////////////////////////////////////////////////////////////////// // PROTECTED SECTION ////////////////////////////////////////////////////////////////////////// @@ -471,3 +488,61 @@ bool LLAvatarItemAgentOnTopComparator::doCompare(const LLAvatarListItem* avatar_ } return LLAvatarItemNameComparator::doCompare(avatar_item1,avatar_item2); } + +/************************************************************************/ +/* class LLAvalineListItem */ +/************************************************************************/ +LLAvalineListItem::LLAvalineListItem(bool hide_number/* = true*/) : LLAvatarListItem(false) +, mIsHideNumber(hide_number) +{ + // should not use buildPanel from the base class to ensure LLAvalineListItem::postBuild is called. + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_avatar_list_item.xml"); +} + +BOOL LLAvalineListItem::postBuild() +{ + BOOL rv = LLAvatarListItem::postBuild(); + + if (rv) + { + setOnline(true); + showLastInteractionTime(false); + setShowProfileBtn(false); + setShowInfoBtn(false); + mAvatarIcon->setValue("Avaline_Icon"); + mAvatarIcon->setToolTip(std::string("")); + } + return rv; +} + +// to work correctly this method should be called AFTER setAvatarId for avaline callers with hidden phone number +void LLAvalineListItem::setName(const std::string& name) +{ + if (mIsHideNumber) + { + static U32 order = 0; + typedef std::map<LLUUID, U32> avaline_callers_nums_t; + static avaline_callers_nums_t mAvalineCallersNums; + + llassert(getAvatarId() != LLUUID::null); + + const LLUUID &uuid = getAvatarId(); + + if (mAvalineCallersNums.find(uuid) == mAvalineCallersNums.end()) + { + mAvalineCallersNums[uuid] = ++order; + LL_DEBUGS("Avaline") << "Set name for new avaline caller: " << uuid << ", order: " << order << LL_ENDL; + } + LLStringUtil::format_map_t args; + args["[ORDER]"] = llformat("%u", mAvalineCallersNums[uuid]); + std::string hidden_name = LLTrans::getString("AvalineCaller", args); + + LL_DEBUGS("Avaline") << "Avaline caller: " << uuid << ", name: " << hidden_name << LL_ENDL; + LLAvatarListItem::setName(hidden_name); + } + else + { + const std::string& formatted_phone = LLTextUtil::formatPhoneNumber(name); + LLAvatarListItem::setName(formatted_phone); + } +} |