Pollutants: Fix scenario update and minor fix.

scenarios
Pierre-Antoine 2025-08-18 10:26:09 +02:00
parent c6ab2647c1
commit 7094ff3e62
2 changed files with 28 additions and 1 deletions

View File

@ -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)

View File

@ -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):