LLFloaterAvatarPicker now uses LLAvatarNames

reviewed by James
master
Leyla Farazha 2010-05-25 14:15:26 -07:00
parent 216c7d3e9a
commit 7fb9410422
15 changed files with 113 additions and 82 deletions

View File

@ -36,8 +36,6 @@
// Viewer includes
#include "llagent.h"
#include "llcallingcard.h"
#include "lldate.h" // split()
#include "lldateutil.h" // ageFromDate()
#include "llfocusmgr.h"
#include "llfloaterreg.h"
#include "llimview.h" // for gIMMgr
@ -61,6 +59,9 @@
//#include "llsdserialize.h"
//put it back as a member once the legacy path is out?
static std::map<LLUUID, LLAvatarName> sAvatarNameMap;
LLFloaterAvatarPicker* LLFloaterAvatarPicker::show(select_callback_t callback,
BOOL allow_multiple,
BOOL closeOnSelect)
@ -167,7 +168,7 @@ void LLFloaterAvatarPicker::onBtnFind()
find();
}
static void getSelectedAvatarData(const LLScrollListCtrl* from, std::vector<std::string>& avatar_names, uuid_vec_t& avatar_ids)
static void getSelectedAvatarData(const LLScrollListCtrl* from, uuid_vec_t& avatar_ids, std::vector<LLAvatarName>& avatar_names)
{
std::vector<LLScrollListItem*> items = from->getAllSelected();
for (std::vector<LLScrollListItem*>::iterator iter = items.begin(); iter != items.end(); ++iter)
@ -175,8 +176,8 @@ static void getSelectedAvatarData(const LLScrollListCtrl* from, std::vector<std:
LLScrollListItem* item = *iter;
if (item->getUUID().notNull())
{
avatar_names.push_back(item->getColumn(0)->getValue().asString());
avatar_ids.push_back(item->getUUID());
avatar_names.push_back(sAvatarNameMap[item->getUUID()]);
}
}
}
@ -212,10 +213,10 @@ void LLFloaterAvatarPicker::onBtnSelect()
if(list)
{
std::vector<std::string> avatar_names;
uuid_vec_t avatar_ids;
getSelectedAvatarData(list, avatar_names, avatar_ids);
mSelectionCallback(avatar_names, avatar_ids);
std::vector<LLAvatarName> avatar_names;
getSelectedAvatarData(list, avatar_ids, avatar_names);
mSelectionCallback(avatar_ids, avatar_names);
}
}
getChild<LLScrollListCtrl>("SearchResults")->deselectAllItems(TRUE);
@ -380,6 +381,9 @@ public:
void LLFloaterAvatarPicker::find()
{
//clear our stored LLAvatarNames
sAvatarNameMap.clear();
std::string text = childGetValue("Edit").asString();
mQueryID.generate();
@ -547,6 +551,14 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void*
avatar_name = LLCacheName::buildFullName(first_name, last_name);
search_results->setEnabled(TRUE);
found_one = TRUE;
LLAvatarName av_name;
av_name.mLegacyFirstName = first_name;
av_name.mLegacyLastName = last_name;
av_name.mDisplayName = avatar_name;
const LLUUID& agent_id = avatar_id;
sAvatarNameMap[agent_id] = av_name;
}
LLSD element;
element["id"] = avatar_id; // value
@ -594,20 +606,18 @@ void LLFloaterAvatarPicker::processResponse(const LLUUID& query_id, const LLSD&
for ( ; it != agents.endArray(); ++it)
{
const LLSD& row = *it;
item["id"] = row["agent_id"];
item["id"] = row["id"];
LLSD& columns = item["columns"];
columns[0]["column"] = "name";
columns[0]["value"] = row["display_name"];
columns[1]["column"] = "slid";
columns[1]["value"] = row["sl_id"];
LLDate account_created = row["account_created"].asDate();
S32 year, month, day;
account_created.split(&year, &month, &day);
std::string age =
LLDateUtil::ageFromDate(account_created, LLDate::now());
columns[2]["column"] = "age";
columns[2]["value"] = age;
columns[1]["column"] = "username";
columns[1]["value"] = row["username"];
search_results->addElement(item);
// add the avatar name to our list
LLAvatarName avatar_name;
avatar_name.fromLLSD(row);
sAvatarNameMap[row["id"].asUUID()] = avatar_name;
}
childEnable("ok_btn");
@ -678,8 +688,8 @@ bool LLFloaterAvatarPicker::isSelectBtnEnabled()
if(list)
{
uuid_vec_t avatar_ids;
std::vector<std::string> avatar_names;
getSelectedAvatarData(list, avatar_names, avatar_ids);
std::vector<LLAvatarName> avatar_names;
getSelectedAvatarData(list, avatar_ids, avatar_names);
return mOkButtonValidateSignal(avatar_ids);
}
}

View File

@ -37,6 +37,7 @@
#include <vector>
class LLAvatarName;
class LLScrollListCtrl;
class LLFloaterAvatarPicker : public LLFloater
@ -46,7 +47,7 @@ public:
typedef validate_signal_t::slot_type validate_callback_t;
// The callback function will be called with an avatar name and UUID.
typedef boost::function<void (const std::vector<std::string>&, const uuid_vec_t&)> select_callback_t;
typedef boost::function<void (const uuid_vec_t&, const std::vector<LLAvatarName>&)> select_callback_t;
// Call this to select an avatar.
static LLFloaterAvatarPicker* show(select_callback_t callback,
BOOL allow_multiple = FALSE,

View File

@ -34,6 +34,7 @@
#include "llfloatergodtools.h"
#include "llavatarnamecache.h"
#include "llcoord.h"
#include "llfontgl.h"
#include "llframetimer.h"
@ -1151,11 +1152,11 @@ void LLPanelObjectTools::onClickSetBySelection(void* data)
panelp->childSetValue("target_avatar_name", name);
}
void LLPanelObjectTools::callbackAvatarID(const std::vector<std::string>& names, const uuid_vec_t& ids)
void LLPanelObjectTools::callbackAvatarID(const uuid_vec_t& ids, const std::vector<LLAvatarName> names)
{
if (ids.empty() || names.empty()) return;
mTargetAvatar = ids[0];
childSetValue("target_avatar_name", names[0]);
childSetValue("target_avatar_name", names[0].getNameAndSLID());
refresh();
}

View File

@ -41,6 +41,7 @@
#include "llpanel.h"
#include <vector>
class LLAvatarName;
class LLButton;
class LLCheckBoxCtrl;
class LLComboBox;
@ -231,7 +232,7 @@ public:
void onChangeAnything();
void onApplyChanges();
void onClickSet();
void callbackAvatarID(const std::vector<std::string>& names, const uuid_vec_t& ids);
void callbackAvatarID(const uuid_vec_t& ids, const std::vector<LLAvatarName> names);
void onClickDeletePublicOwnedBy();
void onClickDeleteAllScriptedOwnedBy();
void onClickDeleteAllOwnedBy();

View File

@ -2769,12 +2769,12 @@ void LLPanelLandAccess::onCommitAny(LLUICtrl *ctrl, void *userdata)
void LLPanelLandAccess::onClickAddAccess()
{
gFloaterView->getParentFloater(this)->addDependentFloater(LLFloaterAvatarPicker::show(boost::bind(&LLPanelLandAccess::callbackAvatarCBAccess, this, _1,_2)) );
gFloaterView->getParentFloater(this)->addDependentFloater(LLFloaterAvatarPicker::show(boost::bind(&LLPanelLandAccess::callbackAvatarCBAccess, this, _1)) );
}
void LLPanelLandAccess::callbackAvatarCBAccess(const std::vector<std::string>& names, const uuid_vec_t& ids)
void LLPanelLandAccess::callbackAvatarCBAccess(const uuid_vec_t& ids)
{
if (!names.empty() && !ids.empty())
if (!ids.empty())
{
LLUUID id = ids[0];
LLParcel* parcel = mParcel->getParcel();
@ -2813,13 +2813,13 @@ void LLPanelLandAccess::onClickRemoveAccess(void* data)
// static
void LLPanelLandAccess::onClickAddBanned()
{
gFloaterView->getParentFloater(this)->addDependentFloater(LLFloaterAvatarPicker::show(boost::bind(&LLPanelLandAccess::callbackAvatarCBBanned, this, _1,_2)));
gFloaterView->getParentFloater(this)->addDependentFloater(LLFloaterAvatarPicker::show(boost::bind(&LLPanelLandAccess::callbackAvatarCBBanned, this, _1)));
}
// static
void LLPanelLandAccess::callbackAvatarCBBanned(const std::vector<std::string>& names, const uuid_vec_t& ids)
void LLPanelLandAccess::callbackAvatarCBBanned(const uuid_vec_t& ids)
{
if (!names.empty() && !ids.empty())
if (!ids.empty())
{
LLUUID id = ids[0];
LLParcel* parcel = mParcel->getParcel();

View File

@ -379,8 +379,8 @@ public:
void onClickAddAccess();
void onClickAddBanned();
void callbackAvatarCBBanned(const std::vector<std::string>& names, const uuid_vec_t& ids);
void callbackAvatarCBAccess(const std::vector<std::string>& names, const uuid_vec_t& ids);
void callbackAvatarCBBanned(const uuid_vec_t& ids);
void callbackAvatarCBAccess(const uuid_vec_t& ids);
protected:
LLNameListCtrl* mListAccess;

View File

@ -49,6 +49,7 @@
#include "llagent.h"
#include "llappviewer.h"
#include "llavatarname.h"
#include "llfloateravatarpicker.h"
#include "llbutton.h"
#include "llcheckboxctrl.h"
@ -606,13 +607,13 @@ void LLPanelRegionGeneralInfo::onClickKick()
// this depends on the grandparent view being a floater
// in order to set up floater dependency
LLFloater* parent_floater = gFloaterView->getParentFloater(this);
LLFloater* child_floater = LLFloaterAvatarPicker::show(boost::bind(&LLPanelRegionGeneralInfo::onKickCommit, this, _1,_2), FALSE, TRUE);
LLFloater* child_floater = LLFloaterAvatarPicker::show(boost::bind(&LLPanelRegionGeneralInfo::onKickCommit, this, _1), FALSE, TRUE);
parent_floater->addDependentFloater(child_floater);
}
void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& names, const uuid_vec_t& ids)
void LLPanelRegionGeneralInfo::onKickCommit(const uuid_vec_t& ids)
{
if (names.empty() || ids.empty()) return;
if (ids.empty()) return;
if(ids[0].notNull())
{
strings_t strings;
@ -848,11 +849,11 @@ void LLPanelRegionDebugInfo::onClickChooseAvatar()
}
void LLPanelRegionDebugInfo::callbackAvatarID(const std::vector<std::string>& names, const uuid_vec_t& ids)
void LLPanelRegionDebugInfo::callbackAvatarID(const uuid_vec_t& ids, const std::vector<LLAvatarName> names)
{
if (ids.empty() || names.empty()) return;
mTargetAvatar = ids[0];
childSetValue("target_avatar_name", LLSD(names[0]));
childSetValue("target_avatar_name", names[0].getNameAndSLID());
refreshFromRegion( gAgent.getRegion() );
}
@ -1527,24 +1528,17 @@ void LLPanelEstateInfo::onClickKickUser()
// this depends on the grandparent view being a floater
// in order to set up floater dependency
LLFloater* parent_floater = gFloaterView->getParentFloater(this);
LLFloater* child_floater = LLFloaterAvatarPicker::show(boost::bind(&LLPanelEstateInfo::onKickUserCommit, this, _1, _2), FALSE, TRUE);
LLFloater* child_floater = LLFloaterAvatarPicker::show(boost::bind(&LLPanelEstateInfo::onKickUserCommit, this, _1), FALSE, TRUE);
parent_floater->addDependentFloater(child_floater);
}
void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names, const uuid_vec_t& ids)
void LLPanelEstateInfo::onKickUserCommit(const uuid_vec_t& ids)
{
if (names.empty() || ids.empty()) return;
if (ids.empty()) return;
//check to make sure there is one valid user and id
if( (ids[0].isNull()) ||
(names[0].length() == 0) )
{
return;
}
//Bring up a confirmation dialog
LLSD args;
args["EVIL_USER"] = names[0];
args["EVIL_USER"] = LLSLURL("agent", ids[0], "inspect").getSLURLString();
LLSD payload;
payload["agent_id"] = ids[0];
LLNotificationsUtil::add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, this, _1, _2));
@ -1710,12 +1704,12 @@ bool LLPanelEstateInfo::accessAddCore2(const LLSD& notification, const LLSD& res
LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo(notification["payload"]);
// avatar picker yes multi-select, yes close-on-select
LLFloaterAvatarPicker::show(boost::bind(&LLPanelEstateInfo::accessAddCore3, _1, _2, (void*)change_info), TRUE, TRUE);
LLFloaterAvatarPicker::show(boost::bind(&LLPanelEstateInfo::accessAddCore3, _1, (void*)change_info), TRUE, TRUE);
return false;
}
// static
void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, const uuid_vec_t& ids, void* data)
void LLPanelEstateInfo::accessAddCore3(const uuid_vec_t& ids, void* data)
{
LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data;
if (!change_info) return;

View File

@ -40,6 +40,7 @@
#include "llhost.h"
#include "llpanel.h"
class LLAvatarName;
class LLDispatcher;
class LLLineEditor;
class LLMessageSystem;
@ -168,7 +169,7 @@ public:
protected:
virtual BOOL sendUpdate();
void onClickKick();
void onKickCommit(const std::vector<std::string>& names, const uuid_vec_t& ids);
void onKickCommit(const uuid_vec_t& ids);
static void onClickKickAll(void* userdata);
bool onKickAllCommit(const LLSD& notification, const LLSD& response);
static void onClickMessage(void* userdata);
@ -193,7 +194,7 @@ protected:
virtual BOOL sendUpdate();
void onClickChooseAvatar();
void callbackAvatarID(const std::vector<std::string>& names, const uuid_vec_t& ids);
void callbackAvatarID(const uuid_vec_t& ids, const std::vector<LLAvatarName> names);
static void onClickReturn(void *);
bool callbackReturn(const LLSD& notification, const LLSD& response);
static void onClickTopColliders(void*);
@ -284,7 +285,7 @@ public:
// Core methods for all above add/remove button clicks
static void accessAddCore(U32 operation_flag, const std::string& dialog_name);
static bool accessAddCore2(const LLSD& notification, const LLSD& response);
static void accessAddCore3(const std::vector<std::string>& names, const uuid_vec_t& ids, void* data);
static void accessAddCore3(const uuid_vec_t& ids, void* data);
static void accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name);
static bool accessRemoveCore2(const LLSD& notification, const LLSD& response);
@ -296,7 +297,7 @@ public:
// Send the actual EstateOwnerRequest "estateaccessdelta" message
static void sendEstateAccessDelta(U32 flags, const LLUUID& agent_id);
void onKickUserCommit(const std::vector<std::string>& names, const uuid_vec_t& ids);
void onKickUserCommit(const uuid_vec_t& ids);
static void onClickMessageEstate(void* data);
bool onMessageCommit(const LLSD& notification, const LLSD& response);

View File

@ -98,7 +98,7 @@ private:
bool onConfirmSale(const LLSD& notification, const LLSD& response);
static void doShowObjects(void *userdata);
void callbackAvatarPick(const std::vector<std::string>& names, const uuid_vec_t& ids);
void callbackAvatarPick(const uuid_vec_t& ids, const std::vector<LLAvatarName> names);
void onBuyerNameCache(const LLAvatarName& av_name);
@ -401,7 +401,7 @@ void LLFloaterSellLandUI::doSelectAgent()
addDependentFloater(LLFloaterAvatarPicker::show(boost::bind(&LLFloaterSellLandUI::callbackAvatarPick, this, _1, _2), FALSE, TRUE));
}
void LLFloaterSellLandUI::callbackAvatarPick(const std::vector<std::string>& names, const uuid_vec_t& ids)
void LLFloaterSellLandUI::callbackAvatarPick(const uuid_vec_t& ids, const std::vector<LLAvatarName> names)
{
LLParcel* parcel = mParcelSelection->getParcel();
@ -412,7 +412,7 @@ void LLFloaterSellLandUI::callbackAvatarPick(const std::vector<std::string>& nam
mAuthorizedBuyer = ids[0];
childSetText("sell_to_agent", names[0]);
childSetText("sell_to_agent", names[0].getNameAndSLID());
refreshUI();
}

View File

@ -35,6 +35,7 @@
#include "llpanelblockedlist.h"
// library include
#include "llavatarname.h"
#include "llfloater.h"
#include "llfloaterreg.h"
#include "llnotificationsutil.h"
@ -186,10 +187,10 @@ void LLPanelBlockedList::onBlockByNameClick()
LLFloaterGetBlockedObjectName::show(&LLPanelBlockedList::callbackBlockByName);
}
void LLPanelBlockedList::callbackBlockPicked(const std::vector<std::string>& names, const uuid_vec_t& ids)
void LLPanelBlockedList::callbackBlockPicked(const uuid_vec_t& ids, const std::vector<LLAvatarName> names)
{
if (names.empty() || ids.empty()) return;
LLMute mute(ids[0], names[0], LLMute::AGENT);
LLMute mute(ids[0], names[0].getLegacyName(), LLMute::AGENT);
LLMuteList::getInstance()->add(mute);
showPanelAndSelect(mute.mID);
}

View File

@ -42,7 +42,8 @@
// class LLLineEditor;
// class LLMessageSystem;
// class LLUUID;
class LLScrollListCtrl;
class LLAvatarName;
class LLScrollListCtrl;
class LLPanelBlockedList
: public LLPanel, public LLMuteListObserver
@ -78,7 +79,7 @@ private:
void onPickBtnClick();
void onBlockByNameClick();
void callbackBlockPicked(const std::vector<std::string>& names, const uuid_vec_t& ids);
void callbackBlockPicked(const uuid_vec_t& ids, const std::vector<LLAvatarName> names);
static void callbackBlockByName(const std::string& text);
private:

View File

@ -34,6 +34,7 @@
#include "llpanelgroupinvite.h"
#include "llagent.h"
#include "llavatarnamecache.h"
#include "llfloateravatarpicker.h"
#include "llbutton.h"
#include "llcallingcard.h"
@ -68,9 +69,13 @@ public:
static void callbackClickAdd(void* userdata);
static void callbackClickRemove(void* userdata);
static void callbackSelect(LLUICtrl* ctrl, void* userdata);
static void callbackAddUsers(const std::vector<std::string>& names,
const uuid_vec_t& agent_ids,
static void callbackAddUsers(const uuid_vec_t& agent_ids,
void* user_data);
static void onAvatarNameCache(const LLUUID& agent_id,
const LLAvatarName& av_name,
void* user_data);
bool inviteOwnerCallback(const LLSD& notification, const LLSD& response);
public:
@ -293,7 +298,7 @@ void LLPanelGroupInvite::impl::callbackClickAdd(void* userdata)
LLFloater* parentp;
parentp = gFloaterView->getParentFloater(panelp);
parentp->addDependentFloater(LLFloaterAvatarPicker::show(boost::bind(impl::callbackAddUsers, _1, _2,
parentp->addDependentFloater(LLFloaterAvatarPicker::show(boost::bind(impl::callbackAddUsers, _1,
panelp->mImplementation),
TRUE));
}
@ -359,16 +364,38 @@ void LLPanelGroupInvite::impl::callbackClickOK(void* userdata)
if ( selfp ) selfp->submitInvitations();
}
//static
void LLPanelGroupInvite::impl::callbackAddUsers(const std::vector<std::string>& names,
const uuid_vec_t& ids,
void* user_data)
void LLPanelGroupInvite::impl::callbackAddUsers(const uuid_vec_t& agent_ids, void* user_data)
{
std::vector<std::string> names;
for (S32 i = 0; i < (S32)agent_ids.size(); i++)
{
LLAvatarNameCache::get(agent_ids[i],
boost::bind(&LLPanelGroupInvite::impl::onAvatarNameCache, _1, _2, user_data));
}
}
void LLPanelGroupInvite::impl::onAvatarNameCache(const LLUUID& agent_id,
const LLAvatarName& av_name,
void* user_data)
{
impl* selfp = (impl*) user_data;
if ( selfp) selfp->addUsers(names, ids);
if (selfp)
{
std::vector<std::string> names;
uuid_vec_t agent_ids;
agent_ids.push_back(agent_id);
names.push_back(av_name.getNameAndSLID());
selfp->addUsers(names, agent_ids);
}
}
LLPanelGroupInvite::LLPanelGroupInvite(const LLUUID& group_id)
: LLPanel(),
mImplementation(new impl(group_id)),

View File

@ -33,6 +33,7 @@
#include "llviewerprecompiledheaders.h"
// libs
#include "llavatarname.h"
#include "llfloaterreg.h"
#include "llmenugl.h"
#include "llnotificationsutil.h"
@ -1161,12 +1162,10 @@ void LLPanelPeople::onActivateButtonClicked()
}
// static
void LLPanelPeople::onAvatarPicked(
const std::vector<std::string>& names,
const uuid_vec_t& ids)
void LLPanelPeople::onAvatarPicked(const uuid_vec_t& ids, const std::vector<LLAvatarName> names)
{
if (!names.empty() && !ids.empty())
LLAvatarActions::requestFriendshipDialog(ids[0], names[0]);
LLAvatarActions::requestFriendshipDialog(ids[0], names[0].getNameAndSLID());
}
void LLPanelPeople::onGroupPlusButtonClicked()

View File

@ -38,10 +38,11 @@
#include "llcallingcard.h" // for avatar tracker
#include "llvoiceclient.h"
class LLFilterEditor;
class LLTabContainer;
class LLAvatarList;
class LLAvatarName;
class LLFilterEditor;
class LLGroupList;
class LLTabContainer;
class LLPanelPeople
: public LLPanel
@ -133,9 +134,7 @@ private:
bool onNearbyViewSortMenuItemCheck(const LLSD& userdata);
// misc callbacks
static void onAvatarPicked(
const std::vector<std::string>& names,
const uuid_vec_t& ids);
static void onAvatarPicked(const uuid_vec_t& ids, const std::vector<LLAvatarName> names);
void onFriendsAccordionExpandedCollapsed(LLUICtrl* ctrl, const LLSD& param, LLAvatarList* avatar_list);

View File

@ -97,12 +97,8 @@
name="name"
width="100" />
<columns
label="SL ID"
name="slid"
width="100" />
<columns
label="Age"
name="age"
label="Username"
name="username"
width="100" />
</scroll_list>
</panel>