From a67af8e7e8823b068cee909bcdc3d8a622a407d5 Mon Sep 17 00:00:00 2001
From: Alexei Arabadji <aarabadji@productengine.com>
Date: Fri, 27 Nov 2009 11:37:48 +0200
Subject: [PATCH] fixed EXT-2566 "Unable to locate other avatars on map via
 "map" button (previously "show on map")"

--HG--
branch : product-engine
---
 indra/newview/llpanelavatar.cpp | 23 +++++++++++++++++++++++
 indra/newview/llpanelavatar.h   |  4 ++++
 indra/newview/llpanelpicks.h    |  4 +++-
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index 6f753b61760..87f1ac1f9fb 100644
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -48,6 +48,8 @@
 #include "llscrollcontainer.h"
 #include "llavatariconctrl.h"
 #include "llweb.h"
+#include "llfloaterworldmap.h"
+#include "llfloaterreg.h"
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // Class LLDropTarget
@@ -150,6 +152,8 @@ BOOL LLPanelAvatarNotes::postBuild()
 	childSetCommitCallback("call", boost::bind(&LLPanelAvatarNotes::onCallButtonClick, this), NULL);
 	childSetCommitCallback("teleport", boost::bind(&LLPanelAvatarNotes::onTeleportButtonClick, this), NULL);
 	childSetCommitCallback("share", boost::bind(&LLPanelAvatarNotes::onShareButtonClick, this), NULL);
+	childSetCommitCallback("show_on_map_btn", (boost::bind(
+				&LLPanelAvatarNotes::onMapButtonClick, this)), NULL);
 
 	LLTextEditor* te = getChild<LLTextEditor>("notes_edit");
 	te->setCommitCallback(boost::bind(&LLPanelAvatarNotes::onCommitNotes,this));
@@ -311,6 +315,7 @@ void LLPanelProfileTab::onOpen(const LLSD& key)
 	// Update data even if we are viewing same avatar profile as some data might been changed.
 	setAvatarId(key.asUUID());
 	updateData();
+	updateButtons();
 }
 
 void LLPanelProfileTab::scrollToTop()
@@ -320,6 +325,22 @@ void LLPanelProfileTab::scrollToTop()
 		scrollContainer->goToTop();
 }
 
+void LLPanelProfileTab::onMapButtonClick()
+{
+	std::string name;
+	gCacheName->getFullName(getAvatarId(), name);
+	gFloaterWorldMap->trackAvatar(getAvatarId(), name);
+	LLFloaterReg::showInstance("world_map");
+}
+
+void LLPanelProfileTab::updateButtons()
+{
+	bool enable_map_btn = LLAvatarTracker::instance().isBuddyOnline(getAvatarId())
+					&& gAgent.isGodlike() || is_agent_mappable(getAvatarId());
+
+	childSetEnabled("show_on_map_btn", enable_map_btn);
+}
+
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
@@ -338,6 +359,8 @@ BOOL LLPanelAvatarProfile::postBuild()
 	childSetCommitCallback("teleport",(boost::bind(&LLPanelAvatarProfile::onTeleportButtonClick,this)),NULL);
 	childSetCommitCallback("overflow_btn", boost::bind(&LLPanelAvatarProfile::onOverflowButtonClicked, this), NULL);
 	childSetCommitCallback("share",(boost::bind(&LLPanelAvatarProfile::onShareButtonClick,this)),NULL);
+	childSetCommitCallback("show_on_map_btn", (boost::bind(
+			&LLPanelAvatarProfile::onMapButtonClick, this)), NULL);
 
 	LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
 	registrar.add("Profile.Pay",  boost::bind(&LLPanelAvatarProfile::pay, this));
diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h
index 527e1c0d340..dc94ff02caa 100644
--- a/indra/newview/llpanelavatar.h
+++ b/indra/newview/llpanelavatar.h
@@ -106,6 +106,10 @@ class LLPanelProfileTab
 	 */
 	void scrollToTop();
 
+	virtual void onMapButtonClick();
+
+	virtual void updateButtons();
+
 private:
 
 	LLUUID mAvatarId;
diff --git a/indra/newview/llpanelpicks.h b/indra/newview/llpanelpicks.h
index b17b6d6fe94..b21b1c64b14 100644
--- a/indra/newview/llpanelpicks.h
+++ b/indra/newview/llpanelpicks.h
@@ -86,6 +86,9 @@ class LLPanelPicks
 	// parent panels failed to work (picks related code was in my profile panel)
 	void setProfilePanel(LLPanelProfile* profile_panel);
 
+protected:
+	/*virtual*/void updateButtons();
+
 private:
 	void onClickDelete();
 	void onClickTeleport();
@@ -125,7 +128,6 @@ class LLPanelPicks
 	bool callbackDeleteClassified(const LLSD& notification, const LLSD& response);
 	bool callbackTeleport(const LLSD& notification, const LLSD& response);
 
-	void updateButtons();
 
 	virtual void onDoubleClickPickItem(LLUICtrl* item);
 	virtual void onDoubleClickClassifiedItem(LLUICtrl* item);
-- 
GitLab