Remove Bookmark functional

This commit is contained in:
Charles J. Cliffe 2016-11-10 21:48:57 -05:00
parent d4fb63cb77
commit 1d1aa515de
3 changed files with 25 additions and 7 deletions

View File

@ -39,6 +39,17 @@ void BookmarkMgr::removeBookmark(std::string group, BookmarkEntry *be) {
bmData[group].erase(be); bmData[group].erase(be);
} }
void BookmarkMgr::removeBookmark(BookmarkEntry *be) {
std::lock_guard < std::mutex > lockData(busy_lock);
std::lock_guard < std::mutex > lockEnt(be->busy_lock);
for (auto &bmd_i : bmData) {
if (bmd_i.second.find(be) != bmd_i.second.end()) {
bmd_i.second.erase(be);
}
}
}
BookmarkList BookmarkMgr::getBookmarks(std::string group) { BookmarkList BookmarkMgr::getBookmarks(std::string group) {
std::lock_guard < std::mutex > lock(busy_lock); std::lock_guard < std::mutex > lock(busy_lock);

View File

@ -42,6 +42,7 @@ public:
void addBookmark(std::string group, DemodulatorInstance *demod); void addBookmark(std::string group, DemodulatorInstance *demod);
void addBookmark(std::string group, BookmarkEntry *be); void addBookmark(std::string group, BookmarkEntry *be);
void removeBookmark(std::string group, BookmarkEntry *be); void removeBookmark(std::string group, BookmarkEntry *be);
void removeBookmark(BookmarkEntry *be);
BookmarkList getBookmarks(std::string group); BookmarkList getBookmarks(std::string group);

View File

@ -470,11 +470,11 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
if (!tvi) { if (!tvi) {
if (itm == bookmarkBranch) { if (itm == bookmarkBranch) {
bookmarkBranchSelection();
} else if (itm == activeBranch) { } else if (itm == activeBranch) {
activeBranchSelection();
} else if (itm == recentBranch) { } else if (itm == recentBranch) {
recentBranchSelection();
} else { } else {
m_propPanel->Hide(); m_propPanel->Hide();
hideProps(); hideProps();
@ -539,9 +539,11 @@ void BookmarkView::onBookmarkActive( wxCommandEvent& event ) {
} }
void BookmarkView::onBookmarkRecent( wxCommandEvent& event ) { void BookmarkView::onBookmarkRecent( wxCommandEvent& event ) {
if (bookmarkSel) { if (recentSel) {
wxGetApp().getBookmarkMgr().removeRecent(bookmarkSel); wxGetApp().getBookmarkMgr().removeRecent(recentSel);
wxGetApp().getBookmarkMgr().addBookmark("Ungrouped", bookmarkSel); wxGetApp().getBookmarkMgr().addBookmark("Ungrouped", recentSel);
wxGetApp().getBookmarkMgr().updateBookmarks();
wxGetApp().getBookmarkMgr().updateActiveList();
} }
} }
@ -557,7 +559,11 @@ void BookmarkView::onRemoveActive( wxCommandEvent& event ) {
void BookmarkView::onRemoveBookmark( wxCommandEvent& event ) { void BookmarkView::onRemoveBookmark( wxCommandEvent& event ) {
// todo if (bookmarkSel) {
wxGetApp().getBookmarkMgr().removeBookmark(bookmarkSel);
bookmarkSel = nullptr;
wxGetApp().getBookmarkMgr().updateBookmarks();
}
} }