[search] Do search in ALL mode always.

This commit is contained in:
vng 2014-04-03 18:59:30 +03:00 committed by Alex Zolotarev
parent a79ba7c171
commit 2657f9afa0
2 changed files with 15 additions and 9 deletions

View file

@ -33,8 +33,12 @@ namespace search
ALL = AROUND_POSITION | IN_VIEWPORT | SEARCH_WORLD | SEARCH_ADDRESS
};
void SetSearchMode(int mode) { m_searchMode = mode; }
bool NeedSearch(SearchModeT mode) const { return ((m_searchMode & mode) != 0); }
inline void SetSearchMode(int /*mode*/)
{
// Always do search in default mode (ALL).
//m_searchMode = mode;
}
inline bool NeedSearch(SearchModeT mode) const { return ((m_searchMode & mode) != 0); }
//@}
void SetPosition(double lat, double lon);

View file

@ -193,6 +193,7 @@ void Engine::SetViewportAsync(m2::RectD const & viewport, m2::RectD const & near
m_pQuery->SetViewport(arrRects, ARRAY_SIZE(arrRects));
}
/*
namespace
{
bool LessByDistance(Result const & r1, Result const & r2)
@ -214,16 +215,17 @@ namespace
return false;
}
}
*/
void Engine::EmitResults(SearchParams const & params, Results & res)
{
if (params.IsValidPosition() &&
params.NeedSearch(SearchParams::AROUND_POSITION) &&
!params.NeedSearch(SearchParams::IN_VIEWPORT) &&
!params.NeedSearch(SearchParams::SEARCH_WORLD))
{
res.Sort(&LessByDistance);
}
// if (params.IsValidPosition() &&
// params.NeedSearch(SearchParams::AROUND_POSITION) &&
// !params.NeedSearch(SearchParams::IN_VIEWPORT) &&
// !params.NeedSearch(SearchParams::SEARCH_WORLD))
// {
// res.Sort(&LessByDistance);
// }
m_searchResults = res;
params.m_callback(res);