mirror of https://gitlab.com/pamhyr/pamhyr2
debug index matching in delete function for LCAdisTS
parent
f1dca727c6
commit
e615a6b9d4
|
|
@ -121,7 +121,7 @@ class TableModel(PamhyrTableModel):
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
if self._lcs_list is not None:
|
if self._lcs_list is not None:
|
||||||
self._lcs_pol_list = [
|
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
|
if lcs.pollutant == self._pollutant
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -209,9 +209,14 @@ class TableModel(PamhyrTableModel):
|
||||||
def delete(self, rows, parent=QModelIndex()):
|
def delete(self, rows, parent=QModelIndex()):
|
||||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||||
|
|
||||||
global_rows = list(
|
row_by_lc = {
|
||||||
map(self._global_row, rows)
|
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(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._lcs_list, global_rows
|
self._lcs_list, global_rows
|
||||||
|
|
@ -241,4 +246,7 @@ class TableModel(PamhyrTableModel):
|
||||||
bc = self.get(row)
|
bc = self.get(row)
|
||||||
if bc is None:
|
if bc is None:
|
||||||
return 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
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ class DelCommand(QUndoCommand):
|
||||||
|
|
||||||
self._lc = []
|
self._lc = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self._lc.append((row, self._lcs.get(row)))
|
self._lc.append((row, self._lcs._lst[row]))
|
||||||
self._lc.sort()
|
self._lc.sort()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue