Fixed suggest search result bugs.

This commit is contained in:
vng 2014-06-02 19:02:49 +03:00 committed by Alex Zolotarev
parent dab46e95e8
commit 6d7ec83b99
3 changed files with 33 additions and 11 deletions

View file

@ -134,8 +134,12 @@ void Framework::OnLocationUpdate(location::GpsInfo const & info)
location::GpsInfo const & rInfo = info;
#endif
m_informationDisplay.locationState()->OnLocationUpdate(rInfo);
shared_ptr<location::State> 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);

View file

@ -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();
}

View file

@ -44,6 +44,8 @@ public:
char const * GetFeatureType() const { return m_type.c_str(); }
//@}
bool IsSuggest() const;
/// Type of the result.
ResultType GetResultType() const;