diff options
author | vng <viktor.govako@gmail.com> | 2013-02-18 22:25:53 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:51:00 +0300 |
commit | d8f5301f4c9b18ed40f81ce8f28ef336572678c0 (patch) | |
tree | b3fc7fb4f3fc344b1c34e581d322f9af60ab2813 /map/bookmark.cpp | |
parent | e502fd04ddcac69e6352cf952d02488a44c12dfe (diff) |
[bookmarks] Handle timestamp in one function Framework::AddBookmark. Keep previous timestamp if bookmark is editing.
Diffstat (limited to 'map/bookmark.cpp')
-rw-r--r-- | map/bookmark.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 2d22202692..9b7e820d51 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -16,36 +16,27 @@ #include "../std/auto_ptr.hpp" -void BookmarkCategory::AddBookmarkImpl(Bookmark const & bm, double scale) +void BookmarkCategory::AddBookmark(Bookmark const & bm) { Bookmark * p = new Bookmark(bm); - p->SetScale(scale); - m_bookmarks.push_back(p); } -void BookmarkCategory::AddBookmark(Bookmark const & bm, double scale) +void BookmarkCategory::ReplaceBookmark(size_t index, Bookmark const & bm) { - AddBookmarkImpl(bm, scale); + ASSERT_LESS ( index, m_bookmarks.size(), () ); + if (index < m_bookmarks.size()) + { + delete m_bookmarks[index]; + m_bookmarks[index] = new Bookmark(bm); + } } -void BookmarkCategory::ReplaceBookmark(size_t index, Bookmark const & bm, double scale) +void BookmarkCategory::AssignTimeStamp(size_t index, Bookmark & bm) const { ASSERT_LESS ( index, m_bookmarks.size(), () ); if (index < m_bookmarks.size()) - { - Bookmark * p = new Bookmark(bm); - p->SetScale(scale); - - Bookmark const * old = m_bookmarks[index]; - // Save creation time stamp - p->SetTimeStamp(old->GetTimeStamp()); - m_bookmarks[index] = p; - - delete old; - } - else - LOG(LWARNING, ("Trying to replace non-existing bookmark")); + bm.SetTimeStamp(m_bookmarks[index]->GetTimeStamp()); } BookmarkCategory::~BookmarkCategory() @@ -207,7 +198,8 @@ namespace bookmark_impl Bookmark bm(m_org, m_name, m_type); bm.SetTimeStamp(m_timeStamp); bm.SetDescription(m_description); - m_category.AddBookmarkImpl(bm, m_scale); + bm.SetScale(m_scale); + m_category.AddBookmark(bm); Reset(); } m_tags.pop_back(); |