summaryrefslogtreecommitdiff
path: root/indra/newview/llnamelistctrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llnamelistctrl.cpp')
-rw-r--r--indra/newview/llnamelistctrl.cpp80
1 files changed, 59 insertions, 21 deletions
diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp
index 7e6145f578..6375362ae2 100644
--- a/indra/newview/llnamelistctrl.cpp
+++ b/indra/newview/llnamelistctrl.cpp
@@ -74,12 +74,12 @@ void LLNameListCtrl::addNameItem(const LLUUID& agent_id, EAddPosition pos,
{
//llinfos << "LLNameListCtrl::addNameItem " << agent_id << llendl;
- std::string fullname;
- gCacheName->getFullName(agent_id, fullname);
-
- fullname.append(suffix);
+ NameItem item;
+ item.value = agent_id;
+ item.enabled = enabled;
+ item.target = INDIVIDUAL;
- addStringUUIDItem(fullname, agent_id, pos, enabled);
+ addNameItemRow(item, pos);
}
// virtual, public
@@ -130,11 +130,12 @@ BOOL LLNameListCtrl::handleDragAndDrop(
return handled;
}
-void LLNameListCtrl::showAvatarInspector(const LLUUID& avatar_id)
+void LLNameListCtrl::showInspector(const LLUUID& avatar_id, bool is_group)
{
- LLSD key;
- key["avatar_id"] = avatar_id;
- LLFloaterReg::showInstance("inspect_avatar", key);
+ if (is_group)
+ LLFloaterReg::showInstance("inspect_group", LLSD().with("group_id", avatar_id));
+ else
+ LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", avatar_id));
}
//virtual
@@ -147,7 +148,7 @@ BOOL LLNameListCtrl::handleToolTip(S32 x, S32 y, MASK mask)
&& column_index == mNameColumnIndex)
{
// ...this is the column with the avatar name
- LLUUID avatar_id = hit_item->getValue().asUUID();
+ LLUUID avatar_id = getItemId(hit_item);
if (avatar_id.notNull())
{
// ...valid avatar id
@@ -164,9 +165,12 @@ BOOL LLNameListCtrl::handleToolTip(S32 x, S32 y, MASK mask)
LLCoordGL pos( sticky_rect.mRight - 16, sticky_rect.mTop );
LLPointer<LLUIImage> icon = LLUI::getUIImage("Info_Small");
+ // Should we show a group or an avatar inspector?
+ bool is_group = hit_item->getValue()["is_group"].asBoolean();
+
LLToolTip::Params params;
params.background_visible( false );
- params.click_callback( boost::bind(&LLNameListCtrl::showAvatarInspector, this, avatar_id) );
+ params.click_callback( boost::bind(&LLNameListCtrl::showInspector, this, avatar_id, is_group) );
params.delay_time(0.0f); // spawn instantly on hover
params.image( icon );
params.message("");
@@ -220,9 +224,22 @@ LLScrollListItem* LLNameListCtrl::addElement(const LLSD& element, EAddPosition p
}
-LLScrollListItem* LLNameListCtrl::addNameItemRow(const LLNameListCtrl::NameItem& name_item, EAddPosition pos)
+LLScrollListItem* LLNameListCtrl::addNameItemRow(
+ const LLNameListCtrl::NameItem& name_item,
+ EAddPosition pos,
+ std::string& suffix)
{
- LLScrollListItem* item = LLScrollListCtrl::addRow(name_item, pos);
+ LLUUID id = name_item.value().asUUID();
+ LLScrollListItem* item = NULL;
+
+ // Store item type so that we can invoke the proper inspector.
+ // *TODO Vadim: Is there a more proper way of storing additional item data?
+ {
+ LLNameListCtrl::NameItem name_item_(name_item);
+ name_item_.value = LLSD().with("uuid", id).with("is_group", name_item.target() == GROUP);
+ item = LLScrollListCtrl::addRow(name_item_, pos);
+ }
+
if (!item) return NULL;
// use supplied name by default
@@ -230,7 +247,7 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow(const LLNameListCtrl::NameItem&
switch(name_item.target)
{
case GROUP:
- gCacheName->getGroupName(name_item.value().asUUID(), fullname);
+ gCacheName->getGroupName(id, fullname);
// fullname will be "nobody" if group not found
break;
case SPECIAL:
@@ -239,7 +256,7 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow(const LLNameListCtrl::NameItem&
case INDIVIDUAL:
{
std::string name;
- if (gCacheName->getFullName(name_item.value().asUUID(), name))
+ if (gCacheName->getFullName(id, name))
{
fullname = name;
}
@@ -249,6 +266,12 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow(const LLNameListCtrl::NameItem&
break;
}
+ // Append optional suffix.
+ if (!suffix.empty())
+ {
+ fullname.append(suffix);
+ }
+
LLScrollListCell* cell = item->getColumn(mNameColumnIndex);
if (cell)
{
@@ -270,15 +293,24 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow(const LLNameListCtrl::NameItem&
// public
void LLNameListCtrl::removeNameItem(const LLUUID& agent_id)
{
- BOOL item_exists = selectByID( agent_id );
- if(item_exists)
+ // Find the item specified with agent_id.
+ S32 idx = -1;
+ for (item_list::iterator it = getItemList().begin(); it != getItemList().end(); it++)
{
- S32 index = getItemIndex(getFirstSelected());
- if(index >= 0)
+ LLScrollListItem* item = *it;
+ if (getItemId(item) == agent_id)
{
- deleteSingleItem(index);
+ idx = getItemIndex(item);
+ break;
}
}
+
+ // Remove it.
+ if (idx >= 0)
+ {
+ selectNthItem(idx); // not sure whether this is needed, taken from previous implementation
+ deleteSingleItem(idx);
+ }
}
// public
@@ -303,7 +335,7 @@ void LLNameListCtrl::refresh(const LLUUID& id, const std::string& first,
for (iter = getItemList().begin(); iter != getItemList().end(); iter++)
{
LLScrollListItem* item = *iter;
- if (item->getUUID() == id)
+ if (getItemId(item) == id)
{
LLScrollListCell* cell = (LLScrollListCell*)item->getColumn(0);
cell = item->getColumn(mNameColumnIndex);
@@ -343,3 +375,9 @@ void LLNameListCtrl::updateColumns()
}
}
}
+
+// static
+LLUUID LLNameListCtrl::getItemId(LLScrollListItem* item)
+{
+ return item->getValue()["uuid"].asUUID();
+}