mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-27 06:08:37 -05:00
When saving bookmarks, use active information when available
+ Fixed std::string <=> std::wstring conversions using wxString + cleanups.
This commit is contained in:
parent
8f45451df2
commit
f1208c7f5c
@ -4,6 +4,7 @@
|
|||||||
#include "BookmarkMgr.h"
|
#include "BookmarkMgr.h"
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
#include "DataTree.h"
|
#include "DataTree.h"
|
||||||
|
#include <wx/string.h>
|
||||||
|
|
||||||
#define BOOKMARK_RECENTS_MAX 25
|
#define BOOKMARK_RECENTS_MAX 25
|
||||||
|
|
||||||
@ -49,9 +50,23 @@ void BookmarkMgr::saveToFile(std::string bookmarkFn, bool backup, bool useFullpa
|
|||||||
*group->newChild("@expanded") = (getExpandState(bmd_i.first)?std::string("true"):std::string("false"));
|
*group->newChild("@expanded") = (getExpandState(bmd_i.first)?std::string("true"):std::string("false"));
|
||||||
|
|
||||||
for (auto &bm_i : bmd_i.second ) {
|
for (auto &bm_i : bmd_i.second ) {
|
||||||
|
|
||||||
|
//if a matching demodulator exists, use its data instead to be be saved, because output_device could have been
|
||||||
|
//modified by the user. So, save that "live" version instead.
|
||||||
|
auto matchingDemod = wxGetApp().getDemodMgr().getLastDemodulatorWith(bm_i->type,
|
||||||
|
bm_i->label,
|
||||||
|
bm_i->frequency,
|
||||||
|
bm_i->bandwidth);
|
||||||
|
|
||||||
|
if (matchingDemod != nullptr) {
|
||||||
|
|
||||||
|
wxGetApp().getDemodMgr().saveInstance(group->newChild("modem"), matchingDemod);
|
||||||
|
}
|
||||||
|
else {
|
||||||
group->newChildCloneFrom("modem", bm_i->node);
|
group->newChildCloneFrom("modem", bm_i->node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DataNode *recent_modems = s.rootNode()->newChild("recent_modems");
|
DataNode *recent_modems = s.rootNode()->newChild("recent_modems");
|
||||||
|
|
||||||
@ -557,9 +572,10 @@ BookmarkEntryPtr BookmarkMgr::nodeToBookmark(DataNode *node) {
|
|||||||
std::wstring BookmarkMgr::getBookmarkEntryDisplayName(BookmarkEntryPtr bmEnt) {
|
std::wstring BookmarkMgr::getBookmarkEntryDisplayName(BookmarkEntryPtr bmEnt) {
|
||||||
std::wstring dispName = bmEnt->label;
|
std::wstring dispName = bmEnt->label;
|
||||||
|
|
||||||
if (dispName == "") {
|
if (dispName == L"") {
|
||||||
std::string freqStr = frequencyToStr(bmEnt->frequency) + " " + bmEnt->type;
|
std::string freqStr = frequencyToStr(bmEnt->frequency) + " " + bmEnt->type;
|
||||||
dispName = wstring(freqStr.begin(),freqStr.end());
|
|
||||||
|
dispName = wxString(freqStr).ToStdWstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
return dispName;
|
return dispName;
|
||||||
@ -568,9 +584,10 @@ std::wstring BookmarkMgr::getBookmarkEntryDisplayName(BookmarkEntryPtr bmEnt) {
|
|||||||
std::wstring BookmarkMgr::getActiveDisplayName(DemodulatorInstancePtr demod) {
|
std::wstring BookmarkMgr::getActiveDisplayName(DemodulatorInstancePtr demod) {
|
||||||
std::wstring activeName = demod->getDemodulatorUserLabel();
|
std::wstring activeName = demod->getDemodulatorUserLabel();
|
||||||
|
|
||||||
if (activeName == "") {
|
if (activeName == L"") {
|
||||||
std::string wstr = frequencyToStr(demod->getFrequency()) + " " + demod->getDemodulatorType();
|
std::string wstr = frequencyToStr(demod->getFrequency()) + " " + demod->getDemodulatorType();
|
||||||
activeName = std::wstring(wstr.begin(),wstr.end());
|
|
||||||
|
activeName = wxString(wstr).ToStdWstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
return activeName;
|
return activeName;
|
||||||
|
@ -78,7 +78,8 @@ public:
|
|||||||
|
|
||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
std::string wstr = frequencyToStr(rangeEnt->startFreq) + " - " + frequencyToStr(rangeEnt->endFreq);
|
std::string wstr = frequencyToStr(rangeEnt->startFreq) + " - " + frequencyToStr(rangeEnt->endFreq);
|
||||||
name = std::wstring(wstr.begin(),wstr.end());
|
|
||||||
|
name = wxString(wstr).ToStdWstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_questionText->SetLabelText(L"Are you sure you want to remove the range\n '" + name + L"'?");
|
m_questionText->SetLabelText(L"Are you sure you want to remove the range\n '" + name + L"'?");
|
||||||
@ -103,7 +104,8 @@ public:
|
|||||||
|
|
||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
std::string wstr = frequencyToStr(rangeEnt->startFreq) + " - " + frequencyToStr(rangeEnt->endFreq);
|
std::string wstr = frequencyToStr(rangeEnt->startFreq) + " - " + frequencyToStr(rangeEnt->endFreq);
|
||||||
name = std::wstring(wstr.begin(),wstr.end());
|
|
||||||
|
name = wxString(wstr).ToStdWstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_questionText->SetLabelText(L"Are you sure you want to update the range\n '" + name + L"' to the active range?");
|
m_questionText->SetLabelText(L"Are you sure you want to update the range\n '" + name + L"' to the active range?");
|
||||||
@ -311,9 +313,9 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
|
|||||||
std::wstring fullText = labelVal +
|
std::wstring fullText = labelVal +
|
||||||
L" " + bmEnt->label +
|
L" " + bmEnt->label +
|
||||||
L" " + std::to_wstring(bmEnt->frequency) +
|
L" " + std::to_wstring(bmEnt->frequency) +
|
||||||
L" " + std::wstring(freqStr.begin(),freqStr.end()) +
|
L" " + wxString(freqStr).ToStdWstring() +
|
||||||
L" " + std::wstring(bwStr.begin(),bwStr.end()) +
|
L" " + wxString(bwStr).ToStdWstring() +
|
||||||
L" " + std::wstring(bmEnt->type.begin(),bmEnt->type.end());
|
L" " + wxString(bmEnt->type).ToStdWstring();
|
||||||
|
|
||||||
if (!isKeywordMatch(fullText, searchKeywords)) {
|
if (!isKeywordMatch(fullText, searchKeywords)) {
|
||||||
continue;
|
continue;
|
||||||
@ -379,9 +381,9 @@ void BookmarkView::doUpdateActiveList() {
|
|||||||
std::wstring fullText = activeLabel.ToStdWstring() +
|
std::wstring fullText = activeLabel.ToStdWstring() +
|
||||||
L" " + demod_i->getDemodulatorUserLabel() +
|
L" " + demod_i->getDemodulatorUserLabel() +
|
||||||
L" " + std::to_wstring(demod_i->getFrequency()) +
|
L" " + std::to_wstring(demod_i->getFrequency()) +
|
||||||
L" " + std::wstring(freqStr.begin(),freqStr.end()) +
|
L" " + wxString(freqStr).ToStdWstring() +
|
||||||
L" " + std::wstring(bwStr.begin(),bwStr.end()) +
|
L" " + wxString(bwStr).ToStdWstring() +
|
||||||
L" " + std::wstring(mtype.begin(),mtype.end());
|
L" " + wxString(mtype).ToStdWstring();
|
||||||
|
|
||||||
if (!isKeywordMatch(fullText, searchKeywords)) {
|
if (!isKeywordMatch(fullText, searchKeywords)) {
|
||||||
continue;
|
continue;
|
||||||
@ -418,9 +420,10 @@ void BookmarkView::doUpdateActiveList() {
|
|||||||
|
|
||||||
std::wstring labelVal = re_i->label;
|
std::wstring labelVal = re_i->label;
|
||||||
|
|
||||||
if (labelVal == "") {
|
if (labelVal == L"") {
|
||||||
std::string wstr = frequencyToStr(re_i->startFreq) + " - " + frequencyToStr(re_i->endFreq);
|
std::string wstr = frequencyToStr(re_i->startFreq) + " - " + frequencyToStr(re_i->endFreq);
|
||||||
labelVal = std::wstring(wstr.begin(),wstr.end());
|
|
||||||
|
labelVal = wxString(wstr).ToStdWstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTreeItemId itm = m_treeView->AppendItem(rangeBranch, labelVal);
|
wxTreeItemId itm = m_treeView->AppendItem(rangeBranch, labelVal);
|
||||||
@ -448,9 +451,10 @@ void BookmarkView::doUpdateActiveList() {
|
|||||||
std::wstring labelVal;
|
std::wstring labelVal;
|
||||||
bmr_i->node->child("user_label")->element()->get(labelVal);
|
bmr_i->node->child("user_label")->element()->get(labelVal);
|
||||||
|
|
||||||
if (labelVal == "") {
|
if (labelVal == L"") {
|
||||||
std::string wstr = frequencyToStr(bmr_i->frequency) + " " + bmr_i->type;
|
std::string str = frequencyToStr(bmr_i->frequency) + " " + bmr_i->type;
|
||||||
labelVal = std::wstring(wstr.begin(),wstr.end());
|
|
||||||
|
labelVal = wxString(str).ToStdWstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchKeywords.size()) {
|
if (searchKeywords.size()) {
|
||||||
@ -460,9 +464,10 @@ void BookmarkView::doUpdateActiveList() {
|
|||||||
|
|
||||||
std::wstring fullText = labelVal +
|
std::wstring fullText = labelVal +
|
||||||
L" " + std::to_wstring(bmr_i->frequency) +
|
L" " + std::to_wstring(bmr_i->frequency) +
|
||||||
L" " + std::wstring(freqStr.begin(),freqStr.end()) +
|
|
||||||
L" " + std::wstring(bwStr.begin(),bwStr.end()) +
|
L" " + wxString(freqStr).ToStdWstring() +
|
||||||
L" " + std::wstring(bmr_i->type.begin(),tvi->bookmarkEnt->type.end());
|
L" " + wxString(bwStr).ToStdWstring() +
|
||||||
|
L" " + wxString(bmr_i->type).ToStdWstring();
|
||||||
|
|
||||||
if (!isKeywordMatch(fullText, searchKeywords)) {
|
if (!isKeywordMatch(fullText, searchKeywords)) {
|
||||||
continue;
|
continue;
|
||||||
@ -971,7 +976,7 @@ void BookmarkView::rangeSelection(BookmarkRangeEntryPtr re) {
|
|||||||
|
|
||||||
std::string strFreq = frequencyToStr(re->startFreq) + "-" + frequencyToStr(re->endFreq);
|
std::string strFreq = frequencyToStr(re->startFreq) + "-" + frequencyToStr(re->endFreq);
|
||||||
|
|
||||||
m_frequencyVal->SetLabelText(std::wstring(strFreq.begin(),strFreq.end()));
|
m_frequencyVal->SetLabelText(wxString(strFreq));
|
||||||
|
|
||||||
showProps();
|
showProps();
|
||||||
|
|
||||||
@ -1473,16 +1478,16 @@ void BookmarkView::onSearchTextFocus( wxMouseEvent& event ) {
|
|||||||
|
|
||||||
|
|
||||||
void BookmarkView::onSearchText( wxCommandEvent& event ) {
|
void BookmarkView::onSearchText( wxCommandEvent& event ) {
|
||||||
wstring searchText = m_searchText->GetValue().Trim().Lower().ToStdWstring();
|
std::wstring searchText = m_searchText->GetValue().Trim().Lower().ToStdWstring();
|
||||||
|
|
||||||
searchKeywords.clear();
|
searchKeywords.clear();
|
||||||
|
|
||||||
if (searchText.length() != 0) {
|
if (searchText.length() != 0) {
|
||||||
std::wstringstream searchTextLo(searchText);
|
std::wstringstream searchTextLo(searchText);
|
||||||
wstring tmp;
|
std::wstring tmp;
|
||||||
|
|
||||||
while(std::getline(searchTextLo, tmp, L' ')) {
|
while(std::getline(searchTextLo, tmp, L' ')) {
|
||||||
if (tmp.length() != 0 && tmp.find(L"search.") == wstring::npos) {
|
if (tmp.length() != 0 && tmp.find(L"search.") == std::wstring::npos) {
|
||||||
searchKeywords.push_back(tmp);
|
searchKeywords.push_back(tmp);
|
||||||
// std::wcout << L"Keyword: " << tmp << '\n';
|
// std::wcout << L"Keyword: " << tmp << '\n';
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "GLFont.h"
|
#include "GLFont.h"
|
||||||
|
|
||||||
|
#include <wx/string.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -245,11 +247,11 @@ void GLFont::loadFontOnce() {
|
|||||||
//Re-compute the resource dir.
|
//Re-compute the resource dir.
|
||||||
resourceFolder = fontDefFileName.GetPath();
|
resourceFolder = fontDefFileName.GetPath();
|
||||||
|
|
||||||
std::wstring fontDefFileNamePath = fontDefFileName.GetFullPath(wxPATH_NATIVE).ToStdWstring();
|
std::string fontDefFileNamePath = fontDefFileName.GetFullPath(wxPATH_NATIVE).ToStdString();
|
||||||
|
|
||||||
std::wifstream input;
|
std::wifstream input;
|
||||||
std::string inpFileStr(fontDefFileNamePath.begin(), fontDefFileNamePath.end());
|
|
||||||
input.open(inpFileStr, std::ios::in);
|
input.open(fontDefFileNamePath, std::ios::in);
|
||||||
|
|
||||||
std::wstring op;
|
std::wstring op;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user