From e2443ace9568406993f207721cf6dd9b2223a7a8 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Thu, 21 Jan 2010 16:58:05 +0200
Subject: [PATCH] Fixed low bug (EXT-4221) Select and display just created
 landmark in the Landmarks panel after closing Create Landmark panel - Added
 selecting landmark in landmarks panel after it was added or edited. - Added
 expanding accordion tab containing the selected landmark.

--HG--
branch : product-engine
---
 indra/newview/llpanellandmarks.cpp | 53 ++++++++++++++++++++++++++++++
 indra/newview/llpanellandmarks.h   | 16 +++++++++
 indra/newview/llpanelplaces.cpp    | 13 ++++++++
 3 files changed, 82 insertions(+)

diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp
index d6e407a0edf..47feef496af 100644
--- a/indra/newview/llpanellandmarks.cpp
+++ b/indra/newview/llpanellandmarks.cpp
@@ -305,6 +305,29 @@ void LLLandmarksPanel::updateShowFolderState()
 		);
 }
 
+void LLLandmarksPanel::setItemSelected(const LLUUID& obj_id, BOOL take_keyboard_focus)
+{
+	if (selectItemInAccordionTab(mFavoritesInventoryPanel, "tab_favorites", obj_id, take_keyboard_focus))
+	{
+		return;
+	}
+
+	if (selectItemInAccordionTab(mLandmarksInventoryPanel, "tab_landmarks", obj_id, take_keyboard_focus))
+	{
+		return;
+	}
+
+	if (selectItemInAccordionTab(mMyInventoryPanel, "tab_inventory", obj_id, take_keyboard_focus))
+	{
+		return;
+	}
+
+	if (selectItemInAccordionTab(mLibraryInventoryPanel, "tab_library", obj_id, take_keyboard_focus))
+	{
+		return;
+	}
+}
+
 //////////////////////////////////////////////////////////////////////////
 // PROTECTED METHODS
 //////////////////////////////////////////////////////////////////////////
@@ -350,6 +373,36 @@ LLFolderViewItem* LLLandmarksPanel::getCurSelectedItem() const
 	return mCurrentSelectedList ?  mCurrentSelectedList->getRootFolder()->getCurSelectedItem() : NULL;
 }
 
+LLFolderViewItem* LLLandmarksPanel::selectItemInAccordionTab(LLPlacesInventoryPanel* inventory_list,
+															 const std::string& tab_name,
+															 const LLUUID& obj_id,
+															 BOOL take_keyboard_focus) const
+{
+	if (!inventory_list)
+		return NULL;
+
+	LLFolderView* folder_view = inventory_list->getRootFolder();
+
+	LLFolderViewItem* item = folder_view->getItemByID(obj_id);
+	if (!item)
+		return NULL;
+
+	LLAccordionCtrlTab* tab = getChild<LLAccordionCtrlTab>(tab_name);
+	if (!tab->isExpanded())
+	{
+		tab->changeOpenClose(false);
+	}
+
+	folder_view->setSelection(item, FALSE, take_keyboard_focus);
+
+	LLAccordionCtrl* accordion = getChild<LLAccordionCtrl>("landmarks_accordion");
+	LLRect screen_rc;
+	localRectToScreen(item->getRect(), &screen_rc);
+	accordion->notifyParent(LLSD().with("scrollToShowRect", screen_rc.getValue()));
+
+	return item;
+}
+
 void LLLandmarksPanel::updateSortOrder(LLInventoryPanel* panel, bool byDate)
 {
 	if(!panel) return; 
diff --git a/indra/newview/llpanellandmarks.h b/indra/newview/llpanellandmarks.h
index 569739237d4..96b790844ca 100644
--- a/indra/newview/llpanellandmarks.h
+++ b/indra/newview/llpanellandmarks.h
@@ -73,6 +73,11 @@ class LLLandmarksPanel : public LLPanelPlacesTab, LLRemoteParcelInfoObserver
 	 */
 	void updateShowFolderState();
 
+	/**
+	 * Selects item with "obj_id" in one of accordion tabs.
+	 */
+	void setItemSelected(const LLUUID& obj_id, BOOL take_keyboard_focus);
+
 protected:
 	/**
 	 * @return true - if current selected panel is not null and selected item is a landmark
@@ -81,6 +86,17 @@ class LLLandmarksPanel : public LLPanelPlacesTab, LLRemoteParcelInfoObserver
 	bool isReceivedFolderSelected() const;
 	void doActionOnCurSelectedLandmark(LLLandmarkList::loaded_callback_t cb);
 	LLFolderViewItem* getCurSelectedItem() const;
+
+	/**
+	 * Selects item with "obj_id" in "inventory_list" and scrolls accordion
+	 * scrollbar to show the item.
+	 * Returns pointer to the item if it is found in "inventory_list", otherwise NULL.
+	 */
+	LLFolderViewItem* selectItemInAccordionTab(LLPlacesInventoryPanel* inventory_list,
+											   const std::string& tab_name,
+											   const LLUUID& obj_id,
+											   BOOL take_keyboard_focus) const;
+
 	void updateSortOrder(LLInventoryPanel* panel, bool byDate);
 
 	//LLRemoteParcelInfoObserver interface
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index a71c8d89589..b037674c374 100644
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -842,6 +842,19 @@ void LLPanelPlaces::togglePlaceInfoPanel(BOOL visible)
 
 			mPlaceProfile->setVisible(FALSE);
 		}
+		else
+		{
+			LLLandmarksPanel* landmarks_panel =
+					dynamic_cast<LLLandmarksPanel*>(mTabContainer->getPanelByName("Landmarks"));
+			if (landmarks_panel && mItem.notNull())
+			{
+				// If a landmark info is being closed we open the landmarks tab
+				// and set this landmark selected.
+				mTabContainer->selectTabPanel(landmarks_panel);
+
+				landmarks_panel->setItemSelected(mItem->getUUID(), TRUE);
+			}
+		}
 	}
 }
 
-- 
GitLab