void BookMarkManager::ShowBookMark(size_t category, size_t index) { ::Framework * pFramework = GetFramework(); BookmarkCategory * pCategory = pFramework->GetBmCategory(category); ActivateBookMark(pCategory->GetBookmark(index)->Copy()); pFramework->ShowBookmark(BookmarkAndCategory(category, index)); }
Tizen::Base::String BookMarkManager::GetCategoryName(int const index) const { if (index > GetCategoriesCount()) return ""; if (index < 0) return ""; BookmarkCategory * pCategory = GetFramework()->GetBmCategory(index); return pCategory->GetName().c_str(); }
void BookmarkManager::SaveBookmarks() { for (auto it = m_categories.begin(); it != m_categories.end(); ++it) { BookmarkCategory * cat = *it; BookmarkCategory::Guard guard(*cat); cat->SaveToKMLFile(); } }
void BookMarkManager::SetCategoryName(int const index, Tizen::Base::String const & sName) const { if (index > GetCategoriesCount()) return; if (index < 0) return; BookmarkCategory * pCategory = GetFramework()->GetBmCategory(index); pCategory->SetName(FromTizenString(sName)); pCategory->SaveToKMLFile(); }
void BookmarkManager::DeleteBmCategory(CategoryIter i) { BookmarkCategory * cat = *i; m_categories.erase(i); cat->DeleteLater(); FileWriter::DeleteFileX(cat->GetFileName()); if (cat->CanBeDeleted()) delete cat; }
void BookmarkManager::ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkData const & bm) { BookmarkCategory * cat = m_categories[catIndex]; BookmarkCategory::Guard guard(*cat); static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(bmIndex))->SetData(bm); cat->SaveToKMLFile(); m_lastType = bm.GetType(); SaveState(); }
void BookMarkManager::DeleteBookMark(size_t category, size_t index) { ::Framework * pFramework = GetFramework(); BookmarkCategory * pCategory = pFramework->GetBmCategory(category); if (pCategory) { pCategory->DeleteBookmark(index); pCategory->SaveToKMLFile(); } pFramework->Invalidate(); ActivateBookMark(0); }
void BookMarkManager::RemoveCurBookMark() { Bookmark const * pBM = GetCurBookMark(); if (!pBM) return; m2::PointD const ptOrg = pBM->GetOrg(); ::Framework * pFramework = GetFramework(); BookmarkAndCategory const & bookmarkAndCategory = pFramework->FindBookmark(pBM); BookmarkCategory * category = pFramework->GetBmCategory(bookmarkAndCategory.first); if (category) { category->DeleteBookmark(bookmarkAndCategory.second); category->SaveToKMLFile(); } pFramework->Invalidate(); ActivateBookMark(pFramework->GetAddressMark(ptOrg)->Copy()); }
size_t BookmarkManager::AddBookmarkInMemory(size_t categoryIndex, m2::PointD const & ptOrg, BookmarkData & bm) { bm.SetTimeStamp(time(0)); bm.SetScale(m_framework.GetDrawScale()); BookmarkCategory * pCat = m_categories[categoryIndex]; BookmarkCategory::Guard guard(*pCat); static_cast<Bookmark *>(guard.m_controller.CreateUserMark(ptOrg))->SetData(bm); guard.m_controller.SetIsVisible(true); m_lastCategoryUrl = pCat->GetFileName(); m_lastType = bm.GetType(); SaveState(); // Bookmark always is pushed front. return 0; }
size_t BookmarkManager::MoveBookmark(size_t bmIndex, size_t curCatIndex, size_t newCatIndex) { BookmarkData data; m2::PointD ptOrg; // guard must be released before AddBookmark to prevent deadlock { BookmarkCategory * cat = m_framework.GetBmCategory(curCatIndex); BookmarkCategory::Guard guard(*cat); Bookmark const * bm = static_cast<Bookmark const *>(guard.m_controller.GetUserMark(bmIndex)); data = bm->GetData(); ptOrg = bm->GetPivot(); guard.m_controller.DeleteUserMark(bmIndex); cat->SaveToKMLFile(); } return AddBookmark(newCatIndex, ptOrg, data); }
Guard(BookmarkCategory & cat) : m_controller(cat.RequestController()) , m_cat(cat) { }
Bookmark const * BookMarkManager::GetBookMark(size_t category, size_t index) { ::Framework * pFramework = GetFramework(); BookmarkCategory * pCategory = pFramework->GetBmCategory(category); return pCategory->GetBookmark(index); }