mirror of https://gitlab.com/pamhyr/pamhyr2
Pollutants: Fix scenario update and minor fix.
parent
c6ab2647c1
commit
7094ff3e62
|
|
@ -163,6 +163,30 @@ class Pollutants(SQLSubModel):
|
|||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_pollutants_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_pollutants_pid(cls, execute, data):
|
||||
pid_pol = data["id2pid"]["Pollutants"]
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, pollutant " +
|
||||
"FROM pollutants_characteristics"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
pol_id = next(it)
|
||||
|
||||
if pol_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE pollutants_characteristics " +
|
||||
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = []
|
||||
|
|
@ -202,7 +226,7 @@ class Pollutants(SQLSubModel):
|
|||
|
||||
if table is not None:
|
||||
for t in table:
|
||||
new_data = t[1:-1]
|
||||
new_data = t[1:-2]
|
||||
|
||||
new_pollutant._data.append(new_data)
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ class TableModel(PamhyrTableModel):
|
|||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if len(self._data.data) == 0 or len(self._data.data[row]) == 0:
|
||||
return QVariant()
|
||||
|
||||
return self._data.data[row][column]
|
||||
|
||||
def setData(self, index, value, role=Qt.EditRole):
|
||||
|
|
|
|||
Loading…
Reference in New Issue