forked from organicmaps/organicmaps
Added special search icon for booking with local ads objects
This commit is contained in:
parent
f67114e565
commit
f6f15b43be
4 changed files with 37 additions and 25 deletions
|
@ -1567,7 +1567,7 @@ void Framework::FillSearchResultsMarks(bool clear, search::Results const & resul
|
|||
|
||||
void Framework::FillSearchResultsMarks(bool clear, search::Results::ConstIter begin,
|
||||
search::Results::ConstIter end,
|
||||
SearchMarkPostProcesing fn /* = nullptr */)
|
||||
SearchMarkPostProcessing fn /* = nullptr */)
|
||||
{
|
||||
auto editSession = GetBookmarkManager().GetEditSession();
|
||||
if (clear)
|
||||
|
@ -1588,16 +1588,7 @@ void Framework::FillSearchResultsMarks(bool clear, search::Results::ConstIter be
|
|||
|
||||
// TODO: Remove after FC2018 finishing.
|
||||
if (r.m_metadata.m_isFootballCupObject)
|
||||
{
|
||||
mark->SetMarkType(SearchMarkType::Fc2018);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isFeature && m_localAdsManager.Contains(r.GetFeatureID()))
|
||||
{
|
||||
mark->SetMarkType(SearchMarkType::LocalAds);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r.m_metadata.m_isSponsoredHotel)
|
||||
{
|
||||
|
@ -1606,6 +1597,12 @@ void Framework::FillSearchResultsMarks(bool clear, search::Results::ConstIter be
|
|||
mark->SetPricing(r.m_metadata.m_hotelPricing);
|
||||
}
|
||||
|
||||
if (isFeature && m_localAdsManager.Contains(r.GetFeatureID()))
|
||||
{
|
||||
mark->SetMarkType(r.m_metadata.m_isSponsoredHotel ? SearchMarkType::LocalAdsBooking
|
||||
: SearchMarkType::LocalAds);
|
||||
}
|
||||
|
||||
if (fn)
|
||||
fn(*mark);
|
||||
}
|
||||
|
|
|
@ -545,11 +545,11 @@ public:
|
|||
|
||||
size_t ShowSearchResults(search::Results const & results);
|
||||
|
||||
using SearchMarkPostProcesing = function<void(SearchMarkPoint & mark)>;
|
||||
using SearchMarkPostProcessing = function<void(SearchMarkPoint & mark)>;
|
||||
|
||||
void FillSearchResultsMarks(bool clear, search::Results const & results);
|
||||
void FillSearchResultsMarks(bool clear, search::Results::ConstIter begin,
|
||||
search::Results::ConstIter end, SearchMarkPostProcesing fn = nullptr);
|
||||
search::Results::ConstIter end, SearchMarkPostProcessing fn = nullptr);
|
||||
list<TSearchRequest> const & GetLastSearchQueries() const { return m_searchQuerySaver.Get(); }
|
||||
void SaveSearchQuery(TSearchRequest const & query) { m_searchQuerySaver.Add(query); }
|
||||
void ClearSearchHistory() { m_searchQuerySaver.Clear(); }
|
||||
|
|
|
@ -13,25 +13,26 @@ namespace
|
|||
{
|
||||
std::vector<std::string> const kSymbols =
|
||||
{
|
||||
"search-result", // Default.
|
||||
"searchbooking-default-l", // Booking.
|
||||
"search-adv", // LocalAds.
|
||||
"search-football", // FC 2018.
|
||||
"search-result", // Default.
|
||||
"searchbooking-default-l", // Booking.
|
||||
"search-adv", // Local Ads.
|
||||
"searchbookingadv-default-l", // Local Ads + Booking.
|
||||
"search-football", // FC 2018.
|
||||
|
||||
"non-found-search-result", // NotFound.
|
||||
"non-found-search-result", // NotFound.
|
||||
};
|
||||
|
||||
std::vector<std::string> const kPreparingSymbols =
|
||||
{
|
||||
"search-result", // Default.
|
||||
"searchbooking-inactive", // Booking.
|
||||
"search-adv", // LocalAds.
|
||||
"search-football", // FC 2018.
|
||||
"search-result", // Default.
|
||||
"searchbooking-inactive", // Booking.
|
||||
"search-adv", // Local Ads.
|
||||
"searchbookingadv-default-l", // Local Ads + Booking.
|
||||
"search-football", // FC 2018.
|
||||
|
||||
"non-found-search-result", // NotFound.
|
||||
"non-found-search-result", // NotFound.
|
||||
};
|
||||
|
||||
std::string const kBookingSmallIcon = "searchbooking-default-s";
|
||||
float const kRatingThreshold = 6.0f;
|
||||
float const kMetricThreshold = 0.38f;
|
||||
|
||||
|
@ -65,6 +66,15 @@ bool NeedShowBookingBadge(float rating, int pricing)
|
|||
auto const metric = CalculateAggregateMetric(rating, pricing);
|
||||
return metric >= kMetricThreshold;
|
||||
}
|
||||
|
||||
std::string GetBookingSmallIcon(SearchMarkType type)
|
||||
{
|
||||
if (type == SearchMarkType::Booking)
|
||||
return "searchbooking-default-s";
|
||||
if (type == SearchMarkType::LocalAdsBooking)
|
||||
return "search-adv";
|
||||
return {};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SearchMarkPoint::SearchMarkPoint(m2::PointD const & ptOrg)
|
||||
|
@ -97,7 +107,7 @@ drape_ptr<df::UserPointMark::SymbolNameZoomInfo> SearchMarkPoint::GetSymbolNames
|
|||
if (IsBookingSpecialMark())
|
||||
{
|
||||
symbol->insert(std::make_pair(1 /* zoomLevel */, m_rating < kRatingThreshold ?
|
||||
kBookingSmallIcon : name));
|
||||
GetBookingSmallIcon(m_type) : name));
|
||||
symbol->insert(std::make_pair(17 /* zoomLevel */, name));
|
||||
}
|
||||
else
|
||||
|
@ -151,6 +161,9 @@ df::ColorConstant SearchMarkPoint::GetColorConstant() const
|
|||
if (!IsBookingSpecialMark())
|
||||
return {};
|
||||
|
||||
if (m_type == SearchMarkType::LocalAdsBooking)
|
||||
return "RatingLocalAds";
|
||||
|
||||
if (HasNoRating(m_rating))
|
||||
return "RatingNone";
|
||||
if (m_rating < 2.0f)
|
||||
|
@ -219,7 +232,8 @@ void SearchMarkPoint::SetPricing(int pricing)
|
|||
|
||||
bool SearchMarkPoint::IsBookingSpecialMark() const
|
||||
{
|
||||
return m_type == SearchMarkType::Booking && !m_isPreparing;
|
||||
return (m_type == SearchMarkType::Booking || m_type == SearchMarkType::LocalAdsBooking) &&
|
||||
!m_isPreparing;
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -20,6 +20,7 @@ enum class SearchMarkType
|
|||
Default = 0,
|
||||
Booking,
|
||||
LocalAds,
|
||||
LocalAdsBooking,
|
||||
Fc2018,
|
||||
NotFound, // Service value used in developer tools.
|
||||
Count
|
||||
|
|
Loading…
Add table
Reference in a new issue