User Label editing

This commit is contained in:
Charles J. Cliffe 2016-11-25 23:21:32 -05:00
parent 849a706871
commit 6f822b96cd
4 changed files with 39 additions and 15 deletions

View File

@ -204,10 +204,6 @@ BookmarkEntry *BookmarkMgr::demodToBookmarkEntry(DemodulatorInstance *demod) {
be->bandwidth = demod->getBandwidth(); be->bandwidth = demod->getBandwidth();
be->type = demod->getDemodulatorType(); be->type = demod->getDemodulatorType();
be->label = demod->getDemodulatorUserLabel(); be->label = demod->getDemodulatorUserLabel();
if (be->label == "") {
std::string wstr = demod->getLabel();
be->label = std::wstring(wstr.begin(),wstr.end());
}
be->frequency = demod->getFrequency(); be->frequency = demod->getFrequency();
be->node = new DataNode; be->node = new DataNode;

View File

@ -28,7 +28,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
m_labelLabel->Wrap( -1 ); m_labelLabel->Wrap( -1 );
fgPropSizer->Add( m_labelLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); fgPropSizer->Add( m_labelLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_labelText = new wxTextCtrl( m_propPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_labelText = new wxTextCtrl( m_propPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
fgPropSizer->Add( m_labelText, 0, wxALL|wxEXPAND, 5 ); fgPropSizer->Add( m_labelText, 0, wxALL|wxEXPAND, 5 );
m_frequencyLabel = new wxStaticText( m_propPanel, wxID_ANY, wxT("Freq"), wxDefaultPosition, wxDefaultSize, 0 ); m_frequencyLabel = new wxStaticText( m_propPanel, wxID_ANY, wxT("Freq"), wxDefaultPosition, wxDefaultSize, 0 );
@ -91,7 +91,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
m_treeView->Connect( wxEVT_COMMAND_TREE_ITEM_MENU, wxTreeEventHandler( BookmarkPanel::onTreeItemMenu ), NULL, this ); m_treeView->Connect( wxEVT_COMMAND_TREE_ITEM_MENU, wxTreeEventHandler( BookmarkPanel::onTreeItemMenu ), NULL, this );
m_treeView->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( BookmarkPanel::onTreeSelect ), NULL, this ); m_treeView->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( BookmarkPanel::onTreeSelect ), NULL, this );
m_treeView->Connect( wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEventHandler( BookmarkPanel::onTreeSelectChanging ), NULL, this ); m_treeView->Connect( wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEventHandler( BookmarkPanel::onTreeSelectChanging ), NULL, this );
m_labelText->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BookmarkPanel::onLabelText ), NULL, this ); m_labelText->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( BookmarkPanel::onLabelText ), NULL, this );
m_frequencyVal->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickFreq ), NULL, this ); m_frequencyVal->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickFreq ), NULL, this );
m_bandwidthVal->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickBandwidth ), NULL, this ); m_bandwidthVal->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickBandwidth ), NULL, this );
this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( BookmarkPanel::onUpdateTimer ) ); this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( BookmarkPanel::onUpdateTimer ) );
@ -114,7 +114,7 @@ BookmarkPanel::~BookmarkPanel()
m_treeView->Disconnect( wxEVT_COMMAND_TREE_ITEM_MENU, wxTreeEventHandler( BookmarkPanel::onTreeItemMenu ), NULL, this ); m_treeView->Disconnect( wxEVT_COMMAND_TREE_ITEM_MENU, wxTreeEventHandler( BookmarkPanel::onTreeItemMenu ), NULL, this );
m_treeView->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( BookmarkPanel::onTreeSelect ), NULL, this ); m_treeView->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( BookmarkPanel::onTreeSelect ), NULL, this );
m_treeView->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEventHandler( BookmarkPanel::onTreeSelectChanging ), NULL, this ); m_treeView->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEventHandler( BookmarkPanel::onTreeSelectChanging ), NULL, this );
m_labelText->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BookmarkPanel::onLabelText ), NULL, this ); m_labelText->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( BookmarkPanel::onLabelText ), NULL, this );
m_frequencyVal->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickFreq ), NULL, this ); m_frequencyVal->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickFreq ), NULL, this );
m_bandwidthVal->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickBandwidth ), NULL, this ); m_bandwidthVal->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickBandwidth ), NULL, this );
this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( BookmarkPanel::onUpdateTimer ) ); this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( BookmarkPanel::onUpdateTimer ) );

View File

@ -189,7 +189,7 @@
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxBOTTOM|wxEXPAND|wxTOP</property> <property name="flag">wxALL|wxBOTTOM|wxEXPAND|wxTOP</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxPanel" expanded="0"> <object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
@ -263,7 +263,7 @@
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="wxFlexGridSizer" expanded="0"> <object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property> <property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property> <property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property> <property name="growablecols">1</property>
@ -408,7 +408,7 @@
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style"></property> <property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
@ -442,8 +442,8 @@
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnText">onLabelText</event> <event name="OnText"></event>
<event name="OnTextEnter"></event> <event name="OnTextEnter">onLabelText</event>
<event name="OnTextMaxLen"></event> <event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event> <event name="OnTextURL"></event>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>

View File

@ -150,6 +150,13 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK; tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK;
tvi->bookmarkEnt = bmEnt; tvi->bookmarkEnt = bmEnt;
tvi->groupName = gn_i; tvi->groupName = gn_i;
std::wstring labelVal;
if (bmEnt->label == "") {
std::string wstr = frequencyToStr(tvi->bookmarkEnt->frequency) + " " + tvi->bookmarkEnt->type;
bmEnt->label = std::wstring(wstr.begin(),wstr.end());
}
wxTreeItemId itm = m_treeView->AppendItem(groupItem, bmEnt->label); wxTreeItemId itm = m_treeView->AppendItem(groupItem, bmEnt->label);
m_treeView->SetItemData(itm, tvi); m_treeView->SetItemData(itm, tvi);
if (bookmarkSel == bmEnt && groupExpanded) { if (bookmarkSel == bmEnt && groupExpanded) {
@ -186,7 +193,8 @@ void BookmarkView::doUpdateActiveList() {
wxString activeLabel = demod_i->getDemodulatorUserLabel(); wxString activeLabel = demod_i->getDemodulatorUserLabel();
if (activeLabel == "") { if (activeLabel == "") {
activeLabel = demod_i->getLabel(); std::string wstr = frequencyToStr(demod_i->getFrequency()) + " " + demod_i->getDemodulatorType();
activeLabel = std::wstring(wstr.begin(),wstr.end());
} }
wxTreeItemId itm = m_treeView->AppendItem(activeBranch,activeLabel); wxTreeItemId itm = m_treeView->AppendItem(activeBranch,activeLabel);
@ -214,7 +222,14 @@ void BookmarkView::doUpdateActiveList() {
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT; tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT;
tvi->bookmarkEnt = bmr_i; tvi->bookmarkEnt = bmr_i;
wxTreeItemId itm = m_treeView->AppendItem(recentBranch, bmr_i->label); std::wstring labelVal;
bmr_i->node->child("user_label")->element()->get(labelVal);
if (labelVal == "") {
std::string wstr = frequencyToStr(bmr_i->frequency) + " " + bmr_i->type;
labelVal = std::wstring(wstr.begin(),wstr.end());
}
wxTreeItemId itm = m_treeView->AppendItem(recentBranch, labelVal);
m_treeView->SetItemData(itm, tvi); m_treeView->SetItemData(itm, tvi);
if (recentSel == bmr_i && recentExpandState) { if (recentSel == bmr_i && recentExpandState) {
selItem = itm; selItem = itm;
@ -658,7 +673,20 @@ void BookmarkView::onTreeSelectChanging( wxTreeEvent& event ) {
void BookmarkView::onLabelText( wxCommandEvent& event ) { void BookmarkView::onLabelText( wxCommandEvent& event ) {
event.Skip(); std::wstring newLabel = m_labelText->GetValue().ToStdWstring();
if (activeSel) {
activeSel->setDemodulatorUserLabel(newLabel);
wxGetApp().getBookmarkMgr().updateActiveList();
} else if (bookmarkSel) {
bookmarkSel->label = m_labelText->GetValue().ToStdWstring();
bookmarkSel->node->child("user_label")->element()->set(newLabel);
wxGetApp().getBookmarkMgr().updateBookmarks();
} else if (recentSel) {
recentSel->label = m_labelText->GetValue().ToStdWstring();
recentSel->node->child("user_label")->element()->set(newLabel);
wxGetApp().getBookmarkMgr().updateActiveList();
}
} }