From 729f880f78e26459d37ff0d120d9537791ccaf8d Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Thu, 18 Mar 2010 00:53:32 +0200
Subject: [PATCH] [SHOWSTOPPER] Fix for (EXT-4704) Add maturity icons to Prefs
 -> General and (EXT-4705) Show maturity icon on Region/Estate tab. - Made
 changes to combobox onItemSelected() to fix (EXT-6269) typing a location into
 the nav bar always sends you to the first location you typed in. - Replaced
 LLIconsComboBox pointers with base class pointers LLComboBox.

Reviewed by Richard Nelson https://codereview.productengine.com/secondlife/r/29/

--HG--
branch : product-engine
---
 indra/llui/llcombobox.cpp           | 33 ++++++++---------------------
 indra/llui/llcombobox.h             |  3 +--
 indra/newview/llpanelclassified.cpp |  6 +++---
 3 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index c1d512e1482..3a8efadaa48 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -706,14 +706,17 @@ void LLComboBox::onListMouseUp()
 
 void LLComboBox::onItemSelected(const LLSD& data)
 {
-	setValue(data);
-
-	if (mAllowTextEntry && mLastSelectedIndex != -1)
+	mLastSelectedIndex = getCurrentIndex();
+	if (mLastSelectedIndex != -1)
 	{
-		gFocusMgr.setKeyboardFocus(mTextEntry);
-		mTextEntry->selectAll();
-	}
+		setLabel(getSelectedItemLabel());
 
+		if (mAllowTextEntry)
+		{
+			gFocusMgr.setKeyboardFocus(mTextEntry);
+			mTextEntry->selectAll();
+		}
+	}
 	// hiding the list reasserts the old value stored in the text editor/dropdown button
 	hideList();
 
@@ -1080,24 +1083,6 @@ LLIconsComboBox::LLIconsComboBox(const LLIconsComboBox::Params& p)
 	mLabelColumnIndex(p.label_column)
 {}
 
-void LLIconsComboBox::setValue(const LLSD& value)
-{
-	BOOL found = mList->selectByValue(value);
-	if (found)
-	{
-		LLScrollListItem* item = mList->getFirstSelected();
-		if (item)
-		{
-			setLabel(getSelectedItemLabel());
-		}
-		mLastSelectedIndex = mList->getFirstSelectedIndex();
-	}
-	else
-	{
-		mLastSelectedIndex = -1;
-	}
-}
-
 const std::string LLIconsComboBox::getSelectedItemLabel(S32 column) const
 {
 	mButton->setImageOverlay(LLComboBox::getSelectedItemLabel(mIconColumnIndex), mButton->getImageOverlayHAlign());
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index 965061ead2d..f0bd432f3a4 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -221,7 +221,6 @@ class LLComboBox
 	LLPointer<LLUIImage>	mArrowImage;
 	LLUIString			mLabel;
 	BOOL				mHasAutocompletedText;
-	S32                 mLastSelectedIndex;
 
 private:
 	BOOL				mAllowTextEntry;
@@ -232,6 +231,7 @@ class LLComboBox
 	commit_callback_t	mTextEntryCallback;
 	commit_callback_t	mSelectionCallback;
         boost::signals2::connection mTopLostSignalConnection;
+    S32					mLastSelectedIndex;
 };
 
 // A combo box with icons for the list of items.
@@ -247,7 +247,6 @@ class LLIconsComboBox
 		Params();
 	};
 
-	/*virtual*/ void setValue(const LLSD& value);
 	/*virtual*/ const std::string getSelectedItemLabel(S32 column = 0) const;
 
 private:
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 021e1f5159a..70a7bf644b7 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -1893,7 +1893,7 @@ void LLPanelClassifiedEdit::resetControls()
 	LLPanelClassifiedInfo::resetControls();
 
 	getChild<LLComboBox>("category")->setCurrentByIndex(0);
-	getChild<LLIconsComboBox>("content_type")->setCurrentByIndex(0);
+	getChild<LLComboBox>("content_type")->setCurrentByIndex(0);
 	childSetValue("auto_renew", false);
 	childSetValue("price_for_listing", MINIMUM_PRICE_FOR_LISTING);
 	childSetEnabled("price_for_listing", TRUE);
@@ -1928,7 +1928,7 @@ U32 LLPanelClassifiedEdit::getContentType()
 
 void LLPanelClassifiedEdit::setContentType(U32 content_type)
 {
-	LLIconsComboBox* ct_cb = getChild<LLIconsComboBox>("content_type");
+	LLComboBox* ct_cb = getChild<LLComboBox>("content_type");
 	ct_cb->setCurrentByIndex(content_type);
 	ct_cb->resetDirty();
 }
@@ -1988,7 +1988,7 @@ U8 LLPanelClassifiedEdit::getFlags()
 {
 	bool auto_renew = childGetValue("auto_renew").asBoolean();
 
-	LLComboBox* content_cb = getChild<LLIconsComboBox>("content_type");
+	LLComboBox* content_cb = getChild<LLComboBox>("content_type");
 	bool mature = content_cb->getCurrentIndex() == CB_ITEM_MATURE;
 	
 	return pack_classified_flags_request(auto_renew, false, mature, false);
-- 
GitLab