forked from organicmaps/organicmaps
Info::SetFromFeatureType refactoring.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
parent
f066d6ea91
commit
dcd85b0e29
2 changed files with 28 additions and 46 deletions
|
@ -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;
|
||||
|
|
|
@ -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<std::string> GetRawTypes() const { return m_types.ToObjectNames(); }
|
||||
|
||||
std::optional<ftypes::IsHotelChecker::Type> GetHotelType() const { return m_hotelType; }
|
||||
|
|
Loading…
Add table
Reference in a new issue