Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/map
diff options
context:
space:
mode:
authorSergey Magidovich <mgsergio@mapswithme.com>2016-06-10 15:19:29 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-06-23 19:26:25 +0300
commit82cc6171cc02b73eec0140fddadd8c4f7e026dbd (patch)
treeea29f2bdb6db5c5b45ada8986f4ed9e9a1979c70 /map
parenta9bdcb8f27a8ab84fe3fe2902abe8cff19584291 (diff)
Do not edit old maps. Refactor edit buttos showups.
Diffstat (limited to 'map')
-rw-r--r--map/framework.cpp18
-rw-r--r--map/framework.hpp4
-rw-r--r--map/place_page_info.cpp22
-rw-r--r--map/place_page_info.hpp15
4 files changed, 35 insertions, 24 deletions
diff --git a/map/framework.cpp b/map/framework.cpp
index cd48c6274a..2b1117b0b8 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -725,9 +725,14 @@ void Framework::FillPointInfo(m2::PointD const & mercator, string const & custom
{
auto feature = GetFeatureAtPoint(mercator);
if (feature)
+ {
FillInfoFromFeatureType(*feature, info);
+ }
else
+ {
info.m_customName = customTitle.empty() ? m_stringsBundle.GetString("placepage_unknown_place") : customTitle;
+ info.m_canEditOrAdd = CanEditMap();
+ }
// This line overwrites mercator center from area feature which can be far away.
info.SetMercator(mercator);
@@ -751,9 +756,8 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info
info.m_sponsoredDescriptionUrl = GetBookingApi().GetDescriptionUrl(baseUrl);
}
- info.m_isEditable = featureStatus != osm::Editor::FeatureStatus::Obsolete &&
- !info.IsSponsoredHotel();
- info.m_isDataEditable = version::IsSingleMwm(ft.GetID().m_mwmId.GetInfo()->m_version.GetVersion());
+ info.m_canEditOrAdd = featureStatus != osm::Editor::FeatureStatus::Obsolete && CanEditMap() &&
+ !info.IsSponsoredHotel();
info.m_localizedWifiString = m_stringsBundle.GetString("wifi");
info.m_localizedRatingString = m_stringsBundle.GetString("place_page_booking_rating");
@@ -2194,11 +2198,7 @@ void Framework::UpdateSavedDataVersion()
settings::Set("DataVersion", m_storage.GetCurrentDataVersion());
}
-int64_t Framework::GetCurrentDataVersion()
-{
- return m_storage.GetCurrentDataVersion();
-}
-
+int64_t Framework::GetCurrentDataVersion() const { return m_storage.GetCurrentDataVersion(); }
void Framework::BuildRoute(m2::PointD const & finish, uint32_t timeoutSec)
{
ASSERT_THREAD_CHECKER(m_threadChecker, ("BuildRoute"));
@@ -2723,6 +2723,8 @@ void SetHostingBuildingAddress(FeatureID const & hostingBuildingFid, Index const
}
} // namespace
+bool Framework::CanEditMap() const { return version::IsSingleMwm(GetCurrentDataVersion()); }
+
bool Framework::CreateMapObject(m2::PointD const & mercator, uint32_t const featureType,
osm::EditableMapObject & emo) const
{
diff --git a/map/framework.hpp b/map/framework.hpp
index 49486afe6c..7c87293bd5 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -579,7 +579,7 @@ public:
//@{
bool IsDataVersionUpdated();
void UpdateSavedDataVersion();
- int64_t GetCurrentDataVersion();
+ int64_t GetCurrentDataVersion() const;
//@}
public:
@@ -655,6 +655,8 @@ public:
//@{
/// Initializes feature for Create Object UI.
/// @returns false in case when coordinate is in the ocean or mwm is not downloaded.
+ bool CanEditMap() const;
+
bool CreateMapObject(m2::PointD const & mercator, uint32_t const featureType, osm::EditableMapObject & emo) const;
/// @returns false if feature is invalid or can't be edited.
bool GetEditableMapObject(FeatureID const & fid, osm:: EditableMapObject & emo) const;
diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp
index 79ae971a90..52edfff5c8 100644
--- a/map/place_page_info.cpp
+++ b/map/place_page_info.cpp
@@ -15,19 +15,25 @@ char const * const Info::kPricingSymbol = "$";
bool Info::IsFeature() const { return m_featureID.IsValid(); }
bool Info::IsBookmark() const { return m_bac != MakeEmptyBookmarkAndCategory(); }
bool Info::IsMyPosition() const { return m_isMyPosition; }
-bool Info::HasApiUrl() const { return !m_apiUrl.empty(); }
-bool Info::IsEditable() const { return m_isEditable && m_isDataEditable; }
-bool Info::IsDataEditable() const { return m_isDataEditable; }
-bool Info::HasWifi() const { return GetInternet() == osm::Internet::Wlan; }
+bool Info::IsSponsoredHotel() const { return m_isSponsoredHotel; }
bool Info::ShouldShowAddPlace() const
{
- return !IsSponsoredHotel() &&
- (!IsFeature() || (!IsPointType() && !IsBuilding())) &&
- m_isDataEditable;
+ auto const isPointOrBuilding = IsPointType() || IsBuilding();
+ return m_canEditOrAdd && !(IsFeature() && isPointOrBuilding);
}
-bool Info::IsSponsoredHotel() const { return m_isSponsoredHotel; }
+bool Info::ShouldShowAddBusiness() const { return m_canEditOrAdd && IsBuilding(); }
+
+bool Info::ShouldShowEditPlace() const
+{
+ return m_canEditOrAdd &&
+ // TODO(mgsergio): Does IsFeature() imply !IsMyPosition()?
+ !IsMyPosition() && IsFeature();
+}
+
+bool Info::HasApiUrl() const { return !m_apiUrl.empty(); }
+bool Info::HasWifi() const { return GetInternet() == osm::Internet::Wlan; }
string Info::FormatNewBookmarkName() const
{
diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp
index c1cedfb34a..cd308c2c8d 100644
--- a/map/place_page_info.hpp
+++ b/map/place_page_info.hpp
@@ -28,14 +28,14 @@ public:
bool IsFeature() const;
bool IsBookmark() const;
bool IsMyPosition() const;
- bool ShouldShowAddPlace() const;
bool IsSponsoredHotel() const;
+
+ bool ShouldShowAddPlace() const;
+ bool ShouldShowAddBusiness() const;
+ bool ShouldShowEditPlace() const;
+
/// @returns true if Back API button should be displayed.
bool HasApiUrl() const;
- /// @returns true if Edit Place button should be displayed.
- bool IsEditable() const;
- /// @returns true if PlacePage was opened on a single mwm (see version::IsSingleMwm).
- bool IsDataEditable() const;
/// TODO: Support all possible Internet types in UI. @See MapObject::GetInternet().
bool HasWifi() const;
@@ -91,8 +91,9 @@ public:
storage::TCountryId m_countryId = storage::kInvalidCountryId;
bool m_isMyPosition = false;
- bool m_isEditable = false;
- bool m_isDataEditable = false;
+ /// True if editing of a selected point is allowed by basic logic.
+ /// See initialization in framework.
+ bool m_canEditOrAdd = false;
// TODO(AlexZ): Temporary solution. It's better to use a wifi icon in UI instead of text.
string m_localizedWifiString;