From 5da607865c8f43a9b78fd5f3e80aa5bac0cd3aa6 Mon Sep 17 00:00:00 2001 From: Dylan Jeannin Date: Thu, 3 Sep 2026 11:47:08 +0200 Subject: [PATCH] Pollutants: line becomes grey when we disable a pollutant + it's mentionned 'disabled' on the view only in the tab --- src/View/Pollutants/Table.py | 27 ++++++++++++++++++++++----- src/View/Pollutants/Translate.py | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/View/Pollutants/Table.py b/src/View/Pollutants/Table.py index 24d4bc5b..ccbee16c 100644 --- a/src/View/Pollutants/Table.py +++ b/src/View/Pollutants/Table.py @@ -26,6 +26,7 @@ from PyQt5.QtCore import ( QCoreApplication, QModelIndex, pyqtSlot, QRect, ) +from PyQt5.QtGui import QColor from PyQt5.QtWidgets import ( QDialogButtonBox, QPushButton, QLineEdit, @@ -59,14 +60,23 @@ class TableModel(PamhyrTableModel): return len(self._lst) def data(self, index, role): - if role != Qt.ItemDataRole.DisplayRole: + if not index.isValid(): return QVariant() row = index.row() column = index.column() + if role == Qt.BackgroundRole and not self._lst[row].enabled: + return QColor(190, 190, 190) + + if role != Qt.ItemDataRole.DisplayRole: + return QVariant() + if self._headers[column] == "name": - return self._lst[row].name + name = self._lst[row].name + if not self._lst[row].enabled: + name += f" ({self._trad['disabled']})" + return name return QVariant() @@ -74,12 +84,19 @@ class TableModel(PamhyrTableModel): if not index.isValid() or role != Qt.EditRole: return False - if self.is_same_data(index, value): - return False - row = index.row() column = index.column() + if self._headers[column] == "name": + suffix = f" ({self._trad['disabled']})" + if not self._lst[row].enabled and str(value).endswith(suffix): + value = str(value)[:-len(suffix)] + + if str(self._lst[row].name) == str(value): + return False + elif self.is_same_data(index, value): + return False + try: if self._headers[column] == "name": self._undo.push( diff --git a/src/View/Pollutants/Translate.py b/src/View/Pollutants/Translate.py index a515f7c2..51b51395 100644 --- a/src/View/Pollutants/Translate.py +++ b/src/View/Pollutants/Translate.py @@ -32,6 +32,7 @@ class PollutantsTranslate(MainTranslate): ) self._dict["x"] = _translate("Pollutants", "X (m)") + self._dict["disabled"] = _translate("Pollutants", "disabled") self._sub_dict["table_headers"] = { "name": self._dict["name"],