Add LLAvatarActions::buildResidentsString

This commit is contained in:
Lirusaito
2013-07-26 08:59:14 -04:00
parent cfaaac3c96
commit 37669a8abc
3 changed files with 63 additions and 0 deletions

View File

@@ -497,6 +497,48 @@ void LLAvatarActions::csr(const LLUUID& id)
// Singu TODO: Share inventory code block should live here
// static
void LLAvatarActions::buildResidentsString(std::vector<LLAvatarName> avatar_names, std::string& residents_string)
{
llassert(avatar_names.size() > 0);
std::sort(avatar_names.begin(), avatar_names.end());
const std::string& separator = LLTrans::getString("words_separator");
for (std::vector<LLAvatarName>::const_iterator it = avatar_names.begin(); ; )
{
residents_string.append((*it).getCompleteName());
if (++it == avatar_names.end())
{
break;
}
residents_string.append(separator);
}
}
// static
void LLAvatarActions::buildResidentsString(const uuid_vec_t& avatar_uuids, std::string& residents_string)
{
std::vector<LLAvatarName> avatar_names;
uuid_vec_t::const_iterator it = avatar_uuids.begin();
for (; it != avatar_uuids.end(); ++it)
{
LLAvatarName av_name;
if (LLAvatarNameCache::get(*it, &av_name))
{
avatar_names.push_back(av_name);
}
}
// We should check whether the vector is not empty to pass the assertion
// that avatar_names.size() > 0 in LLAvatarActions::buildResidentsString.
if (!avatar_names.empty())
{
LLAvatarActions::buildResidentsString(avatar_names, residents_string);
}
}
// Singu TODO: Share inventory code block should live here, too
// static
void LLAvatarActions::toggleBlock(const LLUUID& id)
{

View File

@@ -27,6 +27,7 @@
#ifndef LL_LLAVATARACTIONS_H
#define LL_LLAVATARACTIONS_H
class LLAvatarName;
class LLFloater;
/**
@@ -181,6 +182,22 @@ public:
*/
static bool canOfferTeleport(const uuid_vec_t& ids);
/**
* Builds a string of residents' display names separated by "words_separator" string.
*
* @param avatar_names - a vector of given avatar names from which resulting string is built
* @param residents_string - the resulting string
*/
static void buildResidentsString(std::vector<LLAvatarName> avatar_names, std::string& residents_string);
/**
* Builds a string of residents' display names separated by "words_separator" string.
*
* @param avatar_uuids - a vector of given avatar uuids from which resulting string is built
* @param residents_string - the resulting string
*/
static void buildResidentsString(const uuid_vec_t& avatar_uuids, std::string& residents_string);
private:
static bool callbackAddFriendWithMessage(const LLSD& notification, const LLSD& response);
static bool handleRemove(const LLSD& notification, const LLSD& response);

View File

@@ -4313,6 +4313,10 @@ Abuse Report</string>
<string name="dance7">dance7</string>
<string name="dance8">dance8</string>
<string name="DefaultMimeType">none/none</string>
<!-- language specific white-space characters, delimiters, spacers, item separation symbols -->
<string name="words_separator" value=", "/>
<string name="Chat">Chat</string>
<!-- External editor status codes -->