From e7e158283697ded7982b1c4d728a2dcc0e8cfab4 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Wed, 27 Mar 2024 09:57:53 +0100 Subject: [PATCH] MainWindow: Checker: Minor change and fixes. --- src/Modules.py | 14 ++++ src/Solver/Mage.py | 6 +- src/View/CheckList/Table.py | 79 ++++++++++---------- src/View/ui/Widgets/MainWindowTabCheckers.ui | 24 ------ src/lang/fr.ts | 58 +++++++------- 5 files changed, 87 insertions(+), 94 deletions(-) diff --git a/src/Modules.py b/src/Modules.py index 90881369..643dd05a 100644 --- a/src/Modules.py +++ b/src/Modules.py @@ -79,3 +79,17 @@ class Modules(Flag): cls.RESERVOIR, cls.SEDIMENT_LAYER, ] + + @classmethod + def modelling_display_name(cls): + return { + cls.NETWORK: "Network", + cls.GEOMETRY: "Geometry", + cls.BOUNDARY_CONDITION: "Boundary condition", + cls.LATERAL_CONTRIBUTION: "Lateral contribution", + cls.FRICTION: "Friction", + cls.INITIAL_CONDITION: "Initial condition", + cls.HYDRAULIC_STRUCTURES: "Hydraulic structures", + cls.RESERVOIR: "Reservoir", + cls.SEDIMENT_LAYER: "Sediment layer", + } diff --git a/src/Solver/Mage.py b/src/Solver/Mage.py index dc95c510..3edce593 100644 --- a/src/Solver/Mage.py +++ b/src/Solver/Mage.py @@ -98,9 +98,9 @@ class Mage(CommandLineSolver): @classmethod def checkers(cls): lst = [ - MageNetworkGraphChecker(connectivity=True), - MageNetworkGraphChecker(connectivity=False), - MageGeometryGuideLineChecker(), + MageNetworkGraphChecker(connectivity=True, version=cls._type), + MageNetworkGraphChecker(connectivity=False, version=cls._type), + MageGeometryGuideLineChecker(version=cls._type), ] return lst diff --git a/src/View/CheckList/Table.py b/src/View/CheckList/Table.py index fc95b901..53828af0 100644 --- a/src/View/CheckList/Table.py +++ b/src/View/CheckList/Table.py @@ -79,6 +79,47 @@ class TabTableModel(PamhyrTableModel): def _setup_lst(self): self._lst = self._opt_data + def data(self, index, role): + row = index.row() + column = index.column() + + if role == Qt.ForegroundRole: + if self._headers[column] == "type": + return QVariant() + + color = Qt.gray + status, _ = self.compute_status(row, column) + + if status is STATUS.OK: + color = Qt.green + elif status is STATUS.WARNING: + color = QColor("orange") + elif status is STATUS.ERROR: + color = Qt.red + + return QBrush(color) + + if role == Qt.ItemDataRole.DisplayRole: + if self._headers[column] == "type": + return self.module_display_name(self._opt_data[row]) + + value = "UNKNOWN" + status, _ = self.compute_status(row, column) + + if status is STATUS.OK: + value = "OK" + elif status is STATUS.WARNING: + value = "WARNING" + elif status is STATUS.ERROR: + value = "ERROR" + + return value + + return QVariant() + + def module_display_name(self, module): + return Modules.modelling_display_name()[module] + def get_checkers(self, row, column): module = self._opt_data[row] solver = self._headers[column] @@ -121,41 +162,3 @@ class TabTableModel(PamhyrTableModel): logger.debug(f"Checkers: {row}, {column}: {checkers_status} {status}") return status, checkers_status - - def data(self, index, role): - row = index.row() - column = index.column() - - if role == Qt.ForegroundRole: - if self._headers[column] == "type": - return QVariant() - - color = Qt.gray - status, _ = self.compute_status(row, column) - - if status is STATUS.OK: - color = Qt.green - elif status is STATUS.WARNING: - color = QColor("orange") - elif status is STATUS.ERROR: - color = Qt.red - - return QBrush(color) - - if role == Qt.ItemDataRole.DisplayRole: - if self._headers[column] == "type": - return str(self._opt_data[row]) - - value = "UNKNOWN" - status, _ = self.compute_status(row, column) - - if status is STATUS.OK: - value = "OK" - elif status is STATUS.WARNING: - value = "WARNING" - elif status is STATUS.ERROR: - value = "ERROR" - - return value - - return QVariant() diff --git a/src/View/ui/Widgets/MainWindowTabCheckers.ui b/src/View/ui/Widgets/MainWindowTabCheckers.ui index 89bb9767..444aac34 100644 --- a/src/View/ui/Widgets/MainWindowTabCheckers.ui +++ b/src/View/ui/Widgets/MainWindowTabCheckers.ui @@ -15,30 +15,6 @@ </property> <layout class="QGridLayout" name="gridLayout_3"> <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="pushButton_restart"> - <property name="text"> - <string>Restart</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="1" column="0"> <widget class="QSplitter" name="splitter_2"> <property name="orientation"> <enum>Qt::Horizontal</enum> diff --git a/src/lang/fr.ts b/src/lang/fr.ts index 339e9fa7..40cbd439 100644 --- a/src/lang/fr.ts +++ b/src/lang/fr.ts @@ -871,130 +871,130 @@ <message> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="54"/> <source>Description:</source> - <translation>Description :</translation> + <translation type="obsolete">Description :</translation> </message> <message> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="68"/> <source>Name:</source> - <translation>Nom :</translation> + <translation type="obsolete">Nom :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="78"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="64"/> <source>@study_name</source> <translation>@study_name</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="88"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="74"/> <source>River network</source> <translation>Réseau de la rivière</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="104"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="90"/> <source>Reach:</source> <translation>Bief :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="131"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="117"/> <source>Node:</source> <translation>Nœud :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="141"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="127"/> <source>@nb_nodes</source> <translation>@nb_nodes</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="158"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="144"/> <source>@nb_edges</source> <translation>@nb_edges</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="124"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="110"/> <source>Current reach:</source> <translation>Bief actuel :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="97"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="83"/> <source>@current_reach</source> <translation>@current_reach</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="216"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="202"/> <source>Geometry</source> <translation>Géometrie</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="258"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="244"/> <source>@nb_points</source> <translation>@nb_points</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="265"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="251"/> <source>Cross-sections:</source> <translation>Section en travers :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="272"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="258"/> <source>Points:</source> <translation>Points :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="282"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="268"/> <source>@nb_cs</source> <translation>@nb_cs</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="148"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="134"/> <source>@nb_res</source> <translation>@nb_res</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="165"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="151"/> <source>Boundary conditions:</source> <translation>Conditions aux limites :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="172"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="158"/> <source>Reservoir:</source> <translation>Casier :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="179"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="165"/> <source>@nb_bc</source> <translation>@nb_bc</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="199"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="185"/> <source>Lateral contributions:</source> <translation>Contributions latérales :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="206"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="192"/> <source>@nb_lc</source> <translation>@nb_lc</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="248"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="234"/> <source>Hydraulic stuctures:</source> <translation>Ouvrages hydrauliques :</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="289"/> + <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="275"/> <source>@nb_hs</source> <translation>@nb_hs</translation> </message> <message> <location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="22"/> <source>Restart</source> - <translation>Relancer</translation> + <translation type="obsolete">Relancer</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="53"/> + <location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="29"/> <source>Checkers list</source> <translation>Liste des vérificateurs</translation> </message> <message> - <location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="63"/> + <location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="39"/> <source>Errors summary</source> <translation>Résumer des erreurs</translation> </message> @@ -1874,7 +1874,7 @@ <message> <location filename="../View/ui/CheckList.ui" line="88"/> <source>Retry check</source> - <translation>Réessayer les verifications</translation> + <translation>Réessayer les vérifications</translation> </message> <message> <location filename="../View/ui/BasicHydraulicStructures.ui" line="14"/> @@ -2149,7 +2149,7 @@ <message> <location filename="../View/Translate.py" line="81"/> <source>Checks</source> - <translation>Verifications</translation> + <translation>Vérifications</translation> </message> <message> <location filename="../View/ui/MainWindow.ui" line="200"/> @@ -2239,7 +2239,7 @@ <message> <location filename="../View/ui/MainWindow.ui" line="568"/> <source>Edit the study information</source> - <translation type="unfinished"></translation> + <translation>Éditer les information de l'étude</translation> </message> </context> <context> -- GitLab