forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
ac5c1e1a60
commit
4c9ba8a196
4 changed files with 31 additions and 30 deletions
|
@ -1399,8 +1399,9 @@ void Framework::InitSearchAPI()
|
|||
ASSERT(m_infoGetter.get(), ());
|
||||
try
|
||||
{
|
||||
m_searchAPI = make_unique<SearchAPI>(const_cast<Index &>(m_model.GetIndex()), m_storage,
|
||||
*m_infoGetter, static_cast<SearchAPI::Delegate &>(*this));
|
||||
m_searchAPI =
|
||||
make_unique<SearchAPI>(m_model.GetIndex(), m_storage, *m_infoGetter,
|
||||
static_cast<SearchAPI::Delegate &>(*this));
|
||||
}
|
||||
catch (RootException const & e)
|
||||
{
|
||||
|
@ -3137,7 +3138,10 @@ void Framework::ShowViewportSearchResults(search::Results const & results)
|
|||
FillSearchResultsMarks(results);
|
||||
}
|
||||
|
||||
void Framework::ClearViewportSearchResults() { ClearSearchResultsMarks(); }
|
||||
void Framework::ClearViewportSearchResults()
|
||||
{
|
||||
ClearSearchResultsMarks();
|
||||
}
|
||||
|
||||
boost::optional<m2::PointD> Framework::GetCurrentPosition() const
|
||||
{
|
||||
|
@ -3145,12 +3149,10 @@ boost::optional<m2::PointD> Framework::GetCurrentPosition() const
|
|||
MyPositionMarkPoint * myPosMark = UserMarkContainer::UserMarkForMyPostion();
|
||||
if (!myPosMark->HasPosition())
|
||||
return {};
|
||||
|
||||
position = myPosMark->GetPivot();
|
||||
return position;
|
||||
return myPosMark->GetPivot();
|
||||
}
|
||||
|
||||
bool Framework::ParseMagicSearchQuery(search::SearchParams const & params)
|
||||
bool Framework::ParseSearchQueryCommand(search::SearchParams const & params)
|
||||
{
|
||||
if (ParseDrapeDebugCommand(params.m_query))
|
||||
return true;
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
#include "std/unique_ptr.hpp"
|
||||
#include "std/vector.hpp"
|
||||
|
||||
#include "boost/optional.hpp"
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace osm
|
||||
{
|
||||
|
@ -348,7 +348,7 @@ public:
|
|||
void ShowViewportSearchResults(search::Results const & results) override;
|
||||
void ClearViewportSearchResults() override;
|
||||
boost::optional<m2::PointD> GetCurrentPosition() const override;
|
||||
bool ParseMagicSearchQuery(search::SearchParams const & params) override;
|
||||
bool ParseSearchQueryCommand(search::SearchParams const & params) override;
|
||||
bool IsLocalAdsCustomer(search::Result const & result) const override;
|
||||
double GetMinDistanceBetweenResults() const override;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace search;
|
||||
|
@ -91,7 +92,7 @@ bool SearchAPI::SearchEverywhere(EverywhereSearchParams const & params)
|
|||
static_cast<EverywhereSearchCallback::Delegate &>(*this),
|
||||
[this, params](Results const & results, vector<bool> const & isLocalAdsCustomer) {
|
||||
if (params.m_onResults)
|
||||
RunUITask([params, results, isLocalAdsCustomer]() {
|
||||
RunUITask([params, results, isLocalAdsCustomer] {
|
||||
params.m_onResults(results, isLocalAdsCustomer);
|
||||
});
|
||||
});
|
||||
|
@ -117,7 +118,7 @@ bool SearchAPI::SearchInViewport(ViewportSearchParams const & params)
|
|||
p.m_hotelsFilter = params.m_hotelsFilter;
|
||||
p.m_cianMode = m_cianSearchMode;
|
||||
|
||||
p.m_onStarted = [this, params]() {
|
||||
p.m_onStarted = [this, params] {
|
||||
if (params.m_onStarted)
|
||||
RunUITask([params]() { params.m_onStarted(); });
|
||||
};
|
||||
|
@ -126,7 +127,7 @@ bool SearchAPI::SearchInViewport(ViewportSearchParams const & params)
|
|||
static_cast<ViewportSearchCallback::Delegate &>(*this),
|
||||
[this, params](Results const & results) {
|
||||
if (results.IsEndMarker() && params.m_onCompleted)
|
||||
RunUITask([params, results]() { params.m_onCompleted(results); });
|
||||
RunUITask([params, results] { params.m_onCompleted(results); });
|
||||
});
|
||||
|
||||
return Search(p, false /* forceSearch */);
|
||||
|
@ -213,29 +214,19 @@ bool SearchAPI::IsLocalAdsCustomer(Result const & result) const
|
|||
|
||||
bool SearchAPI::Search(SearchParams const & params, bool forceSearch)
|
||||
{
|
||||
if (m_delegate.ParseMagicSearchQuery(params))
|
||||
if (m_delegate.ParseSearchQueryCommand(params))
|
||||
return false;
|
||||
|
||||
auto const mode = params.m_mode;
|
||||
auto & intent = m_searchIntents[static_cast<size_t>(mode)];
|
||||
|
||||
#ifdef FIXED_LOCATION
|
||||
SearchParams currParams = params;
|
||||
if (currParams.IsValidPosition())
|
||||
{
|
||||
// TODO (@y): fix this
|
||||
m_fixedPos.GetLat(currParams.m_lat);
|
||||
m_fixedPos.GetLon(rParams.m_lon);
|
||||
}
|
||||
#else
|
||||
SearchParams const & currParams = params;
|
||||
#endif
|
||||
|
||||
if (!forceSearch && QueryMayBeSkipped(intent.m_params, currParams))
|
||||
if (!forceSearch && QueryMayBeSkipped(intent.m_params, params))
|
||||
return false;
|
||||
|
||||
intent.m_params = currParams;
|
||||
// Cancels previous search request (if any) and initiates new search request.
|
||||
intent.m_params = params;
|
||||
|
||||
// Cancels previous search request (if any) and initiates a new
|
||||
// search request.
|
||||
CancelQuery(intent.m_handle);
|
||||
|
||||
intent.m_params.m_minDistanceOnMapBetweenResults = m_delegate.GetMinDistanceBetweenResults();
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
|
@ -41,13 +40,22 @@ public:
|
|||
virtual ~Delegate() = default;
|
||||
|
||||
virtual void RunUITask(std::function<void()> /* fn */) {}
|
||||
|
||||
virtual void SetSearchDisplacementModeEnabled(bool /* enabled */) {}
|
||||
|
||||
virtual void ShowViewportSearchResults(search::Results const & /* results */) {}
|
||||
|
||||
virtual void ClearViewportSearchResults() {}
|
||||
|
||||
virtual boost::optional<m2::PointD> GetCurrentPosition() const { return {}; };
|
||||
virtual bool ParseMagicSearchQuery(search::SearchParams const & /* params */) { return false; };
|
||||
|
||||
virtual bool ParseSearchQueryCommand(search::SearchParams const & /* params */)
|
||||
{
|
||||
return false;
|
||||
};
|
||||
|
||||
virtual double GetMinDistanceBetweenResults() const { return 0.0; };
|
||||
|
||||
virtual bool IsLocalAdsCustomer(search::Result const & /* result */) const { return false; }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue