forked from organicmaps/organicmaps-tmp
[bookmarks] Autosave bookmarks on delete/add operations in cross-platform code
This commit is contained in:
parent
ab5938e4f2
commit
e9ce334b61
2 changed files with 11 additions and 2 deletions
|
@ -36,6 +36,9 @@ void BookmarkCategory::DeleteBookmark(size_t index)
|
|||
{
|
||||
delete m_bookmarks[index];
|
||||
m_bookmarks.erase(m_bookmarks.begin() + index);
|
||||
// Save updated file
|
||||
if (!m_file.empty())
|
||||
(void)SaveToKMLFileAtPath(m_file);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -298,7 +298,10 @@ void Framework::LoadBookmarks()
|
|||
|
||||
void Framework::AddBookmark(string const & category, Bookmark const & bm)
|
||||
{
|
||||
GetBmCategory(category)->AddBookmark(bm);
|
||||
BookmarkCategory * cat = GetBmCategory(category);
|
||||
cat->AddBookmark(bm);
|
||||
// Autosave added bookmark
|
||||
(void)cat->SaveToKMLFileAtPath(GetPlatform().WritableDir());
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -339,7 +342,10 @@ bool Framework::DeleteBmCategory(size_t index)
|
|||
{
|
||||
if (index < m_bookmarks.size())
|
||||
{
|
||||
delete m_bookmarks[index];
|
||||
// Delete category file
|
||||
BookmarkCategory * cat = m_bookmarks[index];
|
||||
FileWriter::DeleteFileX(cat->GetFileName());
|
||||
delete cat;
|
||||
m_bookmarks.erase(m_bookmarks.begin() + index);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue