debug index matching in delete function for LCAdisTS

disable_edition_parent_scenario
Dylan Jeannin 2026-05-04 13:03:18 +02:00
parent f1dca727c6
commit e615a6b9d4
2 changed files with 14 additions and 6 deletions

View File

@ -121,7 +121,7 @@ class TableModel(PamhyrTableModel):
def _setup_lst(self):
if self._lcs_list is not None:
self._lcs_pol_list = [
lcs for lcs in self._lcs_list.lst
lcs for lcs in self._lcs_list._lst
if lcs.pollutant == self._pollutant
]
@ -209,9 +209,14 @@ class TableModel(PamhyrTableModel):
def delete(self, rows, parent=QModelIndex()):
self.beginRemoveRows(parent, rows[0], rows[-1])
global_rows = list(
map(self._global_row, rows)
)
row_by_lc = {
id(lc): row for row, lc in enumerate(self._lcs_list._lst)
}
global_rows = [
row_by_lc[id(self._lst[row])]
for row in rows
if 0 <= row < len(self._lst)
]
self._undo.push(
DelCommand(
self._lcs_list, global_rows
@ -241,4 +246,7 @@ class TableModel(PamhyrTableModel):
bc = self.get(row)
if bc is None:
return None
return self._lcs_list.index(bc)
return next(
index for index, lcs in enumerate(self._lcs_list._lst)
if lcs is bc
)

View File

@ -109,7 +109,7 @@ class DelCommand(QUndoCommand):
self._lc = []
for row in rows:
self._lc.append((row, self._lcs.get(row)))
self._lc.append((row, self._lcs._lst[row]))
self._lc.sort()
def undo(self):