mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-12-03 09:05:12 -05:00
Bookmarking bugs, quirks and improvements
This commit is contained in:
parent
4e2fced000
commit
d48887d132
@ -69,6 +69,9 @@ void BookmarkMgr::moveBookmark(BookmarkEntry *be, std::string group) {
|
|||||||
for (auto &bmd_i : bmData) {
|
for (auto &bmd_i : bmData) {
|
||||||
BookmarkList::iterator i = std::find(bmd_i.second.begin(), bmd_i.second.end(), be);
|
BookmarkList::iterator i = std::find(bmd_i.second.begin(), bmd_i.second.end(), be);
|
||||||
if (i != bmd_i.second.end()) {
|
if (i != bmd_i.second.end()) {
|
||||||
|
if (bmd_i.first == group) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
bmData[group].push_back(*i);
|
bmData[group].push_back(*i);
|
||||||
bmd_i.second.erase(i);
|
bmd_i.second.erase(i);
|
||||||
bmDataSorted[group] = false;
|
bmDataSorted[group] = false;
|
||||||
@ -104,7 +107,7 @@ void BookmarkMgr::renameGroup(std::string group, std::string ngroup) {
|
|||||||
std::lock_guard < std::mutex > lock(busy_lock);
|
std::lock_guard < std::mutex > lock(busy_lock);
|
||||||
|
|
||||||
BookmarkMap::iterator i = bmData.find(group);
|
BookmarkMap::iterator i = bmData.find(group);
|
||||||
BookmarkMap::iterator it = bmData.find(group);
|
BookmarkMap::iterator it = bmData.find(ngroup);
|
||||||
|
|
||||||
if (i != bmData.end() && it != bmData.end()) {
|
if (i != bmData.end() && it != bmData.end()) {
|
||||||
for (auto ii : bmData[group]) {
|
for (auto ii : bmData[group]) {
|
||||||
|
@ -14,6 +14,7 @@ public:
|
|||||||
|
|
||||||
std::string type;
|
std::string type;
|
||||||
std::wstring label;
|
std::wstring label;
|
||||||
|
std::wstring userLabel;
|
||||||
|
|
||||||
long long frequency;
|
long long frequency;
|
||||||
int bandwidth;
|
int bandwidth;
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
#define wxCONTEXT_ADD_GROUP_ID 1000
|
#define wxCONTEXT_ADD_GROUP_ID 1000
|
||||||
|
|
||||||
#define BOOKMARK_VIEW_CHOICE_DEFAULT "Bookmark.."
|
#define BOOKMARK_VIEW_CHOICE_DEFAULT "Bookmark.."
|
||||||
|
#define BOOKMARK_VIEW_CHOICE_MOVE "Move to.."
|
||||||
#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 "Add Group"
|
||||||
#define BOOKMARK_VIEW_STR_ADD_GROUP_DESC "Enter Group Name"
|
#define BOOKMARK_VIEW_STR_ADD_GROUP_DESC "Enter Group Name"
|
||||||
|
#define BOOKMARK_VIEW_STR_UNNAMED "Unnamed"
|
||||||
|
|
||||||
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) {
|
||||||
|
|
||||||
@ -128,6 +130,9 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
|
|||||||
wxTreeItemId group_itm = m_treeView->AppendItem(bookmarkBranch, gn_i);
|
wxTreeItemId group_itm = m_treeView->AppendItem(bookmarkBranch, gn_i);
|
||||||
m_treeView->SetItemData(group_itm, tvi);
|
m_treeView->SetItemData(group_itm, tvi);
|
||||||
groups[gn_i] = group_itm;
|
groups[gn_i] = group_itm;
|
||||||
|
if (gn_i == groupSel) {
|
||||||
|
bmSelFound = group_itm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bmExpandState) {
|
if (bmExpandState) {
|
||||||
@ -152,13 +157,14 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
|
|||||||
tvi->bookmarkEnt = bmEnt;
|
tvi->bookmarkEnt = bmEnt;
|
||||||
tvi->groupName = gn_i;
|
tvi->groupName = gn_i;
|
||||||
|
|
||||||
std::wstring labelVal;
|
std::wstring labelVal = bmEnt->label;
|
||||||
if (bmEnt->label == "") {
|
|
||||||
std::string wstr = frequencyToStr(tvi->bookmarkEnt->frequency) + " " + tvi->bookmarkEnt->type;
|
if (labelVal == "") {
|
||||||
bmEnt->label = std::wstring(wstr.begin(),wstr.end());
|
std::string freqStr = frequencyToStr(bmEnt->frequency) + " " + bmEnt->type;
|
||||||
|
labelVal = wstring(freqStr.begin(),freqStr.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTreeItemId itm = m_treeView->AppendItem(groupItem, bmEnt->label);
|
wxTreeItemId itm = m_treeView->AppendItem(groupItem, labelVal);
|
||||||
m_treeView->SetItemData(itm, tvi);
|
m_treeView->SetItemData(itm, tvi);
|
||||||
if (bookmarkSel == bmEnt && groupExpanded) {
|
if (bookmarkSel == bmEnt && groupExpanded) {
|
||||||
bmSelFound = itm;
|
bmSelFound = itm;
|
||||||
@ -459,7 +465,7 @@ void BookmarkView::updateBookmarkChoices() {
|
|||||||
if (!bookmarkChoices.empty()) {
|
if (!bookmarkChoices.empty()) {
|
||||||
bookmarkChoices.erase(bookmarkChoices.begin(),bookmarkChoices.end());
|
bookmarkChoices.erase(bookmarkChoices.begin(),bookmarkChoices.end());
|
||||||
}
|
}
|
||||||
bookmarkChoices.push_back(BOOKMARK_VIEW_CHOICE_DEFAULT);
|
bookmarkChoices.push_back((bookmarkSel!=nullptr)?BOOKMARK_VIEW_CHOICE_MOVE:BOOKMARK_VIEW_CHOICE_DEFAULT);
|
||||||
wxGetApp().getBookmarkMgr().getGroups(bookmarkChoices);
|
wxGetApp().getBookmarkMgr().getGroups(bookmarkChoices);
|
||||||
bookmarkChoices.push_back(BOOKMARK_VIEW_CHOICE_NEW);
|
bookmarkChoices.push_back(BOOKMARK_VIEW_CHOICE_NEW);
|
||||||
}
|
}
|
||||||
@ -501,6 +507,9 @@ void BookmarkView::onBookmarkChoice( wxCommandEvent &event ) {
|
|||||||
if (recentSel) {
|
if (recentSel) {
|
||||||
doBookmarkRecent(groupSel, recentSel);
|
doBookmarkRecent(groupSel, recentSel);
|
||||||
}
|
}
|
||||||
|
if (bookmarkSel) {
|
||||||
|
doMoveBookmark(bookmarkSel, groupSel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -589,6 +598,7 @@ void BookmarkView::bookmarkSelection(BookmarkEntry *bmSel) {
|
|||||||
|
|
||||||
clearButtons();
|
clearButtons();
|
||||||
|
|
||||||
|
addBookmarkChoice(m_buttonPanel);
|
||||||
addButton(m_buttonPanel, "Activate Bookmark", wxCommandEventHandler( BookmarkView::onActivateBookmark ));
|
addButton(m_buttonPanel, "Activate Bookmark", wxCommandEventHandler( BookmarkView::onActivateBookmark ));
|
||||||
addButton(m_buttonPanel, "Remove Bookmark", wxCommandEventHandler( BookmarkView::onRemoveBookmark ));
|
addButton(m_buttonPanel, "Remove Bookmark", wxCommandEventHandler( BookmarkView::onRemoveBookmark ));
|
||||||
|
|
||||||
@ -643,9 +653,16 @@ void BookmarkView::groupSelection(std::string groupName) {
|
|||||||
|
|
||||||
hideProps();
|
hideProps();
|
||||||
|
|
||||||
|
// m_labelText->SetValue(groupSel);
|
||||||
|
|
||||||
|
// m_labelText->Show();
|
||||||
|
// m_labelLabel->Show();
|
||||||
|
|
||||||
addButton(m_buttonPanel, "Remove Group", wxCommandEventHandler( BookmarkView::onRemoveGroup ));
|
addButton(m_buttonPanel, "Remove Group", wxCommandEventHandler( BookmarkView::onRemoveGroup ));
|
||||||
addButton(m_buttonPanel, "Rename Group", wxCommandEventHandler( BookmarkView::onRenameGroup ));
|
addButton(m_buttonPanel, "Rename Group", wxCommandEventHandler( BookmarkView::onRenameGroup ));
|
||||||
|
|
||||||
|
// showProps();
|
||||||
|
|
||||||
showButtons();
|
showButtons();
|
||||||
refreshLayout();
|
refreshLayout();
|
||||||
}
|
}
|
||||||
@ -737,6 +754,12 @@ void BookmarkView::onLabelText( wxCommandEvent& event ) {
|
|||||||
recentSel->node->child("user_label")->element()->set(newLabel);
|
recentSel->node->child("user_label")->element()->set(newLabel);
|
||||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||||
}
|
}
|
||||||
|
// else if (groupSel != "") {
|
||||||
|
// std::string newGroupName = m_labelText->GetValue().ToStdString();
|
||||||
|
// wxGetApp().getBookmarkMgr().renameGroup(groupSel, newGroupName);
|
||||||
|
// groupSel = newGroupName;
|
||||||
|
// wxGetApp().getBookmarkMgr().updateBookmarks();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -807,6 +830,7 @@ void BookmarkView::onAddGroup( wxCommandEvent& event ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BookmarkView::onRemoveGroup( wxCommandEvent& event ) {
|
void BookmarkView::onRemoveGroup( wxCommandEvent& event ) {
|
||||||
if (editingLabel) {
|
if (editingLabel) {
|
||||||
return;
|
return;
|
||||||
@ -908,9 +932,11 @@ 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) {
|
||||||
doBookmarkActive("Ungrouped", dragItem->demod);
|
doBookmarkActive(BOOKMARK_VIEW_STR_UNNAMED, dragItem->demod);
|
||||||
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||||
doBookmarkRecent("Ungrouped", dragItem->bookmarkEnt);
|
doBookmarkRecent(BOOKMARK_VIEW_STR_UNNAMED, dragItem->bookmarkEnt);
|
||||||
|
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||||
|
doMoveBookmark(dragItem->bookmarkEnt, BOOKMARK_VIEW_STR_UNNAMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user