forked from organicmaps/organicmaps
[guides on map] Update guides downloaded status after loading or deleting categories.
This commit is contained in:
parent
4a3e4e8eed
commit
5326c6428c
5 changed files with 58 additions and 10 deletions
|
@ -788,6 +788,9 @@ void BookmarkManager::NotifyChanges()
|
|||
if (m_changesTracker.HasBookmarksChanges())
|
||||
NotifyBookmarksChanged();
|
||||
|
||||
if (m_changesTracker.HasCategoriesChanges())
|
||||
NotifyCategoriesChanged();
|
||||
|
||||
m_bookmarksChangesTracker.AddChanges(m_changesTracker);
|
||||
m_drapeChangesTracker.AddChanges(m_changesTracker);
|
||||
m_changesTracker.ResetChanges();
|
||||
|
@ -2004,6 +2007,11 @@ void BookmarkManager::UpdateViewport(ScreenBase const & screen)
|
|||
}
|
||||
|
||||
void BookmarkManager::SetBookmarksChangedCallback(BookmarksChangedCallback && callback)
|
||||
{
|
||||
m_bookmarksChangedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void BookmarkManager::SetCategoriesChangedCallback(CategoriesChangedCallback && callback)
|
||||
{
|
||||
m_categoriesChangedCallback = std::move(callback);
|
||||
}
|
||||
|
@ -2600,6 +2608,12 @@ void BookmarkManager::SendBookmarksChanges(MarksChangesTracker const & changesTr
|
|||
}
|
||||
|
||||
void BookmarkManager::NotifyBookmarksChanged()
|
||||
{
|
||||
if (m_bookmarksChangedCallback != nullptr)
|
||||
m_bookmarksChangedCallback();
|
||||
}
|
||||
|
||||
void BookmarkManager::NotifyCategoriesChanged()
|
||||
{
|
||||
if (m_categoriesChangedCallback != nullptr)
|
||||
m_categoriesChangedCallback();
|
||||
|
@ -2642,6 +2656,7 @@ kml::MarkGroupId BookmarkManager::CreateBookmarkCategory(std::string const & nam
|
|||
UpdateBmGroupIdList();
|
||||
m_changesTracker.OnAddGroup(groupId);
|
||||
NotifyBookmarksChanged();
|
||||
NotifyCategoriesChanged();
|
||||
return groupId;
|
||||
}
|
||||
|
||||
|
@ -3957,6 +3972,21 @@ bool BookmarkManager::MarksChangesTracker::HasBookmarksChanges() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BookmarkManager::MarksChangesTracker::HasCategoriesChanges() const
|
||||
{
|
||||
for (auto groupId : m_createdGroups)
|
||||
{
|
||||
if (m_bmManager->IsBookmarkCategory(groupId))
|
||||
return true;
|
||||
}
|
||||
for (auto groupId : m_removedGroups)
|
||||
{
|
||||
if (m_bmManager->IsBookmarkCategory(groupId))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BookmarkManager::MarksChangesTracker::ResetChanges()
|
||||
{
|
||||
m_createdGroups.clear();
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
using KMLDataCollectionPtr = std::shared_ptr<KMLDataCollection>;
|
||||
|
||||
using BookmarksChangedCallback = std::function<void()>;
|
||||
using CategoriesChangedCallback = std::function<void()>;
|
||||
using ElevationActivePointChangedCallback = std::function<void()>;
|
||||
using ElevationMyPositionChangedCallback = std::function<void()>;
|
||||
|
||||
|
@ -184,6 +185,7 @@ public:
|
|||
void ResetRegionAddressGetter();
|
||||
|
||||
void SetBookmarksChangedCallback(BookmarksChangedCallback && callback);
|
||||
void SetCategoriesChangedCallback(CategoriesChangedCallback && callback);
|
||||
void SetAsyncLoadingCallbacks(AsyncLoadingCallbacks && callbacks);
|
||||
bool IsAsyncLoadingInProgress() const { return m_asyncLoadingInProgress; }
|
||||
|
||||
|
@ -521,6 +523,7 @@ private:
|
|||
void AcceptDirtyItems();
|
||||
bool HasChanges() const;
|
||||
bool HasBookmarksChanges() const;
|
||||
bool HasCategoriesChanges() const;
|
||||
void ResetChanges();
|
||||
void AddChanges(MarksChangesTracker const & changes);
|
||||
|
||||
|
@ -683,6 +686,7 @@ private:
|
|||
void UpdateBmGroupIdList();
|
||||
|
||||
void NotifyBookmarksChanged();
|
||||
void NotifyCategoriesChanged();
|
||||
|
||||
void SendBookmarksChanges(MarksChangesTracker const & changesTracker);
|
||||
void GetBookmarksInfo(kml::MarkIdSet const & marks, std::vector<BookmarkInfo> & bookmarks);
|
||||
|
@ -788,7 +792,8 @@ private:
|
|||
std::unique_ptr<search::RegionAddressGetter> m_regionAddressGetter;
|
||||
std::mutex m_regionAddressMutex;
|
||||
|
||||
BookmarksChangedCallback m_categoriesChangedCallback;
|
||||
BookmarksChangedCallback m_bookmarksChangedCallback;
|
||||
CategoriesChangedCallback m_categoriesChangedCallback;
|
||||
ElevationActivePointChangedCallback m_elevationActivePointChanged;
|
||||
ElevationMyPositionChangedCallback m_elevationMyPositionChanged;
|
||||
m2::PointD m_lastElevationMyPosition = m2::PointD::Zero();
|
||||
|
|
|
@ -2054,7 +2054,6 @@ void Framework::OnRecoverSurface(int width, int height, bool recreateContextDepe
|
|||
m_trafficManager.OnRecoverSurface();
|
||||
m_transitManager.Invalidate();
|
||||
m_isolinesManager.Invalidate();
|
||||
m_guidesManager.Invalidate();
|
||||
m_localAdsManager.Invalidate();
|
||||
}
|
||||
|
||||
|
|
|
@ -117,11 +117,6 @@ void GuidesManager::UpdateViewport(ScreenBase const & screen)
|
|||
RequestGuides();
|
||||
}
|
||||
|
||||
void GuidesManager::Invalidate()
|
||||
{
|
||||
// TODO: Implement.
|
||||
}
|
||||
|
||||
void GuidesManager::Reconnect()
|
||||
{
|
||||
if (m_state != GuidesState::FatalNetworkError)
|
||||
|
@ -349,7 +344,13 @@ void GuidesManager::SetGalleryListener(GuidesGalleryChangedFn const & onGalleryC
|
|||
|
||||
void GuidesManager::SetBookmarkManager(BookmarkManager * bmManager)
|
||||
{
|
||||
CHECK(bmManager != nullptr, ());
|
||||
m_bmManager = bmManager;
|
||||
m_bmManager->SetCategoriesChangedCallback(
|
||||
[this]()
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this](){ UpdateDownloadedStatus(); });
|
||||
});
|
||||
}
|
||||
|
||||
void GuidesManager::SetDrapeEngine(ref_ptr<df::DrapeEngine> engine)
|
||||
|
@ -367,11 +368,24 @@ bool GuidesManager::IsGuideDownloaded(std::string const & guideId) const
|
|||
return m_bmManager->GetCatalog().HasDownloaded(guideId);
|
||||
}
|
||||
|
||||
void GuidesManager::UpdateDownloadedStatus()
|
||||
{
|
||||
if (m_state == GuidesState::Disabled)
|
||||
return;
|
||||
|
||||
auto es = m_bmManager->GetEditSession();
|
||||
for (auto markId : m_bmManager->GetUserMarkIds(UserMark::Type::GUIDE))
|
||||
{
|
||||
auto * mark = es.GetMarkForEdit<GuideMark>(markId);
|
||||
mark->SetIsDownloaded(IsGuideDownloaded(mark->GetGuideId()));
|
||||
}
|
||||
}
|
||||
|
||||
void GuidesManager::UpdateGuidesMarks()
|
||||
{
|
||||
auto es = m_bmManager->GetEditSession();
|
||||
es.ClearGroup(UserMark::GUIDE_CLUSTER);
|
||||
es.ClearGroup(UserMark::GUIDE);
|
||||
es.ClearGroup(UserMark::Type::GUIDE_CLUSTER);
|
||||
es.ClearGroup(UserMark::Type::GUIDE);
|
||||
|
||||
auto const sortedGuides = SortGuidesByPositions(m_guides.m_nodes, m_screen);
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@ public:
|
|||
void SetStateListener(GuidesStateChangedFn const & onStateChangedFn);
|
||||
|
||||
void UpdateViewport(ScreenBase const & screen);
|
||||
void Invalidate();
|
||||
void Reconnect();
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
|
@ -122,6 +121,7 @@ private:
|
|||
void Clear();
|
||||
|
||||
bool IsGuideDownloaded(std::string const & guideId) const;
|
||||
void UpdateDownloadedStatus();
|
||||
void UpdateGuidesMarks();
|
||||
void UpdateActiveGuide();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue