From 22246364a0ea21b77542002a068831c443edf66d Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Fri, 9 Feb 2018 15:44:57 +0300 Subject: [PATCH] Desktop fixes. --- drape_frontend/drape_engine.cpp | 87 +++++++++++++----------- drape_frontend/drape_engine.hpp | 4 +- drape_frontend/user_mark_generator.cpp | 4 +- drape_frontend/user_marks_global.hpp | 2 +- drape_frontend/user_marks_provider.hpp | 3 +- iphone/Maps/Bookmarks/BookmarksRootVC.mm | 10 +-- map/bookmark.cpp | 17 +++-- map/bookmark.hpp | 4 +- map/bookmark_manager.cpp | 80 +++++++++++++--------- map/bookmark_manager.hpp | 15 ++-- map/framework.cpp | 2 +- map/user_mark.hpp | 3 +- qt/draw_widget.cpp | 8 +-- qt/qt_common/map_widget.hpp | 2 + 14 files changed, 129 insertions(+), 112 deletions(-) diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index f588a6c3ff..0870708d09 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -200,10 +200,10 @@ void DrapeEngine::SetModelViewAnyRect(m2::AnyRectD const & rect, bool isAnim) PostUserEvent(make_unique_dp(rect, isAnim)); } -void DrapeEngine::ClearUserMarksGroup(size_t layerId) +void DrapeEngine::ClearUserMarksGroup(MarkGroupID groupId) { m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, - make_unique_dp(layerId), + make_unique_dp(groupId), MessagePriority::Normal); } @@ -221,9 +221,9 @@ void DrapeEngine::InvalidateUserMarks() MessagePriority::Normal); } -void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider) +void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider, bool firstTime) { - auto const & dirtyGroupIds = provider->GetDirtyGroupIds(); + auto const dirtyGroupIds = firstTime ? provider->GetAllGroupIds() : provider->GetDirtyGroupIds(); if (dirtyGroupIds.empty()) return; @@ -232,49 +232,52 @@ void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider) auto createdIdCollection = make_unique_dp(); auto removedIdCollection = make_unique_dp(); - df::MarkGroupID lastGroupId = *dirtyGroupIds.begin(); - bool visibilityChanged = provider->IsGroupVisibilityChanged(lastGroupId); - bool groupIsVisible = provider->IsGroupVisible(lastGroupId); - - auto const HandleMark = [&]( - df::MarkID markId, - UserMarksRenderCollection & renderCollection, - MarkIDCollection * idCollection) + if (!firstTime) { - auto const * mark = provider->GetUserPointMark(markId); - if (!mark->IsDirty()) - return; - auto const groupId = mark->GetGroupId(); - if (groupId != lastGroupId) + df::MarkGroupID lastGroupId = *dirtyGroupIds.begin(); + bool visibilityChanged = provider->IsGroupVisibilityChanged(lastGroupId); + bool groupIsVisible = provider->IsGroupVisible(lastGroupId); + + auto const handleMark = [&]( + df::MarkID markId, + UserMarksRenderCollection & renderCollection, + MarkIDCollection *idCollection) { - lastGroupId = groupId; - visibilityChanged = provider->IsGroupVisibilityChanged(groupId); - groupIsVisible = provider->IsGroupVisible(groupId); - } - if (!visibilityChanged && groupIsVisible) - { - if (idCollection) - idCollection->push_back(markId); - renderCollection.emplace(markId, GenerateMarkRenderInfo(mark)); - } - }; + auto const *mark = provider->GetUserPointMark(markId); + if (!mark->IsDirty()) + return; + auto const groupId = mark->GetGroupId(); + if (groupId != lastGroupId) + { + lastGroupId = groupId; + visibilityChanged = provider->IsGroupVisibilityChanged(groupId); + groupIsVisible = provider->IsGroupVisible(groupId); + } + if (!visibilityChanged && groupIsVisible) + { + if (idCollection) + idCollection->push_back(markId); + renderCollection.emplace(markId, GenerateMarkRenderInfo(mark)); + } + }; - for (auto markId : provider->GetCreatedMarkIds()) - HandleMark(markId, *marksRenderCollection, &createdIdCollection->m_marksID); + for (auto markId : provider->GetCreatedMarkIds()) + handleMark(markId, *marksRenderCollection, &createdIdCollection->m_marksID); - for (auto markId : provider->GetUpdatedMarkIds()) - HandleMark(markId, *marksRenderCollection, nullptr); + for (auto markId : provider->GetUpdatedMarkIds()) + handleMark(markId, *marksRenderCollection, nullptr); - auto const & removedMarkIds = provider->GetRemovedMarkIds(); - removedIdCollection->m_marksID.reserve(removedMarkIds.size()); - removedIdCollection->m_marksID.assign(removedMarkIds.begin(), removedMarkIds.end()); + auto const & removedMarkIds = provider->GetRemovedMarkIds(); + removedIdCollection->m_marksID.reserve(removedMarkIds.size()); + removedIdCollection->m_marksID.assign(removedMarkIds.begin(), removedMarkIds.end()); + } std::map> dirtyMarkIds; for (auto groupId : dirtyGroupIds) { auto & idCollection = *(dirtyMarkIds.emplace(groupId, make_unique_dp()).first->second); - visibilityChanged = provider->IsGroupVisibilityChanged(groupId); - groupIsVisible = provider->IsGroupVisible(groupId); + bool const visibilityChanged = provider->IsGroupVisibilityChanged(groupId); + bool const groupIsVisible = provider->IsGroupVisible(groupId); if (!groupIsVisible && !visibilityChanged) continue; @@ -293,14 +296,16 @@ void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider) if (visibilityChanged || line->IsDirty()) linesRenderCollection->emplace(lineId, GenerateLineRenderInfo(line)); } - if (visibilityChanged) + if (visibilityChanged || firstTime) { for (auto markId : markIds) + { marksRenderCollection->emplace( markId, GenerateMarkRenderInfo(provider->GetUserPointMark(markId))); + } } } - else + else if (!firstTime) { auto & points = removedIdCollection->m_marksID; points.reserve(points.size() + markIds.size()); @@ -311,8 +316,8 @@ void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider) } } - if (!marksRenderCollection->empty() || !linesRenderCollection->empty() - || !removedIdCollection->IsEmpty() || !createdIdCollection->IsEmpty()) + if (!marksRenderCollection->empty() || !linesRenderCollection->empty() || + !removedIdCollection->IsEmpty() || !createdIdCollection->IsEmpty()) { m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp( diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index 00efa718af..fd54ff1081 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -131,9 +131,9 @@ public: using TModelViewListenerFn = FrontendRenderer::TModelViewChanged; void SetModelViewListener(TModelViewListenerFn && fn); - void ClearUserMarksGroup(size_t layerId); + void ClearUserMarksGroup(MarkGroupID groupId); void ChangeVisibilityUserMarksGroup(MarkGroupID groupId, bool isVisible); - void UpdateUserMarks(UserMarksProvider * provider); + void UpdateUserMarks(UserMarksProvider * provider, bool firstTime); void InvalidateUserMarks(); void SetRenderingEnabled(ref_ptr contextFactory = nullptr); diff --git a/drape_frontend/user_mark_generator.cpp b/drape_frontend/user_mark_generator.cpp index 79be6c90f4..422cff33e4 100644 --- a/drape_frontend/user_mark_generator.cpp +++ b/drape_frontend/user_mark_generator.cpp @@ -101,7 +101,7 @@ void UserMarkGenerator::UpdateIndex(MarkGroupID groupId) for (int zoomLevel = params.m_minZoom; zoomLevel <= scales::GetUpperScale(); ++zoomLevel) { TileKey const tileKey = GetTileKeyByPoint(params.m_pivot, zoomLevel); - ref_ptr groupIDs = GetIdCollection(tileKey, groupId); + auto groupIDs = GetIdCollection(tileKey, groupId); groupIDs->m_marksID.push_back(static_cast(markId)); } } @@ -125,7 +125,7 @@ void UserMarkGenerator::UpdateIndex(MarkGroupID groupId) CalcTilesCoverage(segmentRect, zoomLevel, [&](int tileX, int tileY) { TileKey const tileKey(tileX, tileY, zoomLevel); - ref_ptr groupIDs = GetIdCollection(tileKey, groupId); + auto groupIDs = GetIdCollection(tileKey, groupId); groupIDs->m_linesID.push_back(static_cast(lineId)); }); return true; diff --git a/drape_frontend/user_marks_global.hpp b/drape_frontend/user_marks_global.hpp index ca25fa982b..669d0a324a 100644 --- a/drape_frontend/user_marks_global.hpp +++ b/drape_frontend/user_marks_global.hpp @@ -12,6 +12,6 @@ using MarkIDCollection = std::vector; using LineIDCollection = std::vector; using MarkIDSet = std::set; using LineIDSet = std::set; -using GroupIDList = std::vector; +using GroupIDCollection = std::vector; using GroupIDSet = std::set; } // namespace df diff --git a/drape_frontend/user_marks_provider.hpp b/drape_frontend/user_marks_provider.hpp index f661c8b2ec..6f04870176 100644 --- a/drape_frontend/user_marks_provider.hpp +++ b/drape_frontend/user_marks_provider.hpp @@ -102,6 +102,7 @@ class UserMarksProvider public: virtual ~UserMarksProvider() {} virtual GroupIDSet const & GetDirtyGroupIds() const = 0; + virtual GroupIDSet GetAllGroupIds() const = 0; virtual bool IsGroupVisible(MarkGroupID groupID) const = 0; virtual bool IsGroupVisibilityChanged(MarkGroupID groupID) const = 0; virtual MarkIDSet const & GetGroupPointIds(MarkGroupID groupID) const = 0; @@ -111,7 +112,7 @@ public: virtual MarkIDSet const & GetUpdatedMarkIds() const = 0; /// Never store UserPointMark reference. virtual UserPointMark const * GetUserPointMark(MarkID markID) const = 0; - /// Never store UserLineMark reference. + /// Never store UserLineMark reference. virtual UserLineMark const * GetUserLineMark(LineID lineID) const = 0; }; diff --git a/iphone/Maps/Bookmarks/BookmarksRootVC.mm b/iphone/Maps/Bookmarks/BookmarksRootVC.mm index af13397b66..586763dbdc 100644 --- a/iphone/Maps/Bookmarks/BookmarksRootVC.mm +++ b/iphone/Maps/Bookmarks/BookmarksRootVC.mm @@ -158,16 +158,16 @@ extern NSString * const kBookmarkCategoryDeletedNotification = cell.imageView.tag = indexPath.row; auto & bmManager = GetFramework().GetBookmarkManager(); - size_t const categoryIndex = bmManager.GetBmGroupsIdList()[indexPath.row]; - if (bmManager.HasBmCategory(categoryIndex)) + auto const categoryId = bmManager.GetBmGroupsIdList()[indexPath.row]; + if (bmManager.HasBmCategory(categoryId)) { - NSString * title = @(bmManager.GetCategoryName(categoryIndex).c_str()); + NSString * title = @(bmManager.GetCategoryName(categoryId).c_str()); cell.textLabel.text = [self truncateString:title toWidth:(self.tableView.width - 122) withFont:cell.textLabel.font]; - BOOL const isVisible = bmManager.IsVisible(categoryIndex); + BOOL const isVisible = bmManager.IsVisible(categoryId); cell.imageView.image = [UIImage imageNamed:(isVisible ? @"ic_show" : @"ic_hide")]; cell.imageView.mwm_coloring = isVisible ? MWMImageColoringBlue : MWMImageColoringBlack; cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld", - bmManager.GetUserMarkIds(categoryIndex).size() + bmManager.GetTrackIds(categoryIndex).size()]; + bmManager.GetUserMarkIds(categoryId).size() + bmManager.GetTrackIds(categoryId).size()]; } cell.backgroundColor = [UIColor white]; cell.textLabel.textColor = [UIColor blackPrimaryText]; diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 25b4d98776..d2266b6f28 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -144,7 +144,7 @@ void Bookmark::Detach() BookmarkCategory::BookmarkCategory(std::string const & name, df::MarkGroupID groupID) : Base(UserMark::Type::BOOKMARK) - , m_groupID(groupID) + , m_groupId(groupID) , m_name(name) {} @@ -230,7 +230,7 @@ class KMLParser { m_name.clear(); m_description.clear(); - m_org = m2::PointD(-1000, -1000); + m_org = m2::PointD(0.0, 0.0); m_type.clear(); m_scale = -1.0; m_timeStamp = my::INVALID_TIME_STAMP; @@ -247,7 +247,6 @@ class KMLParser bool ParsePoint(std::string const & s, char const * delim, m2::PointD & pt) { // order in string is: lon, lat, z - strings::SimpleTokenizer iter(s, delim); if (iter) { @@ -281,16 +280,16 @@ class KMLParser { m_geometryType = GEOMETRY_TYPE_LINE; - strings::SimpleTokenizer cortegeIter(s, blockSeparator); - while (cortegeIter) + strings::SimpleTokenizer tupleIter(s, blockSeparator); + while (tupleIter) { m2::PointD pt; - if (ParsePoint(*cortegeIter, coordSeparator, pt)) + if (ParsePoint(*tupleIter, coordSeparator, pt)) { if (m_points.GetSize() == 0 || !(pt - m_points.Back()).IsAlmostZero()) m_points.Add(pt); } - ++cortegeIter; + ++tupleIter; } } @@ -345,7 +344,7 @@ class KMLParser public: KMLParser(KMLData & data) - : m_data(data) + : m_data(data) { Reset(); } @@ -438,7 +437,7 @@ public: if (currTag == "name") m_data.m_name = value; else if (currTag == "visibility") - m_data.m_visible = value == "0" ? false : true; + m_data.m_visible = value != "0"; } else if (prevTag == kPlacemark) { diff --git a/map/bookmark.hpp b/map/bookmark.hpp index 7354fec4aa..ecc7d7dc5c 100644 --- a/map/bookmark.hpp +++ b/map/bookmark.hpp @@ -124,7 +124,7 @@ public: void AttachTrack(df::LineID markId); void DetachTrack(df::LineID markId); - df::MarkGroupID GetID() const { return m_groupID; } + df::MarkGroupID GetID() const { return m_groupId; } df::LineIDSet const & GetUserLines() const override { return m_tracks; } void SetName(std::string const & name) { m_name = name; } @@ -133,7 +133,7 @@ public: std::string const & GetFileName() const { return m_file; } private: - const df::MarkGroupID m_groupID; + df::MarkGroupID const m_groupId; std::string m_name; // Stores file name from which bookmarks were loaded. std::string m_file; diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 9ff4f228b4..486e5da2ec 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -57,8 +57,10 @@ bool IsBadCharForPath(strings::UniChar const & c) static strings::UniChar const illegalChars[] = {':', '/', '\\', '<', '>', '\"', '|', '?', '*'}; for (size_t i = 0; i < ARRAY_SIZE(illegalChars); ++i) + { if (c < ' ' || illegalChars[i] == c) return true; + } return false; } @@ -141,7 +143,7 @@ BookmarkManager::BookmarkManager(Callbacks && callbacks) { ASSERT(m_callbacks.m_getStringsBundle != nullptr, ()); m_userMarkLayers.reserve(UserMark::BOOKMARK); - for (size_t i = 0; i < UserMark::BOOKMARK; ++i) + for (uint32_t i = 0; i < UserMark::BOOKMARK; ++i) m_userMarkLayers.emplace_back(std::make_unique(static_cast(i))); m_selectionMark = CreateUserMark(m2::PointD{}); @@ -322,37 +324,45 @@ void BookmarkManager::OnEditSessionClosed() void BookmarkManager::NotifyChanges() { - if (!m_changesTracker.CheckChanges()) - return; - - df::DrapeEngineLockGuard lock(m_drapeEngine); - if (!lock) + if (!m_changesTracker.CheckChanges() && !m_firstDrapeNotification) return; bool isBookmarks = false; - auto engine = lock.Get(); for (auto groupId : m_changesTracker.GetDirtyGroupIds()) { - isBookmarks |= IsBookmarkCategory(groupId); - auto * group = FindContainer(groupId); - engine->ChangeVisibilityUserMarksGroup(groupId, group->IsVisible()); + if (IsBookmarkCategory(groupId)) + { + isBookmarks = true; + break; + } } - - engine->UpdateUserMarks(&m_changesTracker); - - for (auto groupId : m_changesTracker.GetDirtyGroupIds()) - { - auto * group = FindContainer(groupId); - if (group->GetUserMarks().empty() && group->GetUserLines().empty()) - engine->ClearUserMarksGroup(groupId); - group->ResetChanges(); - } - - engine->InvalidateUserMarks(); - if (isBookmarks) SendBookmarksChanges(); + df::DrapeEngineLockGuard lock(m_drapeEngine); + if (lock) + { + auto engine = lock.Get(); + for (auto groupId : m_changesTracker.GetDirtyGroupIds()) + { + auto *group = FindContainer(groupId); + engine->ChangeVisibilityUserMarksGroup(groupId, group->IsVisible()); + } + + engine->UpdateUserMarks(&m_changesTracker, m_firstDrapeNotification); + m_firstDrapeNotification = false; + + for (auto groupId : m_changesTracker.GetDirtyGroupIds()) + { + auto *group = FindContainer(groupId); + if (group->GetUserMarks().empty() && group->GetUserLines().empty()) + engine->ClearUserMarksGroup(groupId); + group->ResetChanges(); + } + + engine->InvalidateUserMarks(); + } + for (auto const markId : m_changesTracker.GetUpdatedMarkIds()) GetMark(markId)->ResetChanges(); @@ -428,11 +438,10 @@ bool BookmarkManager::IsVisible(df::MarkGroupID groupId) const return FindContainer(groupId)->IsVisible(); } -//////////////////////////// - void BookmarkManager::SetDrapeEngine(ref_ptr engine) { m_drapeEngine.Set(engine); + m_firstDrapeNotification = true; } void BookmarkManager::UpdateViewport(ScreenBase const & screen) @@ -687,7 +696,7 @@ df::MarkGroupID BookmarkManager::LastEditedBMCategory() } if (m_categories.empty()) - CreateBmCategory(m_callbacks.m_getStringsBundle().GetString("my_places")); + CreateBookmarkCategory(m_callbacks.m_getStringsBundle().GetString("my_places")); return m_bmGroupsIdList.front(); } @@ -750,7 +759,7 @@ bool BookmarkManager::HasBmCategory(df::MarkGroupID groupID) const return m_categories.find(groupID) != m_categories.end(); } -df::MarkGroupID BookmarkManager::CreateBmCategory(std::string const & name) +df::MarkGroupID BookmarkManager::CreateBookmarkCategory(std::string const & name) { auto const groupId = m_nextGroupID++; auto & cat = m_categories[groupId]; @@ -866,7 +875,7 @@ void BookmarkManager::CreateCategories(KMLDataCollection && dataCollection) } else { - groupID = CreateBmCategory(data->m_name); + groupID = CreateBookmarkCategory(data->m_name); group = GetBmCategory(groupID); group->SetFileName(data->m_file); group->SetIsVisible(data->m_visible); @@ -1151,6 +1160,15 @@ bool BookmarkManager::SaveToKMLFile(df::MarkGroupID groupID) return false; } +df::GroupIDSet BookmarkManager::MarksChangesTracker::GetAllGroupIds() const +{ + auto const & groupIds = m_bmManager.GetBmGroupsIdList(); + df::GroupIDSet resultingSet(groupIds.begin(), groupIds.end()); + for (uint32_t i = 0; i < UserMark::BOOKMARK; ++i) + resultingSet.insert(static_cast(i)); + return resultingSet; +} + bool BookmarkManager::MarksChangesTracker::IsGroupVisible(df::MarkGroupID groupID) const { return m_bmManager.IsVisible(groupID); @@ -1252,12 +1270,6 @@ Track * BookmarkManager::EditSession::CreateTrack(m2::PolylineD const & polyline return m_bmManager.CreateTrack(polyline, p); } -/* -UserMark * BookmarkManager::EditSession::GetUserMarkForEdit(df::MarkID markID) -{ - return m_bmManager.GetUserMarkForEdit(markID); -}*/ - Bookmark * BookmarkManager::EditSession::GetBookmarkForEdit(df::MarkID markID) { return m_bmManager.GetBookmarkForEdit(markID); diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index 5ad2a9d78a..d4bb0ef515 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -86,13 +86,12 @@ public: return m_bmManager.GetMarkForEdit(markId); } - //UserMark * GetUserMarkForEdit(df::MarkID markID); Bookmark * GetBookmarkForEdit(df::MarkID markID); template - void DeleteUserMarks(UserMark::Type type, F deletePredicate) + void DeleteUserMarks(UserMark::Type type, F && deletePredicate) { - return m_bmManager.DeleteUserMarks(type, deletePredicate); + return m_bmManager.DeleteUserMarks(type, std::move(deletePredicate)); }; void DeleteUserMark(df::MarkID markId); @@ -153,13 +152,13 @@ public: bool IsVisible(df::MarkGroupID groupId) const; - df::MarkGroupID CreateBmCategory(std::string const & name); + df::MarkGroupID CreateBookmarkCategory(std::string const & name); std::string const & GetCategoryName(df::MarkGroupID categoryId) const; std::string const & GetCategoryFileName(df::MarkGroupID categoryId) const; void SetCategoryName(df::MarkGroupID categoryId, std::string const & name); - df::GroupIDList const & GetBmGroupsIdList() const { return m_bmGroupsIdList; } + df::GroupIDCollection const & GetBmGroupsIdList() const { return m_bmGroupsIdList; } bool HasBmCategory(df::MarkGroupID groupID) const; df::MarkGroupID LastEditedBMCategory(); std::string LastEditedBMType() const; @@ -200,6 +199,7 @@ private: void ResetChanges(); // UserMarksProvider + df::GroupIDSet GetAllGroupIds() const override; df::GroupIDSet const & GetDirtyGroupIds() const override { return m_dirtyGroups; } df::MarkIDSet const & GetCreatedMarkIds() const override { return m_createdMarks; } df::MarkIDSet const & GetRemovedMarkIds() const override { return m_removedMarks; } @@ -246,7 +246,7 @@ private: } template - void DeleteUserMarks(UserMark::Type type, F deletePredicate) + void DeleteUserMarks(UserMark::Type type, F && deletePredicate) { std::list marksToDelete; for (auto markId : GetUserMarkIds(type)) @@ -321,11 +321,12 @@ private: df::MarkGroupID m_nextGroupID; uint32_t m_openedEditSessionsCount = 0; bool m_loadBookmarksFinished = false; + bool m_firstDrapeNotification = false; ScreenBase m_viewport; CategoriesCollection m_categories; - df::GroupIDList m_bmGroupsIdList; + df::GroupIDCollection m_bmGroupsIdList; std::string m_lastCategoryUrl; std::string m_lastType; diff --git a/map/framework.cpp b/map/framework.cpp index 2a67508b82..b90ac27885 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -735,7 +735,7 @@ void Framework::LoadBookmarks() df::MarkGroupID Framework::AddCategory(string const & categoryName) { - return GetBookmarkManager().CreateBmCategory(categoryName); + return GetBookmarkManager().CreateBookmarkCategory(categoryName); } void Framework::FillBookmarkInfo(Bookmark const & bmk, place_page::Info & info) const diff --git a/map/user_mark.hpp b/map/user_mark.hpp index bc9c9c0326..b072a766b3 100644 --- a/map/user_mark.hpp +++ b/map/user_mark.hpp @@ -44,8 +44,7 @@ public: UserMark(m2::PointD const & ptOrg, UserMark::Type type); - static Type GetMarkType(df::MarkID); -// static df::MarkGroupID GetGroupId(UserMark::Type type); + static Type GetMarkType(df::MarkID id); Type GetMarkType() const { return GetMarkType(GetId()); } df::MarkGroupID GetGroupId() const override { return GetMarkType(); } diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 7999667147..9827ecb051 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -370,12 +370,10 @@ void DrawWidget::SubmitRoutingPoint(m2::PointD const & pt) void DrawWidget::SubmitBookmark(m2::PointD const & pt) { - size_t categoryIndex = 0; - auto category = m_framework.GetBookmarkManager().GetBmCategory(categoryIndex); - if (category == nullptr) - categoryIndex = m_framework.GetBookmarkManager().CreateBmCategory("Desktop_bookmarks"); + if (!m_framework.GetBookmarkManager().HasBmCategory(m_bookmarksCategoryId)) + m_bookmarksCategoryId = m_framework.GetBookmarkManager().CreateBookmarkCategory("Desktop_bookmarks"); BookmarkData data("", "placemark-red"); - m_framework.GetBookmarkManager().AddBookmark(categoryIndex, m_framework.P3dtoG(pt), data); + m_framework.GetBookmarkManager().GetEditSession().CreateBookmark(m_framework.P3dtoG(pt), data, m_bookmarksCategoryId); } void DrawWidget::FollowRoute() diff --git a/qt/qt_common/map_widget.hpp b/qt/qt_common/map_widget.hpp index a238532e88..846bb4e9f2 100644 --- a/qt/qt_common/map_widget.hpp +++ b/qt/qt_common/map_widget.hpp @@ -3,6 +3,7 @@ #include "drape/pointers.hpp" #include "drape_frontend/gui/skin.hpp" #include "drape_frontend/user_event_stream.hpp" +#include #include "qt/qt_common/qtoglcontextfactory.hpp" #include @@ -86,6 +87,7 @@ protected: bool m_apiOpenGLES3; ScaleSlider * m_slider; SliderState m_sliderState; + df::MarkGroupID m_bookmarksCategoryId = 0; qreal m_ratio; drape_ptr m_contextFactory;