diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index f6b13e9157..38304910fb 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -47,7 +47,11 @@ void Info::SetFromFeatureType(FeatureType & ft) true /* allowTranslit */} , out); } + bool emptyTitle = false; + m_primaryFeatureName = out.GetPrimary(); + m_uiAddress = m_address; + if (IsBookmark()) { m_uiTitle = GetBookmarkName(); @@ -63,60 +67,39 @@ void Info::SetFromFeatureType(FeatureType & ft) if (m_uiTitle != secondaryTitle) m_uiSecondaryTitle = std::move(secondaryTitle); - - m_uiSubtitle = FormatSubtitle(true /* withType */); - m_uiAddress = m_address; - } - else if (IsPublicTransportStop()) - { - const std::string local_ref = std::string(GetMetadata(feature::Metadata::FMD_LOCAL_REF)); - - if (!local_ref.empty()) // has local ref - { - if (!m_primaryFeatureName.empty()) // has name and local_ref - { - m_uiTitle = m_primaryFeatureName + " (" + local_ref + ")"; - m_uiSubtitle = FormatSubtitle(true /* withType */); - } - else // no name but has local_ref - { - m_uiTitle = GetLocalizedType() + " (" + local_ref + ")"; - m_uiSubtitle = FormatSubtitle(false /* withType */); - } - } - else - SetStandardValues(out); } else if (IsBuilding()) { - bool const isAddressEmpty = m_address.empty(); - m_uiTitle = isAddressEmpty ? GetLocalizedType() : m_address; - m_uiSubtitle = FormatSubtitle(!isAddressEmpty /* withType */); + emptyTitle = m_address.empty(); + if (!emptyTitle) + m_uiTitle = m_address; + m_uiAddress.clear(); // already in main title } else - SetStandardValues(out); + { + emptyTitle = m_primaryFeatureName.empty(); + if (!emptyTitle) + m_uiTitle = m_primaryFeatureName; + } + + // Assign Feature's type if main title is empty. + if (emptyTitle) + m_uiTitle = GetLocalizedType(); + + // Append local_ref tag into main title. + if (IsPublicTransportStop()) + { + auto const lRef = GetMetadata(feature::Metadata::FMD_LOCAL_REF); + if (!lRef.empty()) + m_uiTitle.append(" (").append(lRef).append(")"); + } + + m_uiSubtitle = FormatSubtitle(!emptyTitle /* withType */); // apply to all types after checks m_hotelType = ftypes::IsHotelChecker::Instance().GetHotelType(ft); } -void Info::SetStandardValues(feature::NameParamsOut out) -{ - if (!m_primaryFeatureName.empty()) - { - m_uiTitle = m_primaryFeatureName; - m_uiSecondaryTitle = out.secondary; - m_uiSubtitle = FormatSubtitle(true /* withType */); - m_uiAddress = m_address; - } - else - { - m_uiTitle = GetLocalizedType(); - m_uiSubtitle = FormatSubtitle(false /* withType */); - m_uiAddress = m_address; - } -} - void Info::SetMercator(m2::PointD const & mercator) { m_mercator = mercator; diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index 867713d342..ac6ee2cf13 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -142,7 +142,7 @@ public: void SetTitlesForBookmark(); void SetCustomNames(std::string const & title, std::string const & subtitle); void SetCustomNameWithCoordinates(m2::PointD const & mercator, std::string const & name); - void SetAddress(std::string const & address) { m_address = address; } + void SetAddress(std::string && address) { m_address = std::move(address); } void SetCanEditOrAdd(bool canEditOrAdd) { m_canEditOrAdd = canEditOrAdd; } void SetLocalizedWifiString(std::string const & str) { m_localizedWifiString = str; } @@ -205,7 +205,6 @@ public: void SetWikiDescription(std::string && description) { m_description = std::move(description); } void SetMercator(m2::PointD const & mercator); - void SetStandardValues(feature::NameParamsOut out); std::vector GetRawTypes() const { return m_types.ToObjectNames(); } std::optional GetHotelType() const { return m_hotelType; }