Commit 716d0af9 authored by Youcef Aouad's avatar Youcef Aouad
Browse files

INI GOOD

No related merge requests found
Pipeline #55962 passed with stages
in 59 seconds
Showing with 50 additions and 33 deletions
+50 -33
...@@ -96,8 +96,6 @@ class InitialConditionsAdisTS(SQLSubModel): ...@@ -96,8 +96,6 @@ class InitialConditionsAdisTS(SQLSubModel):
"FROM initial_conditions_adists" "FROM initial_conditions_adists"
) )
print("db load ic adists : ", table)
if table is not None: if table is not None:
for row in table: for row in table:
IC_id = row[0] IC_id = row[0]
...@@ -259,16 +257,13 @@ class InitialConditionsAdisTS(SQLSubModel): ...@@ -259,16 +257,13 @@ class InitialConditionsAdisTS(SQLSubModel):
self._status.modified() self._status.modified()
def delete_i(self, indexes): def delete_i(self, indexes):
data = list( for ind in indexes:
map( del self._data[ind]
lambda x: x[1], self._status.modified()
filter(
lambda x: x[0] in indexes, def insert(self, index, data):
enumerate(self._data) self._data.insert(index, data)
) self._status.modified()
)
)
self.delete(data)
......
...@@ -98,6 +98,7 @@ class ICAdisTSSpec(SQLSubModel): ...@@ -98,6 +98,7 @@ class ICAdisTSSpec(SQLSubModel):
) )
for row in table: for row in table:
id = row[0]
name = row[2] name = row[2]
reach = row[3] reach = row[3]
start_kp = row[4] start_kp = row[4]
...@@ -109,7 +110,24 @@ class ICAdisTSSpec(SQLSubModel): ...@@ -109,7 +110,24 @@ class ICAdisTSSpec(SQLSubModel):
rate = row[10] rate = row[10]
enabled = (row[11] == 1) enabled = (row[11] == 1)
new_spec = [name, reach, start_kp, end_kp, concentration, eg, em, ed, rate, enabled] #new_spec = [name, reach, start_kp, end_kp, concentration, eg, em, ed, rate, enabled]
new_spec = cls(
id=id,
name=name,
status=data['status']
)
new_spec.reach = reach
new_spec.start_kp = start_kp
new_spec.end_kp = end_kp
new_spec.concentration = concentration
new_spec.eg = eg
new_spec.em = em
new_spec.ed = ed
new_spec.rate = rate
new_spec.enabled = enabled
new.append(new_spec) new.append(new_spec)
return new return new
......
...@@ -116,11 +116,12 @@ class InitialConditionTableModel(PamhyrTableModel): ...@@ -116,11 +116,12 @@ class InitialConditionTableModel(PamhyrTableModel):
self._data = data self._data = data
print("init table model : ", self._river)
def _setup_lst(self): def _setup_lst(self):
self._lst = self._data._data self._lst = self._data._data
def rowCount(self, parent):
return len(self._lst)
def data(self, index, role): def data(self, index, role):
if role != Qt.ItemDataRole.DisplayRole: if role != Qt.ItemDataRole.DisplayRole:
return QVariant() return QVariant()
...@@ -135,7 +136,6 @@ class InitialConditionTableModel(PamhyrTableModel): ...@@ -135,7 +136,6 @@ class InitialConditionTableModel(PamhyrTableModel):
return n return n
elif self._headers[column] is "reach": elif self._headers[column] is "reach":
n = self._lst[row].reach n = self._lst[row].reach
print(n)
if n is None: if n is None:
return self._trad['not_associated'] return self._trad['not_associated']
return next(filter(lambda edge: edge.id == n, self._river.edges())).name return next(filter(lambda edge: edge.id == n, self._river.edges())).name
......
...@@ -167,23 +167,26 @@ class AddCommand(QUndoCommand): ...@@ -167,23 +167,26 @@ class AddCommand(QUndoCommand):
if self._new is None: if self._new is None:
self._new = self._data.new(self._index) self._new = self._data.new(self._index)
else: else:
self._ics_spec.insert(self._index, self._new) self._data.insert(self._index, self._new)
class DelCommand(QUndoCommand): class DelCommand(QUndoCommand):
def __init__(self, data, ics_spec, rows): def __init__(self, data, ics_spec, rows):
QUndoCommand.__init__(self) QUndoCommand.__init__(self)
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:
self._ic.append((row, self._ics_spec.get(row))) self._ic.append((row, self._ics_spec[row]))
self._ic.sort() self._ic.sort()
def undo(self): def undo(self):
for row, el in self._ic: for row, el in self._ic:
self._ics_spec.insert(row, el) self._data.insert(row, el)
def redo(self): def redo(self):
self._ics_spec.delete_i(self._rows) self._data.delete_i(self._rows)
...@@ -71,7 +71,6 @@ class InitialConditionsAdisTSWindow(PamhyrWindow): ...@@ -71,7 +71,6 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
def __init__(self, data=None, study=None, config=None, parent=None): def __init__(self, data=None, study=None, config=None, parent=None):
self._data = [] self._data = []
self._data.append(data) self._data.append(data)
print(self._data[0]._data)
trad = IcAdisTSTranslate() trad = IcAdisTSTranslate()
name = ( name = (
...@@ -131,8 +130,8 @@ class InitialConditionsAdisTSWindow(PamhyrWindow): ...@@ -131,8 +130,8 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
toolBar.addAction(action_add) toolBar.addAction(action_add)
toolBar.addAction(action_delete) toolBar.addAction(action_delete)
table_spec = QTableView() self.table_spec = QTableView()
layout.addWidget(table_spec) layout.addWidget(self.table_spec)
self._delegate_reach = ComboBoxDelegate( self._delegate_reach = ComboBoxDelegate(
trad=self._trad, trad=self._trad,
...@@ -150,7 +149,7 @@ class InitialConditionsAdisTSWindow(PamhyrWindow): ...@@ -150,7 +149,7 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
) )
self._table_spec = InitialConditionTableModel( self._table_spec = InitialConditionTableModel(
table_view=table_spec, table_view=self.table_spec,
table_headers=self._trad.get_dict("table_headers_spec"), table_headers=self._trad.get_dict("table_headers_spec"),
editable_headers=["name", "reach", "start_kp", "end_kp", "concentration", "eg", "em", "ed", "rate"], editable_headers=["name", "reach", "start_kp", "end_kp", "concentration", "eg", "em", "ed", "rate"],
delegates={ delegates={
...@@ -164,13 +163,13 @@ class InitialConditionsAdisTSWindow(PamhyrWindow): ...@@ -164,13 +163,13 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
river=self._study.river river=self._study.river
) )
table_spec.setModel(self._table_spec) self.table_spec.setModel(self._table_spec)
table_spec.setSelectionBehavior(QAbstractItemView.SelectRows) self.table_spec.setSelectionBehavior(QAbstractItemView.SelectRows)
table_spec.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table_spec.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
table_spec.setAlternatingRowColors(True) self.table_spec.setAlternatingRowColors(True)
selectionModel = table_spec.selectionModel() selectionModel = self.table_spec.selectionModel()
index = table_spec.model().index(0, 0) index = self.table_spec.model().index(0, 0)
selectionModel.select( selectionModel.select(
index, index,
...@@ -178,10 +177,11 @@ class InitialConditionsAdisTSWindow(PamhyrWindow): ...@@ -178,10 +177,11 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
QItemSelectionModel.ClearAndSelect | QItemSelectionModel.ClearAndSelect |
QItemSelectionModel.Select QItemSelectionModel.Select
) )
table_spec.scrollTo(index) self.table_spec.scrollTo(index)
def index_selected_row(self): def index_selected_row(self):
table = self.find(QTableView, f"tableView") #table = self.find(QTableView, f"tableView")
table = self.table_spec
rows = table.selectionModel()\ rows = table.selectionModel()\
.selectedRows() .selectedRows()
...@@ -191,7 +191,8 @@ class InitialConditionsAdisTSWindow(PamhyrWindow): ...@@ -191,7 +191,8 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
return rows[0].row() return rows[0].row()
def index_selected_rows(self): def index_selected_rows(self):
table = self.find(QTableView, f"tableView") #table = self.find(QTableView, f"tableView")
table = self.table_spec
return list( return list(
# Delete duplicate # Delete duplicate
set( set(
......
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment