CubicSDR/src/BookmarkMgr.cpp

68 lines
1.6 KiB
C++
Raw Normal View History

2016-09-14 19:46:57 -04:00
#include "BookmarkMgr.h"
#include "CubicSDR.h"
#include "DataTree.h"
2016-09-14 19:46:57 -04:00
void BookmarkMgr::saveToFile(std::string bookmarkFn) {
}
void BookmarkMgr::loadFromFile(std::string bookmarkFn) {
}
void BookmarkMgr::addBookmark(std::string group, DemodulatorInstance *demod, std::string folder) {
2016-09-14 19:46:57 -04:00
std::lock_guard < std::mutex > lock(busy_lock);
BookmarkEntry *be = new BookmarkEntry;
be->bandwidth = demod->getBandwidth();
be->type = demod->getDemodulatorType();
be->label = demod->getLabel();
be->frequency = demod->getFrequency();
be->folder = folder;
wxGetApp().getDemodMgr().saveInstance(be->node, demod);
bmData[group].insert(be);
}
2016-09-14 19:46:57 -04:00
void BookmarkMgr::removeBookmark(std::string group, BookmarkEntry *be) {
std::lock_guard < std::mutex > lockData(busy_lock);
std::lock_guard < std::mutex > lockEnt(be->busy_lock);
bmData[group].erase(be);
2016-09-14 19:46:57 -04:00
}
2016-09-14 19:46:57 -04:00
BookmarkList BookmarkMgr::getBookmarks(std::string group, std::string folder) {
std::lock_guard < std::mutex > lock(busy_lock);
BookmarkList results;
if (folder != "") {
for (auto be_i : bmData[group]) {
results.push_back(be_i);
}
} else {
for (auto be_i : bmData[group]) {
if (be_i->folder != folder) {
continue;
}
results.push_back(be_i);
}
}
2016-09-14 19:46:57 -04:00
return results;
}
void BookmarkMgr::updateActiveList() {
BookmarkView *bmv = wxGetApp().getAppFrame()->getBookmarkView();
if (bmv) {
bmv->updateActiveList();
}
}