mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-02 13:17:48 -04:00
Basic bookmarking test
This commit is contained in:
parent
fab41f30be
commit
07c55ede21
@ -66,6 +66,23 @@ void BookmarkMgr::updateActiveList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BookmarkMgr::updateBookmarks() {
|
||||||
|
BookmarkView *bmv = wxGetApp().getAppFrame()->getBookmarkView();
|
||||||
|
|
||||||
|
if (bmv) {
|
||||||
|
bmv->updateBookmarks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkMgr::updateBookmarks(std::string group) {
|
||||||
|
BookmarkView *bmv = wxGetApp().getAppFrame()->getBookmarkView();
|
||||||
|
|
||||||
|
if (bmv) {
|
||||||
|
bmv->updateBookmarks(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BookmarkMgr::addRecent(DemodulatorInstance *demod) {
|
void BookmarkMgr::addRecent(DemodulatorInstance *demod) {
|
||||||
std::lock_guard < std::mutex > lock(busy_lock);
|
std::lock_guard < std::mutex > lock(busy_lock);
|
||||||
recents.push_back(demodToBookmarkEntry(demod));
|
recents.push_back(demodToBookmarkEntry(demod));
|
||||||
|
@ -48,6 +48,8 @@ public:
|
|||||||
BookmarkNames getGroups();
|
BookmarkNames getGroups();
|
||||||
|
|
||||||
void updateActiveList();
|
void updateActiveList();
|
||||||
|
void updateBookmarks();
|
||||||
|
void updateBookmarks(std::string group);
|
||||||
|
|
||||||
void addRecent(DemodulatorInstance *demod);
|
void addRecent(DemodulatorInstance *demod);
|
||||||
BookmarkList getRecents();
|
BookmarkList getRecents();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
#include <wx/textdlg.h>
|
#include <wx/textdlg.h>
|
||||||
|
#include <algorithm>
|
||||||
#define wxCONTEXT_ADD_GROUP_ID 1000
|
#define wxCONTEXT_ADD_GROUP_ID 1000
|
||||||
|
|
||||||
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) {
|
||||||
@ -29,6 +30,13 @@ void BookmarkView::onUpdateTimer( wxTimerEvent& event ) {
|
|||||||
|
|
||||||
doUpdateActive.store(false);
|
doUpdateActive.store(false);
|
||||||
}
|
}
|
||||||
|
if (doUpdateBookmarks.load()) {
|
||||||
|
wxTreeItemId bmSel = refreshBookmarks();
|
||||||
|
if (bmSel) {
|
||||||
|
m_treeView->SelectItem(bmSel);
|
||||||
|
}
|
||||||
|
doUpdateBookmarks.store(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::updateTheme() {
|
void BookmarkView::updateTheme() {
|
||||||
@ -61,13 +69,28 @@ void BookmarkView::updateActiveList() {
|
|||||||
doUpdateActive.store(true);
|
doUpdateActive.store(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::refreshBookmarks() {
|
void BookmarkView::updateBookmarks() {
|
||||||
|
doUpdateBookmarks.store(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkView::updateBookmarks(std::string group) {
|
||||||
|
doUpdateBookmarkGroup.insert(group);
|
||||||
|
doUpdateBookmarks.store(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxTreeItemId BookmarkView::refreshBookmarks() {
|
||||||
// if (!bookmarksInitialized) {
|
// if (!bookmarksInitialized) {
|
||||||
groupNames = wxGetApp().getBookmarkMgr().getGroups();
|
groupNames = wxGetApp().getBookmarkMgr().getGroups();
|
||||||
if (!groupNames.size()) {
|
if (!groupNames.size()) {
|
||||||
wxGetApp().getBookmarkMgr().getGroup("Uncategorized");
|
wxGetApp().getBookmarkMgr().getGroup("Ungrouped");
|
||||||
groupNames = wxGetApp().getBookmarkMgr().getGroups();
|
groupNames = wxGetApp().getBookmarkMgr().getGroups();
|
||||||
}
|
}
|
||||||
|
if (doUpdateBookmarkGroup.size()) { // Nothing for the moment..
|
||||||
|
doUpdateBookmarkGroup.erase(doUpdateBookmarkGroup.begin(), doUpdateBookmarkGroup.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTreeItemId bmSelFound = nullptr;
|
||||||
for (auto gn_i : groupNames) {
|
for (auto gn_i : groupNames) {
|
||||||
if (groups.find(gn_i) == groups.end()) {
|
if (groups.find(gn_i) == groups.end()) {
|
||||||
groups[gn_i] = m_treeView->AppendItem(bookmarkBranch, gn_i);
|
groups[gn_i] = m_treeView->AppendItem(bookmarkBranch, gn_i);
|
||||||
@ -77,15 +100,23 @@ void BookmarkView::refreshBookmarks() {
|
|||||||
m_treeView->DeleteChildren(groupItem);
|
m_treeView->DeleteChildren(groupItem);
|
||||||
|
|
||||||
std::vector<wxTreeItemId> &groupEnts = groupEntries[groupItem];
|
std::vector<wxTreeItemId> &groupEnts = groupEntries[groupItem];
|
||||||
|
std::vector<BookmarkEntry *> &groupBMEnts = groupBookmarkEntries[groupItem];
|
||||||
groupEnts.erase(groupEnts.begin(),groupEnts.end());
|
groupEnts.erase(groupEnts.begin(),groupEnts.end());
|
||||||
|
groupBMEnts.erase(groupBMEnts.begin(),groupBMEnts.end());
|
||||||
|
|
||||||
BookmarkGroup bmList = wxGetApp().getBookmarkMgr().getGroup(gn_i);
|
BookmarkGroup bmList = wxGetApp().getBookmarkMgr().getGroup(gn_i);
|
||||||
for (auto bmEnt : bmList) {
|
for (auto bmEnt : bmList) {
|
||||||
wxTreeItemId bmItem = m_treeView->AppendItem(groupItem, bmEnt->label);
|
wxTreeItemId bmItem = m_treeView->AppendItem(groupItem, bmEnt->label);
|
||||||
groupEnts.push_back(bmItem);
|
groupEnts.push_back(bmItem);
|
||||||
|
groupBMEnts.push_back(bmEnt);
|
||||||
|
if (bookmarkSel == bmEnt) {
|
||||||
|
bmSelFound = bmItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// bookmarksInitialized = true;
|
|
||||||
|
return bmSelFound;
|
||||||
|
// bookmarksInitialized = true;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +145,6 @@ void BookmarkView::doUpdateActiveList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bookmarks
|
|
||||||
refreshBookmarks();
|
|
||||||
|
|
||||||
// Recents
|
// Recents
|
||||||
BookmarkList bmRecents = wxGetApp().getBookmarkMgr().getRecents();
|
BookmarkList bmRecents = wxGetApp().getBookmarkMgr().getRecents();
|
||||||
recentItems.erase(recentItems.begin(),recentItems.end());
|
recentItems.erase(recentItems.begin(),recentItems.end());
|
||||||
@ -150,6 +178,9 @@ void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
|
|||||||
if (recentSel) {
|
if (recentSel) {
|
||||||
activateBookmark(recentSel);
|
activateBookmark(recentSel);
|
||||||
}
|
}
|
||||||
|
if (bookmarkSel) {
|
||||||
|
activateBookmark(bookmarkSel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
|
void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
|
||||||
@ -313,14 +344,31 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
|
|||||||
m_propPanel->Show();
|
m_propPanel->Show();
|
||||||
recentSelection(recentSel);
|
recentSelection(recentSel);
|
||||||
} else {
|
} else {
|
||||||
|
bool bFound = false;
|
||||||
|
bookmarkSel = nullptr;
|
||||||
|
|
||||||
|
for (auto ge_i : groupEntries) {
|
||||||
|
wxTreeItemId itm = event.GetItem();
|
||||||
|
for (int i = 0, iMax = ge_i.second.size(); i < iMax; i++) {
|
||||||
|
if (ge_i.second[i] == itm) {
|
||||||
|
bookmarkSel = groupBookmarkEntries[ge_i.first][i];
|
||||||
|
bFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
activeSel = nullptr;
|
activeSel = nullptr;
|
||||||
recentSel = nullptr;
|
recentSel = nullptr;
|
||||||
|
|
||||||
m_propPanel->Hide();
|
if (bFound) {
|
||||||
hideProps();
|
m_propPanel->Show();
|
||||||
|
bookmarkSelection(bookmarkSel);
|
||||||
|
} else {
|
||||||
|
m_propPanel->Hide();
|
||||||
|
hideProps();
|
||||||
|
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
||||||
|
}
|
||||||
this->Layout();
|
this->Layout();
|
||||||
|
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(activeSel, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,13 +395,19 @@ void BookmarkView::onDoubleClickBandwidth( wxMouseEvent& event ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onBookmark( wxCommandEvent& event ) {
|
void BookmarkView::onBookmark( wxCommandEvent& event ) {
|
||||||
event.Skip();
|
if (activeSel) {
|
||||||
|
wxGetApp().getBookmarkMgr().addBookmark("Ungrouped", activeSel);
|
||||||
|
wxGetApp().getBookmarkMgr().updateBookmarks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onActivate( wxCommandEvent& event ) {
|
void BookmarkView::onActivate( wxCommandEvent& event ) {
|
||||||
if (recentSel) {
|
if (recentSel) {
|
||||||
activateBookmark(recentSel);
|
activateBookmark(recentSel);
|
||||||
}
|
}
|
||||||
|
if (bookmarkSel) {
|
||||||
|
activateBookmark(bookmarkSel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::onRemove( wxCommandEvent& event ) {
|
void BookmarkView::onRemove( wxCommandEvent& event ) {
|
||||||
|
@ -9,11 +9,13 @@ public:
|
|||||||
BookmarkView( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1, -1 ), long style = wxTAB_TRAVERSAL );
|
BookmarkView( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1, -1 ), long style = wxTAB_TRAVERSAL );
|
||||||
|
|
||||||
void updateActiveList();
|
void updateActiveList();
|
||||||
|
void updateBookmarks();
|
||||||
|
void updateBookmarks(std::string group);
|
||||||
void activeSelection(DemodulatorInstance *dsel);
|
void activeSelection(DemodulatorInstance *dsel);
|
||||||
void bookmarkSelection(BookmarkEntry *bmSel);
|
void bookmarkSelection(BookmarkEntry *bmSel);
|
||||||
void activateBookmark(BookmarkEntry *bmEnt);
|
void activateBookmark(BookmarkEntry *bmEnt);
|
||||||
void recentSelection(BookmarkEntry *bmSel);
|
void recentSelection(BookmarkEntry *bmSel);
|
||||||
void refreshBookmarks();
|
wxTreeItemId refreshBookmarks();
|
||||||
void updateTheme();
|
void updateTheme();
|
||||||
void onMenuItem(wxCommandEvent& event);
|
void onMenuItem(wxCommandEvent& event);
|
||||||
|
|
||||||
@ -39,17 +41,21 @@ protected:
|
|||||||
void onActivate( wxCommandEvent& event );
|
void onActivate( wxCommandEvent& event );
|
||||||
void onRemove( wxCommandEvent& event );
|
void onRemove( wxCommandEvent& event );
|
||||||
|
|
||||||
std::atomic_bool doUpdateActive;
|
|
||||||
wxTreeItemId rootBranch, activeBranch, bookmarkBranch, recentBranch;
|
wxTreeItemId rootBranch, activeBranch, bookmarkBranch, recentBranch;
|
||||||
|
|
||||||
// Bookmarks
|
// Bookmarks
|
||||||
|
std::atomic_bool doUpdateBookmarks;
|
||||||
|
std::set< std::string > doUpdateBookmarkGroup;
|
||||||
BookmarkNames groupNames;
|
BookmarkNames groupNames;
|
||||||
std::map<std::string, wxTreeItemId> groups;
|
std::map<std::string, wxTreeItemId> groups;
|
||||||
std::map<wxTreeItemId, std::vector<wxTreeItemId> > groupEntries;
|
std::map<wxTreeItemId, std::vector<wxTreeItemId> > groupEntries;
|
||||||
|
std::map<wxTreeItemId, std::vector<BookmarkEntry * > > groupBookmarkEntries;
|
||||||
BookmarkEntry *bookmarkSel;
|
BookmarkEntry *bookmarkSel;
|
||||||
bool bookmarksInitialized;
|
bool bookmarksInitialized;
|
||||||
|
|
||||||
|
|
||||||
// Active
|
// Active
|
||||||
|
std::atomic_bool doUpdateActive;
|
||||||
std::map<wxTreeItemId, DemodulatorInstance *> activeItems;
|
std::map<wxTreeItemId, DemodulatorInstance *> activeItems;
|
||||||
DemodulatorInstance *activeSel;
|
DemodulatorInstance *activeSel;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user