From c6177836ecbe95f75d79f572303a879bf37b3226 Mon Sep 17 00:00:00 2001
From: Yuri Chebotarev <ychebotarev@productengine.com>
Date: Mon, 7 Dec 2009 12:04:27 +0200
Subject: [PATCH] no ticket, minor refactoring. add return value to notifyXXX
 functions, may be usefull

--HG--
branch : product-engine
---
 indra/llui/llflatlistview.cpp    |  5 ++++-
 indra/llui/llflatlistview.h      |  2 +-
 indra/llui/llview.cpp            | 11 +++++++----
 indra/llui/llview.h              | 11 ++++++++---
 indra/newview/llpanelme.cpp      |  6 +++---
 indra/newview/llpanelme.h        |  2 +-
 indra/newview/llpanelpeople.cpp  |  8 ++++----
 indra/newview/llpanelpeople.h    |  2 +-
 indra/newview/llpanelprofile.cpp |  6 +++---
 indra/newview/llpanelprofile.h   |  2 +-
 10 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index d4c3cfb7b6c..831ac66d061 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -932,7 +932,7 @@ void LLFlatListView::onFocusLost()
 }
 
 //virtual 
-void LLFlatListView::notify(const LLSD& info)
+S32 LLFlatListView::notify(const LLSD& info)
 {
 	if(info.has("action"))
 	{
@@ -941,13 +941,16 @@ void LLFlatListView::notify(const LLSD& info)
 		{
 			setFocus(true);
 			selectFirstItem();
+			return 1;
 		}
 		else if(str_action == "select_last")
 		{
 			setFocus(true);
 			selectLastItem();
+			return 1;
 		}
 	}
+	return 0;
 }
 
 //EOF
diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h
index 9e1e0f90fc8..ba824ff2df5 100644
--- a/indra/llui/llflatlistview.h
+++ b/indra/llui/llflatlistview.h
@@ -283,7 +283,7 @@ class LLFlatListView : public LLScrollContainer
 	void selectFirstItem	();
 	void selectLastItem		();
 
-	virtual void	notify(const LLSD& info) ;
+	virtual S32	notify(const LLSD& info) ;
 
 protected:
 
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 23e4131e6d0..d8ebe15dc00 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -2848,18 +2848,21 @@ LLView::default_widget_map_t& LLView::getDefaultWidgetMap() const
 	return *mDefaultWidgets;
 }
 
-void	LLView::notifyParent(const LLSD& info)
+S32	LLView::notifyParent(const LLSD& info)
 {
 	LLView* parent = getParent();
 	if(parent)
-		parent->notifyParent(info);
+		return parent->notifyParent(info);
+	return 0;
 }
-void	LLView::notifyChildren(const LLSD& info)
+bool	LLView::notifyChildren(const LLSD& info)
 {
+	bool ret = false;
 	for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
 	{
-		(*child_it)->notifyChildren(info);
+		ret |= (*child_it)->notifyChildren(info);
 	}
+	return ret;
 }
 
 // convenient accessor for draw context
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index c611e4c85f8..f8460f53616 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -511,10 +511,15 @@ class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElem
 	virtual void	handleReshape(const LLRect& rect, bool by_user);
 	virtual void	dirtyRect();
 
-	virtual void	notifyParent(const LLSD& info);
-	virtual void	notifyChildren(const LLSD& info);
+	//send custom notification to LLView parent
+	virtual S32	notifyParent(const LLSD& info);
 
-	virtual void	notify(const LLSD& info) {};
+	//send custom notification to all view childrend
+	// return true if _any_ children return true. otherwise false.
+	virtual bool	notifyChildren(const LLSD& info);
+
+	//send custom notification to current view
+	virtual S32	notify(const LLSD& info) { return 0;};
 
 	static const LLViewDrawContext& getDrawContext();
 
diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp
index 046118cf75b..4e21268a8a9 100644
--- a/indra/newview/llpanelme.cpp
+++ b/indra/newview/llpanelme.cpp
@@ -71,7 +71,7 @@ void LLPanelMe::onOpen(const LLSD& key)
 	LLPanelProfile::onOpen(key);
 }
 
-void LLPanelMe::notifyChildren(const LLSD& info)
+bool LLPanelMe::notifyChildren(const LLSD& info)
 {
 	if (info.has("task-panel-action") && info["task-panel-action"].asString() == "handle-tri-state")
 	{
@@ -104,10 +104,10 @@ void LLPanelMe::notifyChildren(const LLSD& info)
 		if (on_default_view)
 			LLSideTray::getInstance()->collapseSideBar();
 
-		return; // this notification is only supposed to be handled by task panels 
+		return true; // this notification is only supposed to be handled by task panels 
 	}
 
-	LLPanel::notifyChildren(info);
+	return LLPanel::notifyChildren(info);
 }
 
 void LLPanelMe::buildEditPanel()
diff --git a/indra/newview/llpanelme.h b/indra/newview/llpanelme.h
index 17d367132ed..1325192bbf3 100644
--- a/indra/newview/llpanelme.h
+++ b/indra/newview/llpanelme.h
@@ -54,7 +54,7 @@ class LLPanelMe : public LLPanelProfile
 	LLPanelMe();
 
 	/*virtual*/ void onOpen(const LLSD& key);
-	/*virtual*/ void notifyChildren(const LLSD& info);
+	/*virtual*/ bool notifyChildren(const LLSD& info);
 
 	/*virtual*/ BOOL postBuild();
 
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 1743df52fc6..9c7e3952f56 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -1284,7 +1284,7 @@ void	LLPanelPeople::onOpen(const LLSD& key)
 		reSelectedCurrentTab();
 }
 
-void LLPanelPeople::notifyChildren(const LLSD& info)
+bool LLPanelPeople::notifyChildren(const LLSD& info)
 {
 	if (info.has("task-panel-action") && info["task-panel-action"].asString() == "handle-tri-state")
 	{
@@ -1292,7 +1292,7 @@ void LLPanelPeople::notifyChildren(const LLSD& info)
 		if (!container)
 		{
 			llwarns << "Cannot find People panel container" << llendl;
-			return;
+			return true;
 		}
 
 		if (container->getCurrentPanelIndex() > 0) 
@@ -1303,10 +1303,10 @@ void LLPanelPeople::notifyChildren(const LLSD& info)
 		else
 			LLSideTray::getInstance()->collapseSideBar();
 
-		return; // this notification is only supposed to be handled by task panels
+		return true; // this notification is only supposed to be handled by task panels
 	}
 
-	LLPanel::notifyChildren(info);
+	return LLPanel::notifyChildren(info);
 }
 
 void LLPanelPeople::showAccordion(const std::string name, bool show)
diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h
index 5ac5bcc1d7e..bd1b1559470 100644
--- a/indra/newview/llpanelpeople.h
+++ b/indra/newview/llpanelpeople.h
@@ -51,7 +51,7 @@ class LLPanelPeople : public LLPanel
 
 	/*virtual*/ BOOL 	postBuild();
 	/*virtual*/ void	onOpen(const LLSD& key);
-	/*virtual*/ void	notifyChildren(const LLSD& info);
+	/*virtual*/ bool	notifyChildren(const LLSD& info);
 
 	// internals
 	class Updater;
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index 1830d00f683..32748201746 100644
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -220,15 +220,15 @@ void LLPanelProfile::openPanel(LLPanel* panel, const LLSD& params)
 	panel->setRect(new_rect);
 }
 
-void LLPanelProfile::notifyParent(const LLSD& info)
+S32 LLPanelProfile::notifyParent(const LLSD& info)
 {
 	std::string action = info["action"];
 	// lets update Picks list after Pick was saved
 	if("save_new_pick" == action)
 	{
 		onOpen(info);
-		return;
+		return 1;
 	}
 
-	LLPanel::notifyParent(info);
+	return LLPanel::notifyParent(info);
 }
diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h
index 067beb248b9..bcf4bdd0ec2 100644
--- a/indra/newview/llpanelprofile.h
+++ b/indra/newview/llpanelprofile.h
@@ -55,7 +55,7 @@ class LLPanelProfile : public LLPanel
 
 	virtual void openPanel(LLPanel* panel, const LLSD& params);
 
-	void notifyParent(const LLSD& info);
+	S32 notifyParent(const LLSD& info);
 
 protected:
 
-- 
GitLab