From 8ea130aefe8de220d511dbcf82415d2917dc5a92 Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Thu, 30 Nov 2017 13:09:30 +0300 Subject: [PATCH] [editor] disable editing during download maps --- map/framework.cpp | 6 +++++- storage/storage.cpp | 13 +++++++++++++ storage/storage.hpp | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/map/framework.cpp b/map/framework.cpp index 76cc66dce1..61bc41655e 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -453,6 +453,7 @@ Framework::Framework(FrameworkParams const & params) bind(&Framework::OnCountryFileDownloaded, this, _1, _2), bind(&Framework::OnCountryFileDelete, this, _1, _2)); m_storage.SetDownloadingPolicy(&m_storageDownloadingPolicy); + m_storage.SetStartDownloadingCallback([this]() { UpdatePlacePageInfoForCurrentSelection(); }); LOG(LDEBUG, ("Storage initialized")); // Local ads manager should be initialized after storage initialization. @@ -2829,7 +2830,10 @@ void SetHostingBuildingAddress(FeatureID const & hostingBuildingFid, Index const } } // namespace -bool Framework::CanEditMap() const { return version::IsSingleMwm(GetCurrentDataVersion()); } +bool Framework::CanEditMap() const +{ + return version::IsSingleMwm(GetCurrentDataVersion()) && !GetStorage().IsDownloadInProgress(); +} bool Framework::CreateMapObject(m2::PointD const & mercator, uint32_t const featureType, osm::EditableMapObject & emo) const diff --git a/storage/storage.cpp b/storage/storage.cpp index 2455e2d38f..54c2300229 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -497,9 +497,15 @@ void Storage::DownloadCountry(TCountryId const & countryId, MapOptions opt) m_failedCountries.erase(countryId); m_queue.push_back(QueuedCountry(countryId, opt)); if (m_queue.size() == 1) + { + if (m_startDownloadingCallback) + m_startDownloadingCallback(); DownloadNextCountryFromQueue(); + } else + { NotifyStatusChangedForHierarchy(countryId); + } SaveDownloadQueue(); } @@ -1440,6 +1446,13 @@ bool Storage::IsPossibleToAutoupdate() const return m_diffManager.IsPossibleToAutoupdate(); } +void Storage::SetStartDownloadingCallback(StartDownloadingCallback const & cb) +{ + ASSERT_THREAD_CHECKER(m_threadChecker, ()); + + m_startDownloadingCallback = cb; +} + void Storage::OnDiffStatusReceived(diffs::Status const status) { if (status != diffs::Status::NotAvailable) diff --git a/storage/storage.hpp b/storage/storage.hpp index f63056aed4..e79983b650 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -141,6 +141,7 @@ class Storage : public diffs::Manager::Observer { public: struct StatusCallback; + using StartDownloadingCallback = function; using TUpdateCallback = function; using TDeleteCallback = function; using TChangeCountryFunction = function; @@ -251,6 +252,8 @@ private: vector> m_deferredDownloads; + StartDownloadingCallback m_startDownloadingCallback; + void DownloadNextCountryFromQueue(); void LoadCountriesFile(string const & pathToCountriesFile, string const & dataDir, @@ -557,6 +560,8 @@ public: /// diffs. bool IsPossibleToAutoupdate() const; + void SetStartDownloadingCallback(StartDownloadingCallback const & cb); + private: friend struct UnitClass_StorageTest_DeleteCountry; friend struct UnitClass_TwoComponentStorageTest_DeleteCountry;