From fc0f736e1af20e80f8c844f29469ddb9a17a72c4 Mon Sep 17 00:00:00 2001 From: Yuri Gorshenin Date: Fri, 23 Sep 2016 14:29:53 +0300 Subject: Review fixes and SearchParams refactoring. --- search/search_params.hpp | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'search/search_params.hpp') diff --git a/search/search_params.hpp b/search/search_params.hpp index 7685d3cbdd..e454d017de 100644 --- a/search/search_params.hpp +++ b/search/search_params.hpp @@ -2,6 +2,7 @@ #include "search/mode.hpp" +#include "geometry/latlon.hpp" #include "geometry/point2d.hpp" #include "geometry/rect2d.hpp" @@ -18,48 +19,34 @@ public: using TOnStarted = function; using TOnResults = function; - SearchParams(); - - /// @name Force run search without comparing with previous search params. - //@{ - void SetForceSearch(bool b) { m_forceSearch = b; } - bool IsForceSearch() const { return m_forceSearch; } - //@} - - inline void SetMode(Mode mode) { m_mode = mode; } - inline Mode GetMode() const { return m_mode; } void SetPosition(double lat, double lon); - inline bool IsValidPosition() const { return m_validPos; } - inline bool IsSearchAroundPosition() const { return (m_searchRadiusM > 0 && IsValidPosition()); } - inline void SetSearchRadiusMeters(double radiusM) { m_searchRadiusM = radiusM; } - bool GetSearchRect(m2::RectD & rect) const; + m2::PointD GetPositionMercator() const; + ms::LatLon GetPositionLatLon() const; - /// @param[in] locale can be "fr", "en-US", "ru_RU" etc. - inline void SetInputLocale(string const & locale) { m_inputLocale = locale; } - inline void SetSuggestsEnabled(bool enabled) { m_suggestsEnabled = enabled; } - inline bool GetSuggestsEnabled() const { return m_suggestsEnabled; } + inline bool IsValidPosition() const { return m_validPos; } bool IsEqualCommon(SearchParams const & rhs) const; - inline void Clear() { m_query.clear(); } + TOnStarted m_onStarted; TOnResults m_onResults; string m_query; string m_inputLocale; - double m_lat, m_lon; - // A minimum distance between search results in meters, needed for // pre-ranking of viewport search results. - double m_minDistanceOnMapBetweenResults; + double m_minDistanceOnMapBetweenResults = 0.0; + + Mode m_mode = Mode::Everywhere; + bool m_forceSearch = false; + bool m_suggestsEnabled = true; friend string DebugPrint(SearchParams const & params); private: - double m_searchRadiusM; - Mode m_mode; - bool m_forceSearch; - bool m_validPos; - bool m_suggestsEnabled; + double m_lat = 0.0; + double m_lon = 0.0; + + bool m_validPos = false; }; } // namespace search -- cgit v1.2.3