Fix lazy-edit-device-switch context mismatch

This commit is contained in:
Charles J. Cliffe 2016-01-19 18:38:18 -05:00
parent 19bf41596b
commit b7d4687b8e
5 changed files with 22 additions and 8 deletions

View File

@ -12,7 +12,8 @@ SDRDevicesDialog::SDRDevicesDialog( wxWindow* parent ): devFrame( parent ) {
m_addRemoteButton->Disable();
m_useSelectedButton->Disable();
m_deviceTimer.Start(250);
selId = 0;
selId = nullptr;
editId = nullptr;
}
void SDRDevicesDialog::OnClose( wxCloseEvent& event ) {
@ -177,7 +178,6 @@ SDRDeviceInfo *SDRDevicesDialog::getSelectedDevice(wxTreeItemId selId) {
void SDRDevicesDialog::OnUseSelected( wxMouseEvent& event ) {
if (dev != NULL) {
int i = 0;
SoapySDR::ArgInfoList::const_iterator args_i;
SoapySDR::ArgInfoList args = dev->getSettingsArgInfo();
@ -318,20 +318,25 @@ void SDRDevicesDialog::OnRefreshDevices( wxMouseEvent& event ) {
m_addRemoteButton->Disable();
m_useSelectedButton->Disable();
wxGetApp().reEnumerateDevices();
selId = 0;
selId = nullptr;
editId = nullptr;
dev = nullptr;
refresh = true;
}
void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
if (dev && event.GetProperty() == devSettings["name"]) {
if (!editId) {
return;
}
SDRDeviceInfo *dev = getSelectedDevice(editId);
if (editId && event.GetProperty() == devSettings["name"]) {
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
wxString devName = event.GetPropertyValue().GetString();
devConfig->setDeviceName(devName.ToStdString());
if (selId) {
devTree->SetItemText(selId, devConfig->getDeviceName());
if (editId) {
devTree->SetItemText(editId, devConfig->getDeviceName());
}
if (devName == "") {
event.GetProperty()->SetValueFromString(devConfig->getDeviceName());
@ -345,3 +350,7 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
devConfig->setOffset(offset);
}
}
void SDRDevicesDialog::OnPropGridFocus( wxFocusEvent& event ) {
editId = selId;
}

View File

@ -1002,12 +1002,12 @@
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnPropertyGridChanged"></event>
<event name="OnPropertyGridChanged">OnPropGridChanged</event>
<event name="OnPropertyGridChanging"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSetFocus">OnPropGridFocus</event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>

View File

@ -20,6 +20,7 @@ public:
void OnDeviceTimer( wxTimerEvent& event );
void OnRefreshDevices( wxMouseEvent& event );
void OnPropGridChanged( wxPropertyGridEvent& event );
void OnPropGridFocus( wxFocusEvent& event );
private:
SDRDeviceInfo *getSelectedDevice(wxTreeItemId selId);
@ -34,4 +35,5 @@ private:
std::vector<wxPGProperty *> props;
std::map<std::string, wxPGProperty *> devSettings;
wxTreeItemId selId;
wxTreeItemId editId;
};

View File

@ -94,6 +94,7 @@ devFrame::devFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons
m_addRemoteButton->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( devFrame::OnAddRemote ), NULL, this );
m_useSelectedButton->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( devFrame::OnUseSelected ), NULL, this );
m_propertyGrid->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( devFrame::OnPropGridChanged ), NULL, this );
m_propertyGrid->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( devFrame::OnPropGridFocus ), NULL, this );
this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( devFrame::OnDeviceTimer ) );
}
@ -108,6 +109,7 @@ devFrame::~devFrame()
m_addRemoteButton->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( devFrame::OnAddRemote ), NULL, this );
m_useSelectedButton->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( devFrame::OnUseSelected ), NULL, this );
m_propertyGrid->Disconnect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( devFrame::OnPropGridChanged ), NULL, this );
m_propertyGrid->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( devFrame::OnPropGridFocus ), NULL, this );
this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( devFrame::OnDeviceTimer ) );
}

View File

@ -62,6 +62,7 @@ class devFrame : public wxFrame
virtual void OnAddRemote( wxMouseEvent& event ) { event.Skip(); }
virtual void OnUseSelected( wxMouseEvent& event ) { event.Skip(); }
virtual void OnPropGridChanged( wxPropertyGridEvent& event ) { event.Skip(); }
virtual void OnPropGridFocus( wxFocusEvent& event ) { event.Skip(); }
virtual void OnDeviceTimer( wxTimerEvent& event ) { event.Skip(); }