mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-09 18:27:49 -04:00
Consolidate / tweak bookmark & recent bookmark / activation behavior
This commit is contained in:
parent
cc8c992123
commit
6237317cdb
@ -62,6 +62,16 @@ void BookmarkMgr::removeBookmark(BookmarkEntry *be) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BookmarkMgr::addGroup(std::string group) {
|
||||||
|
std::lock_guard < std::mutex > lock(busy_lock);
|
||||||
|
|
||||||
|
if (bmData.find(group) == bmData.end()) {
|
||||||
|
BookmarkList dummy = bmData[group];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -78,6 +88,7 @@ BookmarkList BookmarkMgr::getBookmarks(std::string group) {
|
|||||||
return bmData[group];
|
return bmData[group];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BookmarkMgr::getGroups(BookmarkNames &arr) {
|
void BookmarkMgr::getGroups(BookmarkNames &arr) {
|
||||||
for (BookmarkMap::iterator i = bmData.begin(); i!= bmData.end(); ++i) {
|
for (BookmarkMap::iterator i = bmData.begin(); i!= bmData.end(); ++i) {
|
||||||
arr.push_back(i->first);
|
arr.push_back(i->first);
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
void removeBookmark(std::string group, BookmarkEntry *be);
|
void removeBookmark(std::string group, BookmarkEntry *be);
|
||||||
void removeBookmark(BookmarkEntry *be);
|
void removeBookmark(BookmarkEntry *be);
|
||||||
|
|
||||||
|
void addGroup(std::string group);
|
||||||
BookmarkList getBookmarks(std::string group);
|
BookmarkList getBookmarks(std::string group);
|
||||||
void getGroups(BookmarkNames &arr);
|
void getGroups(BookmarkNames &arr);
|
||||||
void getGroups(wxArrayString &arr);
|
void getGroups(wxArrayString &arr);
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
#define BOOKMARK_VIEW_CHOICE_DEFAULT "Bookmark.."
|
#define BOOKMARK_VIEW_CHOICE_DEFAULT "Bookmark.."
|
||||||
#define BOOKMARK_VIEW_CHOICE_NEW "(New Group..)"
|
#define BOOKMARK_VIEW_CHOICE_NEW "(New Group..)"
|
||||||
|
|
||||||
|
#define BOOKMARK_VIEW_STR_ADD_GROUP "Add Group"
|
||||||
|
#define BOOKMARK_VIEW_STR_ADD_GROUP_DESC "Enter Group Name"
|
||||||
|
|
||||||
BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : BookmarkPanel(parent, id, pos, size, style) {
|
BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : BookmarkPanel(parent, id, pos, size, style) {
|
||||||
|
|
||||||
rootBranch = m_treeView->AddRoot("Root");
|
rootBranch = m_treeView->AddRoot("Root");
|
||||||
@ -217,7 +220,9 @@ void BookmarkView::onTreeEndLabelEdit( wxTreeEvent& event ) {
|
|||||||
|
|
||||||
void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
|
void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
|
||||||
if (recentSel) {
|
if (recentSel) {
|
||||||
|
wxGetApp().getBookmarkMgr().removeRecent(recentSel);
|
||||||
activateBookmark(recentSel);
|
activateBookmark(recentSel);
|
||||||
|
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||||
}
|
}
|
||||||
if (bookmarkSel) {
|
if (bookmarkSel) {
|
||||||
activateBookmark(bookmarkSel);
|
activateBookmark(bookmarkSel);
|
||||||
@ -238,8 +243,8 @@ void BookmarkView::onTreeExpanded( wxTreeEvent& event ) {
|
|||||||
void BookmarkView::onTreeItemMenu( wxTreeEvent& event ) {
|
void BookmarkView::onTreeItemMenu( wxTreeEvent& event ) {
|
||||||
if (m_treeView->GetSelection() == bookmarkBranch) {
|
if (m_treeView->GetSelection() == bookmarkBranch) {
|
||||||
wxMenu menu;
|
wxMenu menu;
|
||||||
menu.Append(wxCONTEXT_ADD_GROUP_ID, "Add Group");
|
menu.Append(wxCONTEXT_ADD_GROUP_ID, BOOKMARK_VIEW_STR_ADD_GROUP);
|
||||||
menu.Connect(wxCONTEXT_ADD_GROUP_ID, wxEVT_MENU, (wxObjectEventFunction)&BookmarkView::onMenuItem);
|
menu.Connect(wxCONTEXT_ADD_GROUP_ID, wxEVT_MENU, (wxObjectEventFunction)&BookmarkView::onMenuItem, nullptr, this);
|
||||||
PopupMenu(&menu);
|
PopupMenu(&menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,6 +317,24 @@ wxButton *BookmarkView::addButton(wxWindow *parent, std::string labelVal, wxObje
|
|||||||
return nButton;
|
return nButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BookmarkView::doBookmarkActive(std::string group, DemodulatorInstance *demod) {
|
||||||
|
wxGetApp().getBookmarkMgr().addBookmark(group, demod);
|
||||||
|
wxGetApp().getBookmarkMgr().updateBookmarks();
|
||||||
|
activeSelection(demod);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BookmarkView::doBookmarkRecent(std::string group, BookmarkEntry *be) {
|
||||||
|
wxGetApp().getBookmarkMgr().removeRecent(be);
|
||||||
|
wxGetApp().getBookmarkMgr().addBookmark(group, be);
|
||||||
|
wxGetApp().getBookmarkMgr().updateBookmarks();
|
||||||
|
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||||
|
bookmarkSelection(be);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BookmarkView::updateBookmarkChoices() {
|
void BookmarkView::updateBookmarkChoices() {
|
||||||
if (!bookmarkChoices.empty()) {
|
if (!bookmarkChoices.empty()) {
|
||||||
bookmarkChoices.erase(bookmarkChoices.begin(),bookmarkChoices.end());
|
bookmarkChoices.erase(bookmarkChoices.begin(),bookmarkChoices.end());
|
||||||
@ -341,7 +364,7 @@ void BookmarkView::onBookmarkChoice( wxCommandEvent &event ) {
|
|||||||
wxString stringVal = "";
|
wxString stringVal = "";
|
||||||
|
|
||||||
if (sel == (numSel-1)) {
|
if (sel == (numSel-1)) {
|
||||||
stringVal = wxGetTextFromUser("Enter Group Name", "Add Group", "");
|
stringVal = wxGetTextFromUser(BOOKMARK_VIEW_STR_ADD_GROUP_DESC, BOOKMARK_VIEW_STR_ADD_GROUP, "");
|
||||||
} else {
|
} else {
|
||||||
stringVal = bookmarkChoices[sel];
|
stringVal = bookmarkChoices[sel];
|
||||||
}
|
}
|
||||||
@ -353,16 +376,10 @@ void BookmarkView::onBookmarkChoice( wxCommandEvent &event ) {
|
|||||||
groupSel = stringVal;
|
groupSel = stringVal;
|
||||||
|
|
||||||
if (activeSel) {
|
if (activeSel) {
|
||||||
wxGetApp().getBookmarkMgr().addBookmark(groupSel, activeSel);
|
doBookmarkActive(groupSel, activeSel);
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
|
||||||
activeSelection(activeSel);
|
|
||||||
}
|
}
|
||||||
if (recentSel) {
|
if (recentSel) {
|
||||||
wxGetApp().getBookmarkMgr().removeRecent(recentSel);
|
doBookmarkRecent(groupSel, recentSel);
|
||||||
wxGetApp().getBookmarkMgr().addBookmark(groupSel, recentSel);
|
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
|
||||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
|
||||||
bookmarkSelection(recentSel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +526,7 @@ void BookmarkView::bookmarkBranchSelection() {
|
|||||||
clearButtons();
|
clearButtons();
|
||||||
hideProps();
|
hideProps();
|
||||||
|
|
||||||
addButton(m_buttonPanel, "Add Group", wxCommandEventHandler( BookmarkView::onAddGroup ));
|
addButton(m_buttonPanel, BOOKMARK_VIEW_STR_ADD_GROUP, wxCommandEventHandler( BookmarkView::onAddGroup ));
|
||||||
|
|
||||||
showButtons();
|
showButtons();
|
||||||
refreshLayout();
|
refreshLayout();
|
||||||
@ -618,15 +635,18 @@ void BookmarkView::onActivateBookmark( wxCommandEvent& event ) {
|
|||||||
|
|
||||||
void BookmarkView::onActivateRecent( wxCommandEvent& event ) {
|
void BookmarkView::onActivateRecent( wxCommandEvent& event ) {
|
||||||
if (recentSel) {
|
if (recentSel) {
|
||||||
|
wxGetApp().getBookmarkMgr().removeRecent(recentSel);
|
||||||
activateBookmark(recentSel);
|
activateBookmark(recentSel);
|
||||||
|
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||||
|
recentSel = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BookmarkView::onAddGroup( wxCommandEvent& event ) {
|
void BookmarkView::onAddGroup( wxCommandEvent& event ) {
|
||||||
wxString stringVal = wxGetTextFromUser("Enter Group Name", "Add Group", "");
|
wxString stringVal = wxGetTextFromUser(BOOKMARK_VIEW_STR_ADD_GROUP_DESC, BOOKMARK_VIEW_STR_ADD_GROUP, "");
|
||||||
if (stringVal.ToStdString() != "") {
|
if (stringVal.ToStdString() != "") {
|
||||||
wxGetApp().getBookmarkMgr().getBookmarks(stringVal.ToStdString());
|
wxGetApp().getBookmarkMgr().addGroup(stringVal.ToStdString());
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
wxGetApp().getBookmarkMgr().updateBookmarks();
|
||||||
groupSel = stringVal;
|
groupSel = stringVal;
|
||||||
}
|
}
|
||||||
@ -708,41 +728,27 @@ void BookmarkView::onTreeEndDrag( wxTreeEvent& event ) {
|
|||||||
if (!tvi) {
|
if (!tvi) {
|
||||||
if (event.GetItem() == bookmarkBranch) {
|
if (event.GetItem() == bookmarkBranch) {
|
||||||
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||||
wxGetApp().getBookmarkMgr().addBookmark("Ungrouped", dragItem->demod);
|
doBookmarkActive("Ungrouped", dragItem->demod);
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
|
||||||
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||||
wxGetApp().getBookmarkMgr().removeRecent(dragItem->bookmarkEnt);
|
doBookmarkRecent("Ungrouped", dragItem->bookmarkEnt);
|
||||||
wxGetApp().getBookmarkMgr().addBookmark("Ungrouped", dragItem->bookmarkEnt);
|
|
||||||
m_treeView->Delete(dragItemId);
|
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
|
||||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||||
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Group Item
|
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Group Item
|
||||||
wxGetApp().getBookmarkMgr().addBookmark(tvi->groupName, dragItem->demod);
|
doBookmarkActive(tvi->groupName, dragItem->demod);
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
|
||||||
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item
|
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item
|
||||||
wxGetApp().getBookmarkMgr().removeRecent(dragItem->bookmarkEnt);
|
doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt);
|
||||||
wxGetApp().getBookmarkMgr().addBookmark(tvi->groupName, dragItem->bookmarkEnt);
|
|
||||||
m_treeView->Delete(dragItemId);
|
m_treeView->Delete(dragItemId);
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
|
||||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
|
||||||
}
|
}
|
||||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||||
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Same Group
|
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Same Group
|
||||||
wxGetApp().getBookmarkMgr().addBookmark(tvi->groupName, dragItem->demod);
|
doBookmarkActive(tvi->groupName, dragItem->demod);
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
|
||||||
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Same Group
|
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Same Group
|
||||||
wxGetApp().getBookmarkMgr().removeRecent(dragItem->bookmarkEnt);
|
doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt);
|
||||||
wxGetApp().getBookmarkMgr().addBookmark(tvi->groupName, dragItem->bookmarkEnt);
|
|
||||||
m_treeView->Delete(dragItemId);
|
m_treeView->Delete(dragItemId);
|
||||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
|
||||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,9 @@ protected:
|
|||||||
wxButton *makeButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler);
|
wxButton *makeButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler);
|
||||||
wxButton *addButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler);
|
wxButton *addButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler);
|
||||||
|
|
||||||
|
void doBookmarkActive(std::string group, DemodulatorInstance *demod);
|
||||||
|
void doBookmarkRecent(std::string group, BookmarkEntry *be);
|
||||||
|
|
||||||
void updateBookmarkChoices();
|
void updateBookmarkChoices();
|
||||||
void addBookmarkChoice(wxWindow *parent);
|
void addBookmarkChoice(wxWindow *parent);
|
||||||
void onBookmarkChoice( wxCommandEvent &event );
|
void onBookmarkChoice( wxCommandEvent &event );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user