Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bankedit.py: remove redundant memory_changed function #1204

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions chirp/wxui/bankedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __init__(self, radio, *a, **k):
self._memory_cache = {}

self._grid.Bind(wx.grid.EVT_GRID_CELL_CHANGING, self._cell_changing)
self._grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self._memory_changed)
self._grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self._cell_changing)
self._grid.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK, self._label_click)
self._grid.GetGridColLabelWindow().Bind(wx.EVT_MOTION,
self._colheader_mouseover)
Expand Down Expand Up @@ -221,14 +221,16 @@ def _cell_changing(self, event):
col = event.GetCol()
value = event.GetString()
# if index value changed, update memory index
if isinstance(self._col_defs[col], ChirpBankIndexColumn):
if isinstance(self._col_defs[col], ChirpBankIndexColumn) and value:
self._change_memory_index(self.row2mem(row), int(value))
# if activating a checkbox with spacebar, treat it like a click
elif isinstance(self._col_defs[col], ChirpBankToggleColumn):
gridCellValue = self._grid.GetCellValue(row, col)
self._change_memory_mapping(self.row2mem(row),
self.col2bank(col),
gridCellValue != BANK_SET_VALUE)
else:
event.Skip()

def _change_memory_index(self, number, index):
for i, bank_index in enumerate(self._bank_index_order):
Expand All @@ -245,21 +247,6 @@ def _change_memory_index(self, number, index):

wx.PostEvent(self, common.EditorChanged(self.GetId()))

@common.error_proof()
def _memory_changed(self, event):
row = event.GetRow()
col = event.GetCol()
value = self._grid.GetCellValue(row, col)

if isinstance(self._col_defs[col], ChirpBankIndexColumn):
event.Skip()
elif col < self._meta_cols:
event.Skip()
else:
self._change_memory_mapping(self.row2mem(row),
self.col2bank(col),
value != BANK_SET_VALUE)

def _change_memory_mapping(self, number, bank, present):
mem = self._memory_cache[number]
bank = self._bank_indexes[self._bank_index_order[bank]]
Expand Down