From 7ce19e9dbdb17d090eb33f31136ea70551caa037 Mon Sep 17 00:00:00 2001 From: vng Date: Thu, 18 Jul 2013 21:03:16 +0300 Subject: [PATCH] [iOS] Fix adding of bookmark. --- android/jni/com/mapswithme/maps/Framework.cpp | 8 +------- iphone/Maps/Bookmarks/PlacePageVC.mm | 6 ++---- map/bookmark_manager.cpp | 9 +++------ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index b17b5e7740..8559cc5c76 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -557,13 +557,7 @@ namespace android BookmarkAndCategory Framework::AddBookmark(size_t cat, Bookmark & bm) { - size_t const ind = m_work.AddBookmark(cat, bm); - - BookmarkCategory * pCat = m_work.GetBmCategory(cat); - pCat->SetVisible(true); - pCat->SaveToKMLFile(); - - return BookmarkAndCategory(cat, ind); + return BookmarkAndCategory(cat, m_work.AddBookmark(cat, bm)); } void Framework::ReplaceBookmark(BookmarkAndCategory const & ind, Bookmark & bm) diff --git a/iphone/Maps/Bookmarks/PlacePageVC.mm b/iphone/Maps/Bookmarks/PlacePageVC.mm index 39a49a5f9f..8386f2c6ac 100644 --- a/iphone/Maps/Bookmarks/PlacePageVC.mm +++ b/iphone/Maps/Bookmarks/PlacePageVC.mm @@ -640,12 +640,10 @@ typedef enum {Editing, Saved} Mode; -(void)addBookmarkToCategory:(size_t)index { - BookmarkCategory * cat = GetFramework().GetBmCategory(index); Bookmark bm(m2::PointD(_pinGlobalPosition.x, _pinGlobalPosition.y), [self.pinTitle UTF8String], [self.pinColor UTF8String]); bm.SetDescription([self.pinNotes UTF8String]); - cat->AddBookmark(bm); - cat->SaveToKMLFile(); - _pinEditedBookmark = pair(index, cat->GetBookmarksCount() - 1); + + _pinEditedBookmark = pair(index, GetFramework().AddBookmark(index, bm)); } -(void)initializeProperties:(NSString *)name notes:(NSString *)notes color:(NSString *)color category:(BookmarkAndCategory) bmAndCat point: diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 6fc42ea30f..c414dcfff4 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -76,15 +76,12 @@ void BookmarkManager::LoadBookmark(string const & filePath) size_t BookmarkManager::AddBookmark(size_t categoryIndex, Bookmark & bm) { bm.SetTimeStamp(time(0)); - bm.SetScale(scales::GetScaleLevelD(m_framework.GetNavigator().Screen().GlobalRect().GetLocalRect())); + bm.SetScale(m_framework.GetDrawScale()); BookmarkCategory * pCat = m_categories[categoryIndex]; pCat->AddBookmark(bm); - - // Immediately do save category for the new one - // (we need it for the last used category ID). - if (pCat->GetFileName().empty()) - m_categories[categoryIndex]->SaveToKMLFile(); + pCat->SetVisible(true); + pCat->SaveToKMLFile(); m_lastCategoryUrl = pCat->GetFileName(); return pCat->GetBookmarksCount() - 1;