diff --git a/src/View/CheckList/Table.py b/src/View/CheckList/Table.py index 5810c4be6fd2e014513bfc0b898ecbb1c0b771ca..b355eb6c28443401de7ef7d5966e6707e55c0c05 100644 --- a/src/View/CheckList/Table.py +++ b/src/View/CheckList/Table.py @@ -35,25 +35,12 @@ from PyQt5.QtWidgets import ( QComboBox, ) -_translate = QCoreApplication.translate - - -class TableModel(QAbstractTableModel): - def __init__(self, data=None): - super(QAbstractTableModel, self).__init__() - self._headers = ["name", "status"] - self._data = data +from View.Tools.PamhyrTable import PamhyrTableModel - def flags(self, index): - options = Qt.ItemIsEnabled | Qt.ItemIsSelectable - return options - - def rowCount(self, parent): - return len(self._data) +_translate = QCoreApplication.translate - def columnCount(self, parent): - return len(self._headers) +class TableModel(PamhyrTableModel): def data(self, index, role): row = index.row() column = index.column() @@ -81,12 +68,3 @@ class TableModel(QAbstractTableModel): return self._data[row].summary return QVariant() - - def headerData(self, section, orientation, role): - if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal: - return self._headers[section] - - return QVariant() - - def update(self): - self.layoutChanged.emit() diff --git a/src/View/CheckList/Window.py b/src/View/CheckList/Window.py index b02522bcf6c78ba2a45d422b3030c4ea0425c46d..baf99983604b277cf024c9a469df04244a4c7bb7 100644 --- a/src/View/CheckList/Window.py +++ b/src/View/CheckList/Window.py @@ -40,6 +40,7 @@ from PyQt5.QtWidgets import ( from View.CheckList.Table import TableModel from View.CheckList.Worker import Worker +from View.CheckList.Translate import CheckListTranslate _translate = QCoreApplication.translate @@ -61,6 +62,7 @@ class CheckListWindow(PamhyrWindow): title = name, study = study, config = config, + trad = CheckListTranslate(), options = [], parent = parent ) @@ -78,16 +80,12 @@ class CheckListWindow(PamhyrWindow): def setup_table(self): table = self.find(QTableView, f"tableView") - self._table = TableModel( + table_view = table, + table_headers = self._trad.get_dict("table_headers"), data = self._checker_list, ) - table.setModel(self._table) - table.setSelectionBehavior(QAbstractItemView.SelectRows) - table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) - table.setAlternatingRowColors(True) - def setup_progress_bar(self): self._progress = self.find(QProgressBar, f"progressBar") self._p = 0 # Progress current step diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 94acbe39cd82524bb72a925ba67b4cc5cafe2944..20f4f065a17b672ce011fa09210681f06bc93c27 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -53,8 +53,8 @@ from View.Frictions.Window import FrictionsWindow from View.SedimentLayers.Window import SedimentLayersWindow from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow from View.SolverParameters.Window import SolverParametersWindow -# from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow -# from View.CheckList.Window import CheckListWindow +from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow +from View.CheckList.Window import CheckListWindow # from View.Results.Window import ResultsWindow from View.Debug.Window import ReplWindow diff --git a/src/View/Tools/PamhyrTable.py b/src/View/Tools/PamhyrTable.py index 65cd7687a0ce3eee14824f72748580227985a699..d809dceda64d26c5b547925f20e0b0b77d240610 100644 --- a/src/View/Tools/PamhyrTable.py +++ b/src/View/Tools/PamhyrTable.py @@ -33,7 +33,7 @@ from PyQt5.QtWidgets import ( QDialogButtonBox, QPushButton, QLineEdit, QFileDialog, QTableView, QAbstractItemView, QUndoStack, QShortcut, QAction, QItemDelegate, - QComboBox, QStyledItemDelegate, + QComboBox, QStyledItemDelegate, QHeaderView, ) logger = logging.getLogger() @@ -100,10 +100,17 @@ class PamhyrTableModel(QAbstractTableModel): self._setup_delegates() self._setup_lst() + self._table_view_configure() def _setup_lst(self): self._lst = self._data + def _table_view_configure(self): + self._table_view.setModel(self) + self._table_view.setSelectionBehavior(QAbstractItemView.SelectRows) + self._table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) + self._table_view.setAlternatingRowColors(True) + def flags(self, index): column = index.column() @@ -140,3 +147,6 @@ class PamhyrTableModel(QAbstractTableModel): def redo(self): self._undo.redo() self.layoutChanged.emit() + + def update(self): + self.layoutChanged.emit()