diff options
Diffstat (limited to 'indra/newview/llavatarlist.cpp')
-rw-r--r-- | indra/newview/llavatarlist.cpp | 163 |
1 files changed, 126 insertions, 37 deletions
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index 45c540b3a3..3275d784a3 100644 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -33,12 +33,22 @@ #include "llviewerprecompiledheaders.h" #include "llavatarlist.h" -#include "llagentdata.h" // for comparator + +// common +#include "lltrans.h" +#include "llcommonutils.h" + +// llui +#include "lltextutil.h" // newview +#include "llagentdata.h" // for comparator +#include "llavatariconctrl.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llcachename.h" +#include "lllistcontextmenu.h" #include "llrecentpeople.h" +#include "lluuid.h" #include "llvoiceclient.h" #include "llviewercontrol.h" // for gSavedSettings @@ -53,7 +63,7 @@ static const unsigned ADD_LIMIT = 50; bool LLAvatarList::contains(const LLUUID& id) { - const uuid_vector_t& ids = getIDs(); + const uuid_vec_t& ids = getIDs(); return std::find(ids.begin(), ids.end(), id) != ids.end(); } @@ -107,7 +117,7 @@ LLAvatarList::Params::Params() } LLAvatarList::LLAvatarList(const Params& p) -: LLFlatListView(p) +: LLFlatListViewEx(p) , mIgnoreOnlineStatus(p.ignore_online_status) , mShowLastInteractionTime(p.show_last_interaction_time) , mContextMenu(NULL) @@ -148,7 +158,7 @@ void LLAvatarList::draw() // *NOTE dzaporozhan // Call refresh() after draw() to avoid flickering of avatar list items. - LLFlatListView::draw(); + LLFlatListViewEx::draw(); if (mDirty) refresh(); @@ -165,14 +175,20 @@ void LLAvatarList::clear() { getIDs().clear(); setDirty(true); - LLFlatListView::clear(); + LLFlatListViewEx::clear(); } void LLAvatarList::setNameFilter(const std::string& filter) { - if (mNameFilter != filter) + std::string filter_upper = filter; + LLStringUtil::toUpper(filter_upper); + if (mNameFilter != filter_upper) { - mNameFilter = filter; + mNameFilter = filter_upper; + + // update message for empty state here instead of refresh() to avoid blinking when switch + // between tabs. + updateNoItemsMessage(filter); setDirty(); } } @@ -192,6 +208,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 ////////////////////////////////////////////////////////////////////////// @@ -204,17 +232,17 @@ void LLAvatarList::refresh() bool have_filter = !mNameFilter.empty(); // Save selection. - std::vector<LLUUID> selected_ids; + uuid_vec_t selected_ids; getSelectedUUIDs(selected_ids); LLUUID current_id = getSelectedUUID(); // Determine what to add and what to remove. - std::vector<LLUUID> added, removed; + uuid_vec_t 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++) + for (uuid_vec_t::const_iterator it=added.begin(); it != added.end(); it++) { std::string name; const LLUUID& buddy_id = *it; @@ -236,7 +264,7 @@ void LLAvatarList::refresh() } // Handle removed items. - for (std::vector<LLUUID>::const_iterator it=removed.begin(); it != removed.end(); it++) + for (uuid_vec_t::const_iterator it=removed.begin(); it != removed.end(); it++) { removeItemByUUID(*it); modified = true; @@ -291,9 +319,7 @@ void LLAvatarList::refresh() } // Send refresh_complete signal. - std::vector<LLSD> cur_values; - getValues(cur_values); - mRefreshCompleteSignal(this, LLSD((S32)cur_values.size())); + mRefreshCompleteSignal(this, LLSD((S32)size(false))); } // Commit if we've added/removed items. @@ -303,9 +329,9 @@ void LLAvatarList::refresh() bool LLAvatarList::filterHasMatches() { - uuid_vector_t values = getIDs(); + uuid_vec_t values = getIDs(); - for (uuid_vector_t::const_iterator it=values.begin(); it != values.end(); it++) + for (uuid_vec_t::const_iterator it=values.begin(); it != values.end(); it++) { std::string name; const LLUUID& buddy_id = *it; @@ -334,6 +360,17 @@ boost::signals2::connection LLAvatarList::setItemDoubleClickCallback(const mouse return mItemDoubleClickSignal.connect(cb); } +//virtual +S32 LLAvatarList::notifyParent(const LLSD& info) +{ + if (info.has("sort") && &NAME_COMPARATOR == mItemComparator) + { + sort(); + return 1; + } + return LLFlatListViewEx::notifyParent(info); +} + void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos) { LLAvatarListItem* item = new LLAvatarListItem(); @@ -358,20 +395,28 @@ BOOL LLAvatarList::handleRightMouseDown(S32 x, S32 y, MASK mask) BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask); if ( mContextMenu ) { - std::vector<LLUUID> selected_uuids; + uuid_vec_t selected_uuids; getSelectedUUIDs(selected_uuids); mContextMenu->show(this, selected_uuids, x, y); } return handled; } +void LLAvatarList::setVisible(BOOL visible) +{ + if ( visible == FALSE && mContextMenu ) + { + mContextMenu->hide(); + } + LLFlatListViewEx::setVisible(visible); +} + void LLAvatarList::computeDifference( - const std::vector<LLUUID>& vnew_unsorted, - std::vector<LLUUID>& vadded, - std::vector<LLUUID>& vremoved) + const uuid_vec_t& vnew_unsorted, + uuid_vec_t& vadded, + uuid_vec_t& vremoved) { - std::vector<LLUUID> vcur; - std::vector<LLUUID> vnew = vnew_unsorted; + uuid_vec_t vcur; // Convert LLSDs to LLUUIDs. { @@ -382,21 +427,7 @@ void LLAvatarList::computeDifference( vcur.push_back(vcur_values[i].asUUID()); } - std::sort(vcur.begin(), vcur.end()); - std::sort(vnew.begin(), vnew.end()); - - std::vector<LLUUID>::iterator it; - size_t maxsize = llmax(vcur.size(), vnew.size()); - vadded.resize(maxsize); - vremoved.resize(maxsize); - - // what to remove - it = set_difference(vcur.begin(), vcur.end(), vnew.begin(), vnew.end(), vremoved.begin()); - vremoved.erase(it, vremoved.end()); - - // what to add - it = set_difference(vnew.begin(), vnew.end(), vcur.begin(), vcur.end(), vadded.begin()); - vadded.erase(it, vadded.end()); + LLCommonUtils::computeDifference(vnew_unsorted, vcur, vadded, vremoved); } // Refresh shown time of our last interaction with all listed avatars. @@ -459,3 +490,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); + } +} |