summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorVadim Savchuk <vsavchuk@productengine.com>2010-01-19 19:24:01 +0200
committerVadim Savchuk <vsavchuk@productengine.com>2010-01-19 19:24:01 +0200
commita2d083f3ce7b490c88285410591dbcf3592609a2 (patch)
tree711895462189a1bcc122d75cb10788245eec7b1a /indra
parentc008e692b5a92c6c70dd9fe1098dcc735c98d5a2 (diff)
Fixed major bug EXT-4336 (Inspectors display groups as people).
Added storing item type (avatar/group) in its value, so that we can choose the proper inspector. --HG-- branch : product-engine
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llnamelistctrl.cpp80
-rw-r--r--indra/newview/llnamelistctrl.h5
2 files changed, 62 insertions, 23 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();
+}
diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h
index d0f0ec4d21..192a3a5afa 100644
--- a/indra/newview/llnamelistctrl.h
+++ b/indra/newview/llnamelistctrl.h
@@ -94,7 +94,7 @@ public:
void addNameItem(NameItem& item, EAddPosition pos = ADD_BOTTOM);
/*virtual*/ LLScrollListItem* addElement(const LLSD& element, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL);
- LLScrollListItem* addNameItemRow(const NameItem& value, EAddPosition pos = ADD_BOTTOM);
+ LLScrollListItem* addNameItemRow(const NameItem& value, EAddPosition pos = ADD_BOTTOM, std::string& suffix = LLStringUtil::null);
// Add a user to the list by name. It will be added, the name
// requested from the cache, and updated as necessary.
@@ -121,7 +121,8 @@ public:
/*virtual*/ void updateColumns();
private:
- void showAvatarInspector(const LLUUID& avatar_id);
+ void showInspector(const LLUUID& avatar_id, bool is_group);
+ static LLUUID getItemId(LLScrollListItem* item);
private:
S32 mNameColumnIndex;