From 6d7ec83b9941e6e058119fdb3ae830ac0b9b1824 Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 2 Jun 2014 19:02:49 +0300 Subject: [PATCH] Fixed suggest search result bugs. --- map/framework.cpp | 31 +++++++++++++++++++++++-------- search/result.cpp | 11 ++++++++--- search/result.hpp | 2 ++ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index 30241386d7..e0a5390738 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -134,8 +134,12 @@ void Framework::OnLocationUpdate(location::GpsInfo const & info) location::GpsInfo const & rInfo = info; #endif - m_informationDisplay.locationState()->OnLocationUpdate(rInfo); + shared_ptr const & state = m_informationDisplay.locationState(); + state->OnLocationUpdate(rInfo); m_balloonManager.LocationChanged(rInfo); + + if (state->GetLocationProcessMode() != location::ELocationDoNothing) + UpdateUserViewportChanged(); } void Framework::OnCompassUpdate(location::CompassInfo const & info) @@ -1192,7 +1196,6 @@ void Framework::ShowSearchResult(search::Result const & res) break; default: - ASSERT(false, ()); return; } @@ -1207,18 +1210,30 @@ size_t Framework::ShowAllSearchResults() Results results; GetSearchEngine()->GetResults(results); - size_t const count = results.GetCount(); + size_t count = results.GetCount(); switch (count) { - case 1: ShowSearchResult(results.GetResult(0)); - case 0: return count; + case 1: + { + Result const & r = results.GetResult(0); + if (!r.IsSuggest()) + ShowSearchResult(r); + else + count = 0; + // do not put break here + } + case 0: + return count; } m2::RectD rect; FillSearchResultsMarks(results, rect); - ShowRectEx(rect); - StopLocationFollow(); + if (rect.IsValid()) + { + ShowRectEx(rect); + StopLocationFollow(); + } return count; } @@ -1235,7 +1250,7 @@ void Framework::FillSearchResultsMarks(search::Results const & results, m2::Rect using namespace search; Result const & r = results.GetResult(i); - if (r.GetResultType() == Result::RESULT_FEATURE) + if (!r.IsSuggest()) { AddressInfo info; info.MakeFrom(r); diff --git a/search/result.cpp b/search/result.cpp index 97db30c014..c56efdd2f8 100644 --- a/search/result.cpp +++ b/search/result.cpp @@ -43,6 +43,11 @@ Result::ResultType Result::GetResultType() const return RESULT_LATLON; } +bool Result::IsSuggest() const +{ + return !m_suggestionStr.empty(); +} + FeatureID Result::GetFeatureID() const { ASSERT_EQUAL(GetResultType(), RESULT_FEATURE, ()); @@ -51,19 +56,19 @@ FeatureID Result::GetFeatureID() const double Result::GetDistance() const { - ASSERT_NOT_EQUAL(GetResultType(), RESULT_SUGGESTION, ()); + ASSERT(!IsSuggest(), ()); return m_distance; } m2::PointD Result::GetFeatureCenter() const { - ASSERT_NOT_EQUAL(GetResultType(), RESULT_SUGGESTION, ()); + ASSERT(!IsSuggest(), ()); return m_center; } char const * Result::GetSuggestionString() const { - ASSERT_EQUAL(GetResultType(), RESULT_SUGGESTION, ()); + ASSERT(IsSuggest(), ()); return m_suggestionStr.c_str(); } diff --git a/search/result.hpp b/search/result.hpp index 971b90e409..2375cd1a41 100644 --- a/search/result.hpp +++ b/search/result.hpp @@ -44,6 +44,8 @@ public: char const * GetFeatureType() const { return m_type.c_str(); } //@} + bool IsSuggest() const; + /// Type of the result. ResultType GetResultType() const;