From 8bd6e5e659d0da975a07516890577732e3fffc3f Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 23 Feb 2012 19:54:32 +0100 Subject: [PATCH] Fixed search bar not functional (FIRE-5065) --- indra/newview/llnavigationbar.cpp | 38 ++++++++++++++++++++++++++++++- indra/newview/llnavigationbar.h | 4 ++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp index c4a9ee9b14..4e5c386a71 100644 --- a/indra/newview/llnavigationbar.cpp +++ b/indra/newview/llnavigationbar.cpp @@ -270,6 +270,7 @@ LLNavigationBar::LLNavigationBar() mBtnForward(NULL), mBtnHome(NULL), mCmbLocation(NULL), + mSearchComboBox(NULL), mPurgeTPHistoryItems(false), mSaveToLocationHistory(false) { @@ -291,7 +292,10 @@ BOOL LLNavigationBar::postBuild() mBtnForward = getChild("forward_btn"); mBtnHome = getChild("home_btn"); - mCmbLocation= getChild("location_combo"); + mCmbLocation= getChild("location_combo"); + mSearchComboBox = getChild("search_combo_box"); + + fillSearchComboBox(); mBtnBack->setEnabled(FALSE); mBtnBack->setClickedCallback(boost::bind(&LLNavigationBar::onBackButtonClicked, this)); @@ -306,6 +310,8 @@ BOOL LLNavigationBar::postBuild() mBtnHome->setClickedCallback(boost::bind(&LLNavigationBar::onHomeButtonClicked, this)); mCmbLocation->setCommitCallback(boost::bind(&LLNavigationBar::onLocationSelection, this)); + + mSearchComboBox->setCommitCallback(boost::bind(&LLNavigationBar::onSearchCommit, this)); mTeleportFinishConnection = LLViewerParcelMgr::getInstance()-> setTeleportFinishedCallback(boost::bind(&LLNavigationBar::onTeleportFinished, this, _1)); @@ -351,6 +357,26 @@ void LLNavigationBar::setVisible(BOOL visible) } } + +void LLNavigationBar::fillSearchComboBox() +{ + if(!mSearchComboBox) + { + return; + } + + LLSearchHistory::getInstance()->load(); + + LLSearchHistory::search_history_list_t search_list = + LLSearchHistory::getInstance()->getSearchHistoryList(); + LLSearchHistory::search_history_list_t::const_iterator it = search_list.begin(); + for( ; search_list.end() != it; ++it) + { + LLSearchHistory::LLSearchHistoryItem item = *it; + mSearchComboBox->add(item.search_query); + } +} + void LLNavigationBar::draw() { if(mPurgeTPHistoryItems) @@ -403,6 +429,16 @@ void LLNavigationBar::onHomeButtonClicked() gAgent.teleportHome(); } +void LLNavigationBar::onSearchCommit() +{ + std::string search_query = mSearchComboBox->getSimple(); + if(!search_query.empty()) + { + LLSearchHistory::getInstance()->addEntry(search_query); + } + invokeSearch(search_query); +} + void LLNavigationBar::onTeleportHistoryMenuItemClicked(const LLSD& userdata) { int idx = userdata.asInteger(); diff --git a/indra/newview/llnavigationbar.h b/indra/newview/llnavigationbar.h index 66bc3a01d6..768ce74ebd 100644 --- a/indra/newview/llnavigationbar.h +++ b/indra/newview/llnavigationbar.h @@ -118,6 +118,7 @@ private: void onHomeButtonClicked(); void onLocationSelection(); void onLocationPrearrange(const LLSD& data); + void onSearchCommit(); void onTeleportFinished(const LLVector3d& global_agent_pos); void onTeleportFailed(); void onRegionNameResponse( @@ -127,6 +128,8 @@ private: U64 region_handle, const std::string& url, const LLUUID& snapshot_id, bool teleport); + void fillSearchComboBox(); + static void destroyClass() { if (LLNavigationBar::instanceExists()) @@ -139,6 +142,7 @@ private: LLPullButton* mBtnBack; LLPullButton* mBtnForward; LLButton* mBtnHome; + LLSearchComboBox* mSearchComboBox; LLLocationInputCtrl* mCmbLocation; LLRect mDefaultNpRect; LLRect mDefaultNavContainerRect;