From 60d680f2eb92e5dbf2ba287f7e4e2e36e1d024e9 Mon Sep 17 00:00:00 2001
From: Igor Borovkov <iborovkov@productengine.com>
Date: Tue, 23 Mar 2010 16:13:59 +0200
Subject: [PATCH] fixed EXT-4753 Just arrived avatars aren't sorted by name in
 VCP

added requesting a list to resort when avatar list item gets updated with avatar name from the name cache

--HG--
branch : product-engine
---
 indra/llui/llflatlistview.h        |  5 ++++-
 indra/newview/llavatarlist.cpp     | 11 +++++++++++
 indra/newview/llavatarlist.h       |  2 ++
 indra/newview/llavatarlistitem.cpp |  6 +++++-
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h
index 92cb40332e..5a1ddc2c59 100644
--- a/indra/llui/llflatlistview.h
+++ b/indra/llui/llflatlistview.h
@@ -379,11 +379,14 @@ private:
 
 	void setNoItemsCommentVisible(bool visible) const;
 
-private:
+protected:
 
 	/** Comparator to use when sorting the list. */
 	const ItemComparator* mItemComparator;
 
+
+private:
+
 	LLPanel* mItemsPanel;
 
 	S32 mItemsNoScrollWidth;
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 45c540b3a3..91ebe910ce 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -334,6 +334,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 LLFlatListView::notifyParent(info);
+}
+
 void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos)
 {
 	LLAvatarListItem* item = new LLAvatarListItem();
diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h
index 00c72f1f9d..b9be1d0bdc 100644
--- a/indra/newview/llavatarlist.h
+++ b/indra/newview/llavatarlist.h
@@ -96,6 +96,8 @@ public:
 
 	boost::signals2::connection setItemDoubleClickCallback(const mouse_signal_t::slot_type& cb);
 
+	virtual S32 notifyParent(const LLSD& info);
+
 protected:
 	void refresh();
 
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index 9645e75e60..44f88cce29 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -119,8 +119,9 @@ S32 LLAvatarListItem::notifyParent(const LLSD& info)
 	if (info.has("visibility_changed"))
 	{
 		updateChildren();
+		return 1;
 	}
-	return 0;
+	return LLPanel::notifyParent(info);
 }
 
 void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask)
@@ -334,6 +335,9 @@ void LLAvatarListItem::onNameCache(const std::string& first_name, const std::str
 {
 	std::string name = first_name + " " + last_name;
 	setName(name);
+
+	//requesting the list to resort
+	notifyParent(LLSD().with("sort", LLSD()));
 }
 
 // Convert given number of seconds to a string like "23 minutes", "15 hours" or "3 years",
-- 
GitLab