diff options
| -rw-r--r-- | indra/newview/lllocationhistory.cpp | 8 | ||||
| -rw-r--r-- | indra/newview/lllocationhistory.h | 17 | ||||
| -rw-r--r-- | indra/newview/lllocationinputctrl.cpp | 18 | ||||
| -rw-r--r-- | indra/newview/lllocationinputctrl.h | 5 | ||||
| -rw-r--r-- | indra/newview/llnavigationbar.cpp | 6 | 
5 files changed, 37 insertions, 17 deletions
| diff --git a/indra/newview/lllocationhistory.cpp b/indra/newview/lllocationhistory.cpp index df93930d33..7906d9b20f 100644 --- a/indra/newview/lllocationhistory.cpp +++ b/indra/newview/lllocationhistory.cpp @@ -63,6 +63,7 @@ void LLLocationHistory::addItem(const LLLocationHistoryItem& item) {  		mItems.erase(mItems.begin(), mItems.end()-max_items);  	}  	llassert((S32)mItems.size() <= max_items); +	mChangedSignal(ADD);  }  /* @@ -87,9 +88,10 @@ bool LLLocationHistory::touchItem(const LLLocationHistoryItem& item) {  void LLLocationHistory::removeItems()  {  	mItems.clear(); +	mChangedSignal(CLEAR);  } -bool LLLocationHistory::getMatchingItems(std::string substring, location_list_t& result) const +bool LLLocationHistory::getMatchingItems(const std::string& substring, location_list_t& result) const  {  	// *TODO: an STL algorithm would look nicer  	result.clear(); @@ -160,7 +162,7 @@ void LLLocationHistory::load()  		return;  	} -	removeItems(); +	mItems.clear();// need to use a direct call of clear() method to avoid signal invocation  	// add each line in the file to the list  	std::string line; @@ -179,5 +181,5 @@ void LLLocationHistory::load()  	file.close(); -	mLoadedSignal(); +	mChangedSignal(LOAD);  } diff --git a/indra/newview/lllocationhistory.h b/indra/newview/lllocationhistory.h index 65f0dd2e1b..fb71fbaa0f 100644 --- a/indra/newview/lllocationhistory.h +++ b/indra/newview/lllocationhistory.h @@ -111,9 +111,16 @@ class LLLocationHistory: public LLSingleton<LLLocationHistory>  	LOG_CLASS(LLLocationHistory);  public: +	enum EChangeType +	{ +		 ADD +		,CLEAR +		,LOAD +	}; +	  	typedef std::vector<LLLocationHistoryItem>	location_list_t; -	typedef boost::function<void()>		loaded_callback_t; -	typedef boost::signals2::signal<void()> loaded_signal_t; +	typedef boost::function<void(EChangeType event)>			history_changed_callback_t; +	typedef boost::signals2::signal<void(EChangeType event)>	history_changed_signal_t;  	LLLocationHistory(); @@ -122,8 +129,8 @@ public:  	void                    removeItems();  	size_t					getItemCount() const	{ return mItems.size(); }  	const location_list_t&	getItems() const		{ return mItems; } -	bool					getMatchingItems(std::string substring, location_list_t& result) const; -	boost::signals2::connection	setLoadedCallback(loaded_callback_t cb) { return mLoadedSignal.connect(cb); } +	bool					getMatchingItems(const std::string& substring, location_list_t& result) const; +	boost::signals2::connection	setChangedCallback(history_changed_callback_t cb) { return mChangedSignal.connect(cb); }  	void					save() const;  	void					load(); @@ -133,7 +140,7 @@ private:  	location_list_t			mItems;  	std::string							mFilename; /// File to store the history to. -	loaded_signal_t						mLoadedSignal; +	history_changed_signal_t			mChangedSignal;  };  #endif diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 5f233bece0..0ea4b1f6da 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -52,7 +52,6 @@  #include "llinventoryobserver.h"  #include "lllandmarkactions.h"  #include "lllandmarklist.h" -#include "lllocationhistory.h"  #include "llteleporthistory.h"  #include "llsidetray.h"  #include "llslurl.h" @@ -377,9 +376,10 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)  	// - Update the location string on parcel change.  	mParcelMgrConnection = LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(  		boost::bind(&LLLocationInputCtrl::onAgentParcelChange, this)); - -	mLocationHistoryConnection = LLLocationHistory::getInstance()->setLoadedCallback( -			boost::bind(&LLLocationInputCtrl::onLocationHistoryLoaded, this)); +	// LLLocationHistory instance is being created before the location input control, so we have to update initial state of button manually. +	mButton->setEnabled(LLLocationHistory::instance().getItemCount() > 0); +	mLocationHistoryConnection = LLLocationHistory::getInstance()->setChangedCallback( +			boost::bind(&LLLocationInputCtrl::onLocationHistoryChanged, this,_1));  	mRemoveLandmarkObserver	= new LLRemoveLandmarkObserver(this);  	mAddLandmarkObserver	= new LLAddLandmarkObserver(this); @@ -620,9 +620,13 @@ void LLLocationInputCtrl::onLandmarkLoaded(LLLandmark* lm)  	updateAddLandmarkButton();  } -void LLLocationInputCtrl::onLocationHistoryLoaded() +void LLLocationInputCtrl::onLocationHistoryChanged(LLLocationHistory::EChangeType event)  { -	rebuildLocationHistory(); +	if(event == LLLocationHistory::LOAD) +	{ +		rebuildLocationHistory(); +	} +	mButton->setEnabled(LLLocationHistory::instance().getItemCount() > 0);  }  void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) @@ -893,7 +897,7 @@ void LLLocationInputCtrl::positionMaturityIcon()  	mMaturityIcon->setVisible(rect.mRight < mTextEntry->getRect().getWidth() - right_pad);  } -void LLLocationInputCtrl::rebuildLocationHistory(std::string filter) +void LLLocationInputCtrl::rebuildLocationHistory(const std::string& filter)  {  	LLLocationHistory::location_list_t filtered_items;  	const LLLocationHistory::location_list_t* itemsp = NULL; diff --git a/indra/newview/lllocationinputctrl.h b/indra/newview/lllocationinputctrl.h index 4bb41f3bf4..dac6be2a24 100644 --- a/indra/newview/lllocationinputctrl.h +++ b/indra/newview/lllocationinputctrl.h @@ -36,6 +36,7 @@  #include "llcombobox.h"  #include "lliconctrl.h"		// Params  #include "lltextbox.h"		// Params +#include "lllocationhistory.h"  class LLLandmark; @@ -137,7 +138,7 @@ private:  	void					refreshHealth();  	void					positionMaturityIcon(); -	void					rebuildLocationHistory(std::string filter = ""); +	void					rebuildLocationHistory(const std::string& filter = LLStringUtil::null);  	bool 					findTeleportItemsByTitle(const LLTeleportHistoryItem& item, const std::string& filter);  	void					setText(const LLStringExplicit& text);  	void					updateAddLandmarkButton(); @@ -147,7 +148,7 @@ private:  	void					changeLocationPresentation();  	void					onInfoButtonClicked(); -	void					onLocationHistoryLoaded(); +	void					onLocationHistoryChanged(LLLocationHistory::EChangeType event);  	void					onLocationPrearrange(const LLSD& data);  	void 					onTextEditorRightClicked(S32 x, S32 y, MASK mask);  	void					onLandmarkLoaded(LLLandmark* lm); diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp index d42e4bc250..e11df06d86 100644 --- a/indra/newview/llnavigationbar.cpp +++ b/indra/newview/llnavigationbar.cpp @@ -451,6 +451,12 @@ void LLNavigationBar::onLocationSelection()  		return;  	//get selected item from combobox item  	LLSD value = mCmbLocation->getSelectedValue(); +	if(value.isUndefined() && !mCmbLocation->getTextEntry()->isDirty()) +	{ +		// At this point we know that: there is no selected item in list and text field has NOT been changed +		// So there is no sense to try to change the location +		return; +	}  	/* since navbar list support autocompletion it contains several types of item: landmark, teleport hystory item,  	 * typed by user slurl or region name. Let's find out which type of item the user has selected   	 * to make decision about adding this location into typed history. see mSaveToLocationHistory | 
