diff --git a/plugins/dm.stimresponse/ClassEditor.cpp b/plugins/dm.stimresponse/ClassEditor.cpp index 6a4f2f1869..413dab853d 100644 --- a/plugins/dm.stimresponse/ClassEditor.cpp +++ b/plugins/dm.stimresponse/ClassEditor.cpp @@ -354,12 +354,8 @@ std::string ClassEditor::getStimTypeIdFromSelector(wxComboBox* comboBox) void ClassEditor::onContextMenu(wxDataViewEvent& ev) { - wxutil::TreeView* view = dynamic_cast(ev.GetEventObject()); - - assert(view != NULL); - // Call the subclass implementation - openContextMenu(view); + openSRListContextMenu(); } void ClassEditor::onStimTypeSelect(wxCommandEvent& ev) diff --git a/plugins/dm.stimresponse/ClassEditor.h b/plugins/dm.stimresponse/ClassEditor.h index 70bca9f195..bd4112265a 100644 --- a/plugins/dm.stimresponse/ClassEditor.h +++ b/plugins/dm.stimresponse/ClassEditor.h @@ -147,11 +147,10 @@ class ClassEditor : */ virtual void selectionChanged() = 0; - /** greebo: Opens the context menu. The treeview widget this event - * has been happening on gets passed so that the correct - * menu can be displayed (in the case of multiple possible treeviews). + /** + * greebo: Opens the context menu. Needs to be implemented by subclasses. */ - virtual void openContextMenu(wxutil::TreeView* view) = 0; + virtual void openSRListContextMenu() = 0; // Callback for Stim/Response selection changes void onSRSelectionChange(wxDataViewEvent& ev); diff --git a/plugins/dm.stimresponse/ResponseEditor.cpp b/plugins/dm.stimresponse/ResponseEditor.cpp index 37627e944a..c6d24f8082 100644 --- a/plugins/dm.stimresponse/ResponseEditor.cpp +++ b/plugins/dm.stimresponse/ResponseEditor.cpp @@ -37,7 +37,7 @@ void ResponseEditor::setEntity(const SREntityPtr& entity) // Pass the call to the base class ClassEditor::setEntity(entity); - if (entity != NULL) + if (entity) { wxutil::TreeModel::Ptr responseStore = _entity->getResponseStore(); _list->AssociateModel(responseStore.get()); @@ -216,13 +216,13 @@ void ResponseEditor::createEffectWidgets() // Connect the signals _effectWidgets.view->Connect(wxEVT_DATAVIEW_SELECTION_CHANGED, - wxDataViewEventHandler(ResponseEditor::onEffectSelectionChange), NULL, this); + wxDataViewEventHandler(ResponseEditor::onEffectSelectionChange), nullptr, this); _effectWidgets.view->Connect(wxEVT_DATAVIEW_ITEM_ACTIVATED, - wxDataViewEventHandler(ResponseEditor::onEffectItemActivated), NULL, this); + wxDataViewEventHandler(ResponseEditor::onEffectItemActivated), nullptr, this); _effectWidgets.view->Connect(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, - wxDataViewEventHandler(ResponseEditor::onContextMenu), NULL, this); + wxDataViewEventHandler(ResponseEditor::onEffectItemContextMenu), nullptr, this); // View Columns _effectWidgets.view->AppendTextColumn("#", StimResponse::getColumns().index.getColumnIndex(), @@ -461,18 +461,9 @@ int ResponseEditor::getEffectIdFromSelection() } } -void ResponseEditor::openContextMenu(wxutil::TreeView* view) +void ResponseEditor::openSRListContextMenu() { - // Check the treeview this remove call is targeting - if (view == _list) - { - _list->PopupMenu(_contextMenu.menu.get()); - } - else if (view == _effectWidgets.view) - { - updateEffectContextMenu(); - _effectWidgets.view->PopupMenu(_effectWidgets.contextMenu.get()); - } + _list->PopupMenu(_contextMenu.menu.get()); } void ResponseEditor::selectionChanged() @@ -504,6 +495,13 @@ void ResponseEditor::addSR() selectId(id); } +void ResponseEditor::onEffectItemContextMenu(wxDataViewEvent& ev) +{ + updateEffectContextMenu(); + + _effectWidgets.view->PopupMenu(_effectWidgets.contextMenu.get()); +} + // Button click events on TreeViews void ResponseEditor::onEffectItemActivated(wxDataViewEvent& ev) { diff --git a/plugins/dm.stimresponse/ResponseEditor.h b/plugins/dm.stimresponse/ResponseEditor.h index c9a87e3ecf..a0b8df4b8a 100644 --- a/plugins/dm.stimresponse/ResponseEditor.h +++ b/plugins/dm.stimresponse/ResponseEditor.h @@ -108,7 +108,7 @@ class ResponseEditor : */ virtual void selectionChanged(); - void openContextMenu(wxutil::TreeView* view); + void openSRListContextMenu() override; /** greebo: Creates all the widgets */ @@ -117,9 +117,6 @@ class ResponseEditor : // Context menu callbacks void onContextMenuAdd(wxCommandEvent& ev); void onContextMenuDelete(wxCommandEvent& ev); - void onContextMenuEffectUp(wxCommandEvent& ev); - void onContextMenuEffectDown(wxCommandEvent& ev); - void onContextMenuEdit(wxCommandEvent& ev); void onEffectMenuDelete(wxCommandEvent& ev); void onEffectMenuEdit(wxCommandEvent& ev); @@ -130,6 +127,9 @@ class ResponseEditor : // To catch double-clicks in the response effect list void onEffectItemActivated(wxDataViewEvent& ev); + // Context menu handler for effects view + void onEffectItemContextMenu(wxDataViewEvent& ev); + // Callback for Stim/Response and effect selection changes void onEffectSelectionChange(wxDataViewEvent& ev); }; diff --git a/plugins/dm.stimresponse/StimEditor.cpp b/plugins/dm.stimresponse/StimEditor.cpp index 04987e0f72..6bbd1efd9c 100644 --- a/plugins/dm.stimresponse/StimEditor.cpp +++ b/plugins/dm.stimresponse/StimEditor.cpp @@ -358,9 +358,9 @@ void StimEditor::checkBoxToggled(wxCheckBox* toggleButton) } } -void StimEditor::openContextMenu(wxutil::TreeView* view) +void StimEditor::openSRListContextMenu() { - view->PopupMenu(_contextMenu.menu.get()); + _list->PopupMenu(_contextMenu.menu.get()); } void StimEditor::addSR() diff --git a/plugins/dm.stimresponse/StimEditor.h b/plugins/dm.stimresponse/StimEditor.h index 404cceadea..71a6566c52 100644 --- a/plugins/dm.stimresponse/StimEditor.h +++ b/plugins/dm.stimresponse/StimEditor.h @@ -125,7 +125,7 @@ class StimEditor : */ virtual void selectionChanged(); - void openContextMenu(wxutil::TreeView* view); + void openSRListContextMenu() override; /** greebo: Creates all the widgets */