mirror of https://gitlab.com/pamhyr/pamhyr2
debug delete functionnality in InitialConditionsAdisTS
parent
1f97af9c03
commit
4550fc95d7
|
|
@ -267,7 +267,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, name):
|
def name(self, name):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pollutant(self):
|
def pollutant(self):
|
||||||
|
|
@ -276,7 +276,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@pollutant.setter
|
@pollutant.setter
|
||||||
def pollutant(self, pollutant):
|
def pollutant(self, pollutant):
|
||||||
self._pollutant = pollutant
|
self._pollutant = pollutant
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def concentration(self):
|
def concentration(self):
|
||||||
|
|
@ -285,7 +285,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@concentration.setter
|
@concentration.setter
|
||||||
def concentration(self, concentration):
|
def concentration(self, concentration):
|
||||||
self._concentration = concentration
|
self._concentration = concentration
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def eg(self):
|
def eg(self):
|
||||||
|
|
@ -294,7 +294,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@eg.setter
|
@eg.setter
|
||||||
def eg(self, eg):
|
def eg(self, eg):
|
||||||
self._eg = eg
|
self._eg = eg
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def em(self):
|
def em(self):
|
||||||
|
|
@ -303,7 +303,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@em.setter
|
@em.setter
|
||||||
def em(self, em):
|
def em(self, em):
|
||||||
self._em = em
|
self._em = em
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ed(self):
|
def ed(self):
|
||||||
|
|
@ -312,7 +312,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@ed.setter
|
@ed.setter
|
||||||
def ed(self, ed):
|
def ed(self, ed):
|
||||||
self._ed = ed
|
self._ed = ed
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enabled(self):
|
def enabled(self):
|
||||||
|
|
@ -321,28 +321,45 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@enabled.setter
|
@enabled.setter
|
||||||
def enabled(self, enabled):
|
def enabled(self, enabled):
|
||||||
self._enabled = enabled
|
self._enabled = enabled
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def new(self, index):
|
def new(self, index):
|
||||||
n = ICAdisTSSpec(status=self._status)
|
n = ICAdisTSSpec(status=self._status)
|
||||||
self._data.insert(index, n)
|
self._data.insert(index, n)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def delete(self, data):
|
def delete(self, data):
|
||||||
self._data = list(
|
list(
|
||||||
filter(
|
map(
|
||||||
lambda x: x not in data,
|
lambda x: x.set_as_deleted(),
|
||||||
self._data
|
data
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def delete_i(self, indexes):
|
def delete_i(self, indexes):
|
||||||
for ind in indexes:
|
list(
|
||||||
del self._data[ind]
|
map(
|
||||||
self._status.modified()
|
lambda e: e[1].set_as_deleted(),
|
||||||
|
filter(
|
||||||
|
lambda e: e[0] in indexes,
|
||||||
|
enumerate(self._data)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.modified()
|
||||||
|
|
||||||
def insert(self, index, data):
|
def insert(self, index, data):
|
||||||
self._data.insert(index, data)
|
if data in self._data:
|
||||||
self._status.modified()
|
self.undelete([data])
|
||||||
|
else:
|
||||||
|
self._data.insert(index, data)
|
||||||
|
|
||||||
|
self.modified()
|
||||||
|
|
||||||
|
def undelete(self, lst):
|
||||||
|
for x in lst:
|
||||||
|
x.set_as_not_deleted()
|
||||||
|
|
||||||
|
self.modified()
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,12 @@ class InitialConditionTableModel(PamhyrTableModel):
|
||||||
self._data = data
|
self._data = data
|
||||||
|
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = self._data._data
|
self._lst = list(
|
||||||
|
filter(
|
||||||
|
lambda ica: ica._deleted == False,
|
||||||
|
self._data._data
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def rowCount(self, parent):
|
def rowCount(self, parent):
|
||||||
return len(self._lst)
|
return len(self._lst)
|
||||||
|
|
@ -222,12 +227,18 @@ class InitialConditionTableModel(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])
|
||||||
|
|
||||||
|
data_rows = {
|
||||||
|
id(ica): i for i, ica in enumerate(self._data._data)
|
||||||
|
}
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._data, self._lst, rows
|
self._data,
|
||||||
|
self._data._data,
|
||||||
|
[data_rows[id(self._lst[row])] for row in rows]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._setup_lst()
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,6 @@ class DelCommand(QUndoCommand):
|
||||||
self._data = data
|
self._data = data
|
||||||
self._ics_spec = ics_spec
|
self._ics_spec = ics_spec
|
||||||
self._rows = rows
|
self._rows = rows
|
||||||
# self._data = data
|
|
||||||
|
|
||||||
self._ic = []
|
self._ic = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue